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