Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/DebuggerEventData.java
41161 views
/*1* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22package nsk.share.jdi;2324import com.sun.jdi.*;25import com.sun.jdi.event.*;2627/*28* Classes included in this class represent JDI events on debugger VM's side29* All this classes contain information about JDI event which should be generated during test execution,30* instances of this classes should be created using instances of corresponding classes from debuggee VM31*/32public class DebuggerEventData33{34static abstract class DebugEventData35{3637protected Class<?> eventClass;38public DebugEventData(Class<?> eventClass) {39this.eventClass = eventClass;40}4142public boolean shouldCheckEvent(Event event) {43return this.eventClass.isAssignableFrom(event.getClass());44}4546// is given event's data identical with data stored in this object47abstract public boolean checkEvent(Event event);48}4950/*51* debug information about monitor event52*/53static abstract class DebugMonitorEventData extends DebugEventData {54protected ObjectReference monitor;5556protected ThreadReference thread;5758public DebugMonitorEventData(Class<?> eventClass, ObjectReference debuggeeMirror) {59super(eventClass);6061this.eventClass = eventClass;62monitor = (ObjectReference) debuggeeMirror.getValue(debuggeeMirror.referenceType().fieldByName("monitor"));63thread = (ThreadReference) debuggeeMirror.getValue(debuggeeMirror.referenceType().fieldByName("thread"));64}6566public String toString() {67return eventClass.getName() + " monitor: " + monitor + " thread: " + thread;68}69}7071/*72* information about MonitorContendedEnterEvent73*/74static class DebugMonitorEnterEventData extends DebugMonitorEventData {75public DebugMonitorEnterEventData(ObjectReference debuggeeMirror) {76super(MonitorContendedEnterEvent.class, debuggeeMirror);77}7879public boolean checkEvent(Event event) {80MonitorContendedEnterEvent monitorEnterEvent = (MonitorContendedEnterEvent) event;8182return monitorEnterEvent.monitor().equals(monitor) && monitorEnterEvent.thread().equals(thread);83}84}8586/*87* information about MonitorContendedEnteredEvent88*/89static class DebugMonitorEnteredEventData extends DebugMonitorEventData {90public DebugMonitorEnteredEventData(ObjectReference debuggeeMirror) {91super(MonitorContendedEnteredEvent.class, debuggeeMirror);92}9394public boolean checkEvent(Event event) {95MonitorContendedEnteredEvent monitorEnterEvent = (MonitorContendedEnteredEvent) event;9697return monitorEnterEvent.monitor().equals(monitor) && monitorEnterEvent.thread().equals(thread);98}99}100101/*102* information about MonitorWaitEvent103*/104static class DebugMonitorWaitEventData extends DebugMonitorEventData {105private long timeout;106107public DebugMonitorWaitEventData(ObjectReference debuggeeMirror) {108super(MonitorWaitEvent.class, debuggeeMirror);109110timeout = ((LongValue) debuggeeMirror.getValue(debuggeeMirror.referenceType().fieldByName("timeout"))).longValue();111}112113public boolean checkEvent(Event event) {114MonitorWaitEvent monitorWaitEvent = (MonitorWaitEvent) event;115116return monitorWaitEvent.monitor().equals(monitor) && monitorWaitEvent.thread().equals(thread) && (monitorWaitEvent.timeout() == timeout);117}118119public String toString() {120return eventClass.getName() + " monitor: " + monitor + " thread: " + thread + " timeout: " + timeout;121}122}123124/*125* information about MonitorWaitedEvent126*/127static class DebugMonitorWaitedEventData extends DebugMonitorEventData {128private boolean timedout;129130public DebugMonitorWaitedEventData(ObjectReference debuggeeMirror) {131super(MonitorWaitedEvent.class, debuggeeMirror);132133timedout = ((BooleanValue) debuggeeMirror.getValue(debuggeeMirror.referenceType().fieldByName("timedout"))).booleanValue();134}135136public boolean checkEvent(Event event) {137MonitorWaitedEvent monitorWaitedEvent = (MonitorWaitedEvent) event;138139return monitorWaitedEvent.monitor().equals(monitor) && monitorWaitedEvent.thread().equals(thread)140&& (monitorWaitedEvent.timedout() == timedout);141}142143public String toString() {144return eventClass.getName() + " monitor: " + monitor + " thread: " + thread + " timedout: " + timedout;145}146}147}148149150