Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/DebuggerEventData.java
41161 views
1
/*
2
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
package nsk.share.jdi;
24
25
import com.sun.jdi.*;
26
import com.sun.jdi.event.*;
27
28
/*
29
* Classes included in this class represent JDI events on debugger VM's side
30
* All this classes contain information about JDI event which should be generated during test execution,
31
* instances of this classes should be created using instances of corresponding classes from debuggee VM
32
*/
33
public class DebuggerEventData
34
{
35
static abstract class DebugEventData
36
{
37
38
protected Class<?> eventClass;
39
public DebugEventData(Class<?> eventClass) {
40
this.eventClass = eventClass;
41
}
42
43
public boolean shouldCheckEvent(Event event) {
44
return this.eventClass.isAssignableFrom(event.getClass());
45
}
46
47
// is given event's data identical with data stored in this object
48
abstract public boolean checkEvent(Event event);
49
}
50
51
/*
52
* debug information about monitor event
53
*/
54
static abstract class DebugMonitorEventData extends DebugEventData {
55
protected ObjectReference monitor;
56
57
protected ThreadReference thread;
58
59
public DebugMonitorEventData(Class<?> eventClass, ObjectReference debuggeeMirror) {
60
super(eventClass);
61
62
this.eventClass = eventClass;
63
monitor = (ObjectReference) debuggeeMirror.getValue(debuggeeMirror.referenceType().fieldByName("monitor"));
64
thread = (ThreadReference) debuggeeMirror.getValue(debuggeeMirror.referenceType().fieldByName("thread"));
65
}
66
67
public String toString() {
68
return eventClass.getName() + " monitor: " + monitor + " thread: " + thread;
69
}
70
}
71
72
/*
73
* information about MonitorContendedEnterEvent
74
*/
75
static class DebugMonitorEnterEventData extends DebugMonitorEventData {
76
public DebugMonitorEnterEventData(ObjectReference debuggeeMirror) {
77
super(MonitorContendedEnterEvent.class, debuggeeMirror);
78
}
79
80
public boolean checkEvent(Event event) {
81
MonitorContendedEnterEvent monitorEnterEvent = (MonitorContendedEnterEvent) event;
82
83
return monitorEnterEvent.monitor().equals(monitor) && monitorEnterEvent.thread().equals(thread);
84
}
85
}
86
87
/*
88
* information about MonitorContendedEnteredEvent
89
*/
90
static class DebugMonitorEnteredEventData extends DebugMonitorEventData {
91
public DebugMonitorEnteredEventData(ObjectReference debuggeeMirror) {
92
super(MonitorContendedEnteredEvent.class, debuggeeMirror);
93
}
94
95
public boolean checkEvent(Event event) {
96
MonitorContendedEnteredEvent monitorEnterEvent = (MonitorContendedEnteredEvent) event;
97
98
return monitorEnterEvent.monitor().equals(monitor) && monitorEnterEvent.thread().equals(thread);
99
}
100
}
101
102
/*
103
* information about MonitorWaitEvent
104
*/
105
static class DebugMonitorWaitEventData extends DebugMonitorEventData {
106
private long timeout;
107
108
public DebugMonitorWaitEventData(ObjectReference debuggeeMirror) {
109
super(MonitorWaitEvent.class, debuggeeMirror);
110
111
timeout = ((LongValue) debuggeeMirror.getValue(debuggeeMirror.referenceType().fieldByName("timeout"))).longValue();
112
}
113
114
public boolean checkEvent(Event event) {
115
MonitorWaitEvent monitorWaitEvent = (MonitorWaitEvent) event;
116
117
return monitorWaitEvent.monitor().equals(monitor) && monitorWaitEvent.thread().equals(thread) && (monitorWaitEvent.timeout() == timeout);
118
}
119
120
public String toString() {
121
return eventClass.getName() + " monitor: " + monitor + " thread: " + thread + " timeout: " + timeout;
122
}
123
}
124
125
/*
126
* information about MonitorWaitedEvent
127
*/
128
static class DebugMonitorWaitedEventData extends DebugMonitorEventData {
129
private boolean timedout;
130
131
public DebugMonitorWaitedEventData(ObjectReference debuggeeMirror) {
132
super(MonitorWaitedEvent.class, debuggeeMirror);
133
134
timedout = ((BooleanValue) debuggeeMirror.getValue(debuggeeMirror.referenceType().fieldByName("timedout"))).booleanValue();
135
}
136
137
public boolean checkEvent(Event event) {
138
MonitorWaitedEvent monitorWaitedEvent = (MonitorWaitedEvent) event;
139
140
return monitorWaitedEvent.monitor().equals(monitor) && monitorWaitedEvent.thread().equals(thread)
141
&& (monitorWaitedEvent.timedout() == timedout);
142
}
143
144
public String toString() {
145
return eventClass.getName() + " monitor: " + monitor + " thread: " + thread + " timedout: " + timedout;
146
}
147
}
148
}
149
150