test/jdk/com/sun/jdi/TestScaffold.java
author gadams
Tue, 23 Oct 2018 11:51:03 -0400
changeset 52365 45e3d52aaced
parent 52068 218b5b64f102
permissions -rw-r--r--
8206330: Revisit com/sun/jdi/RedefineCrossEvent.java Reviewed-by: cjplummer, sspitsyn, amenkov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
52068
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
     2
 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
import com.sun.jdi.request.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
import com.sun.jdi.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Framework used by all JDI regression tests
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
abstract public class TestScaffold extends TargetAdapter {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    private boolean shouldTrace = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    private VMConnection connection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    private VirtualMachine vm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    private EventRequestManager requestManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    private List listeners = Collections.synchronizedList(new LinkedList());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    private boolean redefineAtStart = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    private boolean redefineAtEvents = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private boolean redefineAsynchronously = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    private ReferenceType mainStartClass = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    ThreadReference mainThread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * We create a VMDeathRequest, SUSPEND_ALL, to sync the BE and FE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private VMDeathRequest ourVMDeathRequest = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * We create an ExceptionRequest, SUSPEND_NONE so that we can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * catch it and output a msg if an exception occurs in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * debuggee.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private ExceptionRequest ourExceptionRequest = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * If we do catch an uncaught exception, we set this true
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * so the testcase can find out if it wants to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private boolean exceptionCaught = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    ThreadReference vmStartThread = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    boolean vmDied = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    boolean vmDisconnected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    final String[] args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    protected boolean testFailed = false;
37321
d069569242e3 7153107: com/sun/jdi/InterruptHangTest.java fails in nightlies
sla
parents: 36424
diff changeset
    67
    protected long startTime;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    static private class ArgInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        String targetVMArgs = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        String targetAppCommandLine = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        String connectorSpec = "com.sun.jdi.CommandLineLaunch:";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        int traceFlags = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * An easy way to sleep for awhile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public void mySleep(int millis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            Thread.sleep(millis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        } catch (InterruptedException ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    boolean getExceptionCaught() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        return exceptionCaught;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    void setExceptionCaught(boolean value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        exceptionCaught = value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * Return true if eventSet contains the VMDeathEvent for the request in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * the ourVMDeathRequest ivar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    private boolean containsOurVMDeathRequest(EventSet eventSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        if (ourVMDeathRequest != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            Iterator myIter = eventSet.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            while (myIter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                Event myEvent = (Event)myIter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                if (!(myEvent instanceof VMDeathEvent)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                    // We assume that an EventSet contains only VMDeathEvents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                    // or no VMDeathEvents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                if (ourVMDeathRequest.equals(myEvent.request())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * The following methods override those in our base class, TargetAdapter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Events handled directly by scaffold always resume (well, almost always)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public void eventSetComplete(EventSet set) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        // The listener in connect(..) resumes after receiving our
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        // special VMDeathEvent.  We can't also do the resume
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        // here or we will probably get a VMDisconnectedException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        if (!containsOurVMDeathRequest(set)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            traceln("TS: set.resume() called");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            set.resume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * This method sets up default requests.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Testcases can override this to change default behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    protected void createDefaultEventRequests() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        createDefaultVMDeathRequest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        createDefaultExceptionRequest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * We want the BE to stop when it issues a VMDeathEvent in order to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * give the FE time to complete handling events that occured before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * the VMDeath.  When we get the VMDeathEvent for this request in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * the listener in connect(), we will do a resume.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * If a testcase wants to do something special with VMDeathEvent's,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * then it should override this method with an empty method or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * whatever in order to suppress the automatic resume.  The testcase
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * will then be responsible for the handling of VMDeathEvents.  It
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * has to be sure that it does a resume if it gets a VMDeathEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * with SUSPEND_ALL, and it has to be sure that it doesn't do a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * resume after getting a VMDeath with SUSPEND_NONE (the automatically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * generated VMDeathEvent.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    protected void createDefaultVMDeathRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        ourVMDeathRequest = requestManager.createVMDeathRequest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        ourVMDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        ourVMDeathRequest.enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * This will allow us to print a warning if a debuggee gets an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * unexpected exception.  The unexpected exception will be handled in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * the exceptionThrown method in the listener created in the connect()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * If a testcase does not want an uncaught exception to cause a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * msg, it must override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    protected void createDefaultExceptionRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        ourExceptionRequest = requestManager.createExceptionRequest(null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                                                                false, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        // We can't afford to make this be other than SUSPEND_NONE.  Otherwise,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        // it would have to be resumed.  If our connect() listener resumes it,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        // what about the case where the EventSet contains other events with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        // SUSPEND_ALL and there are other listeners who expect the BE to still
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        // be suspended when their handlers get called?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        ourExceptionRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        ourExceptionRequest.enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    private class EventHandler implements Runnable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        EventHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            Thread thread = new Thread(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            thread.setDaemon(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            thread.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        private void notifyEvent(TargetListener listener, Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            if (event instanceof BreakpointEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                listener.breakpointReached((BreakpointEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            } else if (event instanceof ExceptionEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                listener.exceptionThrown((ExceptionEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            } else if (event instanceof StepEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                listener.stepCompleted((StepEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            } else if (event instanceof ClassPrepareEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                listener.classPrepared((ClassPrepareEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            } else if (event instanceof ClassUnloadEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                listener.classUnloaded((ClassUnloadEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            } else if (event instanceof MethodEntryEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                listener.methodEntered((MethodEntryEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            } else if (event instanceof MethodExitEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                listener.methodExited((MethodExitEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            } else if (event instanceof MonitorContendedEnterEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                listener.monitorContendedEnter((MonitorContendedEnterEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            } else if (event instanceof MonitorContendedEnteredEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                listener.monitorContendedEntered((MonitorContendedEnteredEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            } else if (event instanceof MonitorWaitEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                listener.monitorWait((MonitorWaitEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            } else if (event instanceof MonitorWaitedEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                listener.monitorWaited((MonitorWaitedEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            } else if (event instanceof AccessWatchpointEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                listener.fieldAccessed((AccessWatchpointEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            } else if (event instanceof ModificationWatchpointEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                listener.fieldModified((ModificationWatchpointEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            } else if (event instanceof ThreadStartEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                listener.threadStarted((ThreadStartEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            } else if (event instanceof ThreadDeathEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                listener.threadDied((ThreadDeathEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            } else if (event instanceof VMStartEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                listener.vmStarted((VMStartEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            } else if (event instanceof VMDeathEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                listener.vmDied((VMDeathEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            } else if (event instanceof VMDisconnectEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                listener.vmDisconnected((VMDisconnectEvent)event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                throw new InternalError("Unknown event type: " + event.getClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        private void traceSuspendPolicy(int policy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            if (shouldTrace) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                switch (policy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                case EventRequest.SUSPEND_NONE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                    traceln("TS: eventHandler: suspend = SUSPEND_NONE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                case EventRequest.SUSPEND_ALL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                    traceln("TS: eventHandler: suspend = SUSPEND_ALL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                case EventRequest.SUSPEND_EVENT_THREAD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                    traceln("TS: eventHandler: suspend = SUSPEND_EVENT_THREAD");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            boolean connected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                    EventSet set = vm.eventQueue().remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                    traceSuspendPolicy(set.suspendPolicy());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                    synchronized (listeners) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                        ListIterator iter = listeners.listIterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                        while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                            TargetListener listener = (TargetListener)iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                            traceln("TS: eventHandler: listener = " + listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                            listener.eventSetReceived(set);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                            if (listener.shouldRemoveListener()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                                iter.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                                Iterator jter = set.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                                while (jter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                                    Event event = (Event)jter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                                    traceln("TS: eventHandler:    event = " + event.getClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                                    if (event instanceof VMDisconnectEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                                        connected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                                    listener.eventReceived(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                                    if (listener.shouldRemoveListener()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                                        iter.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                                    notifyEvent(listener, event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                                    if (listener.shouldRemoveListener()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                                        iter.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                                traceln("TS: eventHandler:   end of events loop");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                                if (!listener.shouldRemoveListener()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                                    traceln("TS: eventHandler:   calling ESC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                                    listener.eventSetComplete(set);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                                    if (listener.shouldRemoveListener()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                                        iter.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                            traceln("TS: eventHandler: end of listeners loop");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                } catch (InterruptedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                    traceln("TS: eventHandler: InterruptedException");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                    failure("FAILED: Exception occured in eventHandler: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                    e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                    connected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                    synchronized(TestScaffold.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                        // This will make the waiters such as waitForVMDisconnect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                        // exit their wait loops.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                        vmDisconnected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                        TestScaffold.this.notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                traceln("TS: eventHandler: End of outerloop");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            } while (connected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            traceln("TS: eventHandler: finished");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * Constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    public TestScaffold(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        this.args = args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    public void enableScaffoldTrace() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        this.shouldTrace = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    public void disableScaffoldTrace() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        this.shouldTrace = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * Helper for the redefine method.  Build the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * needed for a redefine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    protected Map makeRedefineMap(ReferenceType rt) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        String className = rt.name();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        File path = new File(System.getProperty("test.classes", "."));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        className = className.replace('.', File.separatorChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        File phyl = new File(path, className + ".class");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        byte[] bytes = new byte[(int)phyl.length()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        InputStream in = new FileInputStream(phyl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        in.read(bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        Map map = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        map.put(rt, bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        return map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * Redefine a class - HotSwap it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    protected void redefine(ReferenceType rt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            println("Redefining " + rt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            vm().redefineClasses(makeRedefineMap(rt));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        } catch (Exception exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            failure("FAIL: redefine - unexpected exception: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    protected void startUp(String targetName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        List argList = new ArrayList(Arrays.asList(args));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        argList.add(targetName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        println("run args: " + argList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        connect((String[]) argList.toArray(args));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        waitForVMStart();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    protected BreakpointEvent startToMain(String targetName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        return startTo(targetName, "main", "([Ljava/lang/String;)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    protected BreakpointEvent startTo(String targetName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                                      String methodName, String signature) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        startUp(targetName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        traceln("TS: back from startUp");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        BreakpointEvent bpr = resumeTo(targetName, methodName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                                       signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        Location loc = bpr.location();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        mainStartClass = loc.declaringType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        if (redefineAtStart) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            redefine(mainStartClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        if (redefineAsynchronously) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            Thread asyncDaemon = new Thread("Async Redefine") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                        Map redefMap = makeRedefineMap(mainStartClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                        while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                            println("Redefining " + mainStartClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                            vm().redefineClasses(redefMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                            Thread.sleep(100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                    } catch (VMDisconnectedException vmde) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                        println("async redefine - VM disconnected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                    } catch (Exception exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                        failure("FAIL: async redefine - unexpected exception: " + exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            asyncDaemon.setDaemon(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            asyncDaemon.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        if (System.getProperty("jpda.wait") != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            waitForInput();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        return bpr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    protected void waitForInput() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            System.err.println("Press <enter> to continue");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            System.in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            System.err.println("running...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        } catch(Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * Test cases should implement tests in runTests and should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * initiate testing by calling run().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    abstract protected void runTests() throws Exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    final public void startTests() throws Exception {
37321
d069569242e3 7153107: com/sun/jdi/InterruptHangTest.java fails in nightlies
sla
parents: 36424
diff changeset
   429
        startTime = System.currentTimeMillis();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            runTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            shutdown();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    protected void println(String str) {
37321
d069569242e3 7153107: com/sun/jdi/InterruptHangTest.java fails in nightlies
sla
parents: 36424
diff changeset
   438
        long elapsed = System.currentTimeMillis() - startTime;
d069569242e3 7153107: com/sun/jdi/InterruptHangTest.java fails in nightlies
sla
parents: 36424
diff changeset
   439
        System.err.println("[" + elapsed + "ms] " + str);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    protected void print(String str) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        System.err.print(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    protected void traceln(String str) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        if (shouldTrace) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            println(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    protected void failure(String str) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        println(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    private ArgInfo parseArgs(String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        ArgInfo argInfo = new ArgInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        for (int i = 0; i < args.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            if (args[i].equals("-connect")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                i++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                argInfo.connectorSpec = args[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            } else if (args[i].equals("-trace")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                i++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                argInfo.traceFlags = Integer.decode(args[i]).intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            } else if (args[i].equals("-redefstart")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                redefineAtStart = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            } else if (args[i].equals("-redefevent")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                redefineAtEvents = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            } else if (args[i].equals("-redefasync")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                redefineAsynchronously = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            } else if (args[i].startsWith("-J")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                argInfo.targetVMArgs += (args[i].substring(2) + ' ');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                 * classpath can span two arguments so we need to handle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                 * it specially.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                if (args[i].equals("-J-classpath")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                    i++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                    argInfo.targetVMArgs += (args[i] + ' ');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                argInfo.targetAppCommandLine += (args[i] + ' ');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        return argInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * This is called to connect to a debuggee VM.  It starts the VM and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * installs a listener to catch VMStartEvent, our default events, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * VMDisconnectedEvent.  When these events appear, that is remembered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * and waiters are notified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * This is normally called in the main thread of the test case.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * It starts up an EventHandler thread that gets events coming in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * from the debuggee and distributes them to listeners.  That thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * keeps running until a VMDisconnectedEvent occurs or some exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * occurs during its processing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * The 'listenUntilVMDisconnect' method adds 'this' as a listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * This means that 'this's vmDied method will get called.  This has a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * default impl in TargetAdapter.java which can be overridden in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * testcase.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * waitForRequestedEvent also adds an adaptor listener that listens
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * for the particular event it is supposed to wait for (and it also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * catches VMDisconnectEvents.)  This listener is removed once
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * its eventReceived method is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * waitForRequestedEvent is called by most of the methods to do bkpts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    public void connect(String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        ArgInfo argInfo = parseArgs(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        argInfo.targetVMArgs += VMConnection.getDebuggeeVMOptions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        connection = new VMConnection(argInfo.connectorSpec,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                                      argInfo.traceFlags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        addListener(new TargetAdapter() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                public void eventSetComplete(EventSet set) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                    if (TestScaffold.this.containsOurVMDeathRequest(set)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                        traceln("TS: connect: set.resume() called");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                        set.resume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                        // Note that we want to do the above resume before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                        // waking up any sleepers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                        synchronized(TestScaffold.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                            TestScaffold.this.notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                public void eventReceived(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                    if (redefineAtEvents && event instanceof Locatable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                        Location loc = ((Locatable)event).location();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                        ReferenceType rt = loc.declaringType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                        String name = rt.name();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                        if (name.startsWith("java.") &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                                       !name.startsWith("sun.") &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                                       !name.startsWith("com.")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                            if (mainStartClass != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                                redefine(mainStartClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                        } else {
52365
45e3d52aaced 8206330: Revisit com/sun/jdi/RedefineCrossEvent.java
gadams
parents: 52068
diff changeset
   545
                            if (!name.startsWith("jdk.")) {
45e3d52aaced 8206330: Revisit com/sun/jdi/RedefineCrossEvent.java
gadams
parents: 52068
diff changeset
   546
                                redefine(rt);
45e3d52aaced 8206330: Revisit com/sun/jdi/RedefineCrossEvent.java
gadams
parents: 52068
diff changeset
   547
                            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                public void vmStarted(VMStartEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                    synchronized(TestScaffold.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                        vmStartThread = event.thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                        TestScaffold.this.notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                 * By default, we catch uncaught exceptions and print a msg.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                 * The testcase must override the createDefaultExceptionRequest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                 * method if it doesn't want this behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                public void exceptionThrown(ExceptionEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                    if (TestScaffold.this.ourExceptionRequest != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                        TestScaffold.this.ourExceptionRequest.equals(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                                                        event.request())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                         * See
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                         *    5038723: com/sun/jdi/sde/TemperatureTableTest.java:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                         *             intermittent ObjectCollectedException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                         * Since this request was SUSPEND_NONE, the debuggee
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                         * could keep running and the calls below back into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                         * the debuggee might not work.  That is why we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                         * have this try/catch.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                            println("Note: Unexpected Debuggee Exception: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                                    event.exception().referenceType().name() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                                    " at line " + event.location().lineNumber());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                            TestScaffold.this.exceptionCaught = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                            ObjectReference obj = event.exception();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                            ReferenceType rtt = obj.referenceType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                            Field detail = rtt.fieldByName("detailMessage");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                            Value val = obj.getValue(detail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                            println("detailMessage = " + val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                             * This code is commented out because it needs a thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                             * in which to do the invokeMethod and we don't have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                             * one.  To enable this code change the request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                             * to be SUSPEND_ALL in createDefaultExceptionRequest,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                             * and then put this line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                             *    mainThread = bpe.thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                             * in the testcase after the line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                             *    BreakpointEvent bpe = startToMain("....");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                            if (false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                                List lll = rtt.methodsByName("printStackTrace");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                                Method mm = (Method)lll.get(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                                obj.invokeMethod(mainThread, mm, new ArrayList(0), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                        } catch (Exception ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                            println("TestScaffold Exception while handling debuggee Exception: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                                    + ee);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                public void vmDied(VMDeathEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                    vmDied = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                    traceln("TS: vmDied called");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                public void vmDisconnected(VMDisconnectEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                    synchronized(TestScaffold.this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                        vmDisconnected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                        TestScaffold.this.notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        if (connection.connector().name().equals("com.sun.jdi.CommandLineLaunch")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            if (argInfo.targetVMArgs.length() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                if (connection.connectorArg("options").length() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                    throw new IllegalArgumentException("VM options in two places");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                connection.setConnectorArg("options", argInfo.targetVMArgs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            if (argInfo.targetAppCommandLine.length() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                if (connection.connectorArg("main").length() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                    throw new IllegalArgumentException("Command line in two places");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                connection.setConnectorArg("main", argInfo.targetAppCommandLine);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        vm = connection.open();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        requestManager = vm.eventRequestManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        createDefaultEventRequests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        new EventHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    public VirtualMachine vm() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        return vm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    public EventRequestManager eventRequestManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        return requestManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    public void addListener(TargetListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        traceln("TS: Adding listener " + listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        listeners.add(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    public void removeListener(TargetListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        traceln("TS: Removing listener " + listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        listeners.remove(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    protected void listenUntilVMDisconnect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            addListener (this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        } catch (Exception ex){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            ex.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
            // Allow application to complete and shut down
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            resumeToVMDisconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    public synchronized ThreadReference waitForVMStart() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        while ((vmStartThread == null) && !vmDisconnected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                wait();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            } catch (InterruptedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        if (vmStartThread == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            throw new VMDisconnectedException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        return vmStartThread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    public synchronized void waitForVMDisconnect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        traceln("TS: waitForVMDisconnect");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        while (!vmDisconnected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                wait();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            } catch (InterruptedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        traceln("TS: waitForVMDisconnect: done");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    public Event waitForRequestedEvent(final EventRequest request) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        class EventNotification {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            Event event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            boolean disconnected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        final EventNotification en = new EventNotification();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        TargetAdapter adapter = new TargetAdapter() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            public void eventReceived(Event event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                if (request.equals(event.request())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                    traceln("TS:Listener2: got requested event");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                    synchronized (en) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                        en.event = event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                        en.notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                    removeThisListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                } else if (event instanceof VMDisconnectEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                    traceln("TS:Listener2: got VMDisconnectEvent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                    synchronized (en) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                        en.disconnected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                        en.notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                    removeThisListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        addListener(adapter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
            synchronized (en) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                traceln("TS: waitForRequestedEvent: vm.resume called");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                vm.resume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                while (!en.disconnected && (en.event == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                    en.wait();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        } catch (InterruptedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        if (en.disconnected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            throw new RuntimeException("VM Disconnected before requested event occurred");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        return en.event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    private StepEvent doStep(ThreadReference thread, int gran, int depth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        final StepRequest sr =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                  requestManager.createStepRequest(thread, gran, depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        sr.addClassExclusionFilter("java.*");
20184
a2c4b7079eb6 8024985: com/sun/jdi/StepTest.java failed since jdk8b107
sla
parents: 5506
diff changeset
   754
        sr.addClassExclusionFilter("javax.*");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        sr.addClassExclusionFilter("sun.*");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        sr.addClassExclusionFilter("com.sun.*");
20184
a2c4b7079eb6 8024985: com/sun/jdi/StepTest.java failed since jdk8b107
sla
parents: 5506
diff changeset
   757
        sr.addClassExclusionFilter("com.oracle.*");
a2c4b7079eb6 8024985: com/sun/jdi/StepTest.java failed since jdk8b107
sla
parents: 5506
diff changeset
   758
        sr.addClassExclusionFilter("oracle.*");
a2c4b7079eb6 8024985: com/sun/jdi/StepTest.java failed since jdk8b107
sla
parents: 5506
diff changeset
   759
        sr.addClassExclusionFilter("jdk.internal.*");
36424
741c43b676d4 8151053: com/sun/jdi/StepTest.java fails in 2016-03-01 JDK9-hs-rt nightly
mgronlun
parents: 23010
diff changeset
   760
        sr.addClassExclusionFilter("jdk.jfr.*");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        sr.addCountFilter(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        sr.enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        StepEvent retEvent = (StepEvent)waitForRequestedEvent(sr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        requestManager.deleteEventRequest(sr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        return retEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    public StepEvent stepIntoInstruction(ThreadReference thread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        return doStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_INTO);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    public StepEvent stepIntoLine(ThreadReference thread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        return doStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_INTO);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    public StepEvent stepOverInstruction(ThreadReference thread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        return doStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OVER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    public StepEvent stepOverLine(ThreadReference thread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        return doStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_OVER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    public StepEvent stepOut(ThreadReference thread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        return doStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_OUT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    public BreakpointEvent resumeTo(Location loc) {
52068
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   789
        return resumeTo(loc, false);
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   790
    }
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   791
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   792
    public BreakpointEvent resumeTo(Location loc, boolean suspendThread) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        final BreakpointRequest request =
52068
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   794
                requestManager.createBreakpointRequest(loc);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        request.addCountFilter(1);
52068
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   796
        if (suspendThread) {
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   797
            request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   798
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        request.enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        return (BreakpointEvent)waitForRequestedEvent(request);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
    public ReferenceType findReferenceType(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        List rts = vm.classesByName(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        Iterator iter = rts.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            ReferenceType rt = (ReferenceType)iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
            if (rt.name().equals(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                return rt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    public Method findMethod(ReferenceType rt, String name, String signature) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        List methods = rt.methods();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        Iterator iter = methods.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
            Method method = (Method)iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
            if (method.name().equals(name) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
                method.signature().equals(signature)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
                return method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    public Location findLocation(ReferenceType rt, int lineNumber)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                         throws AbsentInformationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        List locs = rt.locationsOfLine(lineNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        if (locs.size() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            throw new IllegalArgumentException("Bad line number");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        } else if (locs.size() > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            throw new IllegalArgumentException("Line number has multiple locations");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        return (Location)locs.get(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    public BreakpointEvent resumeTo(String clsName, String methodName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                                         String methodSignature) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        ReferenceType rt = findReferenceType(clsName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        if (rt == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            rt = resumeToPrepareOf(clsName).referenceType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        Method method = findMethod(rt, methodName, methodSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        if (method == null) {
20184
a2c4b7079eb6 8024985: com/sun/jdi/StepTest.java failed since jdk8b107
sla
parents: 5506
diff changeset
   849
            throw new IllegalArgumentException("Bad method name/signature: "
a2c4b7079eb6 8024985: com/sun/jdi/StepTest.java failed since jdk8b107
sla
parents: 5506
diff changeset
   850
                    + clsName + "." + methodName + ":" + methodSignature);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        return resumeTo(method.location());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    public BreakpointEvent resumeTo(String clsName, int lineNumber) throws AbsentInformationException {
52068
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   857
        return resumeTo(clsName, lineNumber, false);
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   858
    }
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   859
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   860
    public BreakpointEvent resumeTo(String clsName, int lineNumber, boolean suspendThread) throws AbsentInformationException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        ReferenceType rt = findReferenceType(clsName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        if (rt == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
            rt = resumeToPrepareOf(clsName).referenceType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
52068
218b5b64f102 8193879: Java debugger hangs on method invocation
dtitov
parents: 47216
diff changeset
   866
        return resumeTo(findLocation(rt, lineNumber), suspendThread);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    public ClassPrepareEvent resumeToPrepareOf(String className) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        final ClassPrepareRequest request =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            requestManager.createClassPrepareRequest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        request.addClassFilter(className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        request.addCountFilter(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        request.enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        return (ClassPrepareEvent)waitForRequestedEvent(request);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    public void resumeForMsecs(long msecs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            addListener (this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        } catch (Exception ex){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            ex.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
            vm().resume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        } catch (VMDisconnectedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        if (!vmDisconnected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
                System.out.println("Sleeping for " + msecs + " milleseconds");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
                Thread.sleep(msecs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
                vm().suspend();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            } catch (InterruptedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    public void resumeToVMDisconnect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            traceln("TS: resumeToVMDisconnect: vm.resume called");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            vm.resume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        } catch (VMDisconnectedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            // clean up below
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        waitForVMDisconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    public void shutdown() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
        shutdown(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    public void shutdown(String message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
        traceln("TS: shutdown: vmDied= " + vmDied +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                 ", vmDisconnected= " + vmDisconnected +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                 ", connection = " + connection);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        if ((connection != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                connection.disposeVM();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
             } catch (VMDisconnectedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                // Shutting down after the VM has gone away. This is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                // not an error, and we just ignore it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            traceln("TS: shutdown: disposeVM not called");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        if (message != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            println(message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        vmDied = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        vmDisconnected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
}