/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/**
* Framework used by all JDI regression tests
*/
private boolean shouldTrace = false;
/**
* We create a VMDeathRequest, SUSPEND_ALL, to sync the BE and FE.
*/
//private VMDeathRequest ourVMDeathRequest = null;
/**
* We create an ExceptionRequest, SUSPEND_NONE so that we can
* catch it and output a msg if an exception occurs in the
* debuggee.
*/
/**
* If we do catch an uncaught exception, we set this true
* so the testcase can find out if it wants to.
*/
private boolean exceptionCaught = false;
boolean vmDied = false;
boolean vmDisconnected = false;
protected boolean testFailed = false;
static private class ArgInfo {
}
/**
* An easy way to sleep for awhile
*/
try {
} catch (InterruptedException ee) {
}
}
boolean getExceptionCaught() {
return exceptionCaught;
}
}
/**
* Return true if eventSet contains the VMDeathEvent for the request in
* the ourVMDeathRequest ivar.
*/
if (ourVMDeathRequest != null) {
if (!(myEvent instanceof VMDeathEvent)) {
// We assume that an EventSet contains only VMDeathEvents
// or no VMDeathEvents.
break;
}
return true;
}
}
}
return false;
}
/************************************************************************
* The following methods override those in our base class, TargetAdapter.
*************************************************************************/
/**
* Events handled directly by scaffold always resume (well, almost always)
*/
// The listener in connect(..) resumes after receiving our
// special VMDeathEvent. We can't also do the resume
// here or we will probably get a VMDisconnectedException
if (!containsOurVMDeathRequest(set)) {
traceln("TS: set.resume() called");
}
}
/**
* This method sets up default requests.
* Testcases can override this to change default behavior.
*/
protected void createDefaultEventRequests() {
}
/**
* We want the BE to stop when it issues a VMDeathEvent in order to
* give the FE time to complete handling events that occured before
* the VMDeath. When we get the VMDeathEvent for this request in
* the listener in connect(), we will do a resume.
* If a testcase wants to do something special with VMDeathEvent's,
* then it should override this method with an empty method or
* whatever in order to suppress the automatic resume. The testcase
* will then be responsible for the handling of VMDeathEvents. It
* has to be sure that it does a resume if it gets a VMDeathEvent
* with SUSPEND_ALL, and it has to be sure that it doesn't do a
* resume after getting a VMDeath with SUSPEND_NONE (the automatically
* generated VMDeathEvent.)
*/
protected void createDefaultVMDeathRequest() {
// ourVMDeathRequest = requestManager.createVMDeathRequest();
// ourVMDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
// ourVMDeathRequest.enable();
}
/**
* This will allow us to print a warning if a debuggee gets an
* unexpected exception. The unexpected exception will be handled in
* the exceptionThrown method in the listener created in the connect()
* method.
* If a testcase does not want an uncaught exception to cause a
* msg, it must override this method.
*/
protected void createDefaultExceptionRequest() {
false, true);
// We can't afford to make this be other than SUSPEND_NONE. Otherwise,
// it would have to be resumed. If our connect() listener resumes it,
// what about the case where the EventSet contains other events with
// SUSPEND_ALL and there are other listeners who expect the BE to still
// be suspended when their handlers get called?
}
EventHandler() {
}
if (event instanceof BreakpointEvent) {
} else if (event instanceof ExceptionEvent) {
} else if (event instanceof ClassPrepareEvent) {
} else if (event instanceof ClassUnloadEvent) {
} else if (event instanceof MethodEntryEvent) {
} else if (event instanceof MethodExitEvent) {
} else if (event instanceof AccessWatchpointEvent) {
} else if (event instanceof ModificationWatchpointEvent) {
} else if (event instanceof ThreadStartEvent) {
} else if (event instanceof ThreadDeathEvent) {
} else if (event instanceof VMStartEvent) {
} else if (event instanceof VMDeathEvent) {
} else if (event instanceof VMDisconnectEvent) {
} else {
}
}
if (shouldTrace) {
switch (policy) {
case EventRequest.SUSPEND_NONE:
traceln("TS: eventHandler: suspend = SUSPEND_NONE");
break;
case EventRequest.SUSPEND_ALL:
traceln("TS: eventHandler: suspend = SUSPEND_ALL");
break;
traceln("TS: eventHandler: suspend = SUSPEND_EVENT_THREAD");
break;
}
}
}
public void run() {
boolean connected = true;
do {
try {
synchronized (listeners) {
if (listener.shouldRemoveListener()) {
} else {
if (event instanceof VMDisconnectEvent) {
connected = false;
}
if (listener.shouldRemoveListener()) {
break;
}
if (listener.shouldRemoveListener()) {
break;
}
}
traceln("TS: eventHandler: end of events loop");
if (!listener.shouldRemoveListener()) {
traceln("TS: eventHandler: calling ESC");
if (listener.shouldRemoveListener()) {
}
}
}
traceln("TS: eventHandler: end of listeners loop");
}
}
} catch (InterruptedException e) {
traceln("TS: eventHandler: InterruptedException");
} catch (Exception e) {
failure("FAILED: Exception occured in eventHandler: " + e);
e.printStackTrace();
connected = false;
synchronized(TestScaffold.this) {
// This will make the waiters such as waitForVMDisconnect
// exit their wait loops.
vmDisconnected = true;
TestScaffold.this.notifyAll();
}
}
traceln("TS: eventHandler: End of outerloop");
} while (connected);
traceln("TS: eventHandler: finished");
}
}
/**
* Constructor
*/
}
public void enableScaffoldTrace() {
this.shouldTrace = true;
}
public void disableScaffoldTrace() {
this.shouldTrace = false;
}
}
traceln("TS: back from startUp");
waitForInput();
return bpr;
}
protected void waitForInput() {
try {
} catch(Exception e) {
}
}
}
/*
* Test cases should implement tests in runTests and should
* initiate testing by calling run().
*/
try {
runTests();
} finally {
shutdown();
}
}
}
}
if (shouldTrace) {
}
}
testFailed = true;
}
i++;
i++;
/*
* classpath can span two arguments so we need to handle
* it specially.
*/
i++;
}
} else {
}
}
return argInfo;
}
/**
* This is called to connect to a debuggee VM. It starts the VM and
* installs a listener to catch VMStartEvent, our default events, and
* VMDisconnectedEvent. When these events appear, that is remembered
* and waiters are notified.
* This is normally called in the main thread of the test case.
* It starts up an EventHandler thread that gets events coming in
* from the debuggee and distributes them to listeners. That thread
* keeps running until a VMDisconnectedEvent occurs or some exception
* occurs during its processing.
*
* The 'listenUntilVMDisconnect' method adds 'this' as a listener.
* This means that 'this's vmDied method will get called. This has a
* default impl in TargetAdapter.java which can be overridden in the
* testcase.
*
* waitForRequestedEvent also adds an adaptor listener that listens
* for the particular event it is supposed to wait for (and it also
* catches VMDisconnectEvents.) This listener is removed once
* its eventReceived method is called.
* waitForRequestedEvent is called by most of the methods to do bkpts,
* etc.
*/
addListener(new TargetAdapter() {
traceln("TS: connect: set.resume() called");
// Note that we want to do the above resume before
// waking up any sleepers.
synchronized(TestScaffold.this) {
TestScaffold.this.notifyAll();
}
}
}
synchronized(TestScaffold.this) {
TestScaffold.this.notifyAll();
}
}
/**
* By default, we catch uncaught exceptions and print a msg.
* The testcase must override the createDefaultExceptionRequest
* method if it doesn't want this behavior.
*/
println("Note: Unexpected Debuggee Exception: " +
TestScaffold.this.exceptionCaught = true;
}
}
vmDied = true;
traceln("TS: vmDied called");
}
synchronized(TestScaffold.this) {
vmDisconnected = true;
TestScaffold.this.notifyAll();
}
}
});
throw new IllegalArgumentException("VM options in two places");
}
}
throw new IllegalArgumentException("Command line in two places");
}
}
}
new EventHandler();
}
return vm;
}
return requestManager;
}
}
}
protected void listenUntilVMDisconnect() {
try {
addListener (this);
testFailed = true;
} finally {
// Allow application to complete and shut down
}
}
try {
wait();
} catch (InterruptedException e) {
}
}
if (vmStartThread == null) {
throw new VMDisconnectedException();
}
return vmStartThread;
}
public synchronized void waitForVMDisconnect() {
traceln("TS: waitForVMDisconnect");
while (!vmDisconnected) {
try {
wait();
} catch (InterruptedException e) {
}
}
traceln("TS: waitForVMDisconnect: done");
}
class EventNotification {
boolean disconnected = false;
}
traceln("TS:Listener2: got requested event");
synchronized (en) {
}
} else if (event instanceof VMDisconnectEvent) {
traceln("TS:Listener2: got VMDisconnectEvent");
synchronized (en) {
en.disconnected = true;
}
}
}
};
try {
synchronized (en) {
traceln("TS: waitForRequestedEvent: vm.resume called");
}
}
} catch (InterruptedException e) {
return null;
}
if (en.disconnected) {
throw new RuntimeException("VM Disconnected before requested event occurred");
}
}
final StepRequest sr =
return retEvent;
}
}
}
}
}
}
final BreakpointRequest request =
}
return rt;
}
}
return null;
}
return method;
}
}
return null;
}
throws AbsentInformationException {
throw new IllegalArgumentException("Bad line number");
throw new IllegalArgumentException("Line number has multiple locations");
}
}
}
throw new IllegalArgumentException("Bad method name/signature");
}
}
}
}
final ClassPrepareRequest request =
}
public void resumeToVMDisconnect() {
try {
traceln("TS: resumeToVMDisconnect: vm.resume called");
} catch (VMDisconnectedException e) {
// clean up below
}
}
public void shutdown() {
}
", vmDisconnected= " + vmDisconnected +
", connection = " + connection);
if ((connection != null)) {
try {
} catch (VMDisconnectedException e) {
// Shutting down after the VM has gone away. This is
// not an error, and we just ignore it.
}
} else {
traceln("TS: shutdown: disposeVM not called");
}
}
vmDied = true;
vmDisconnected = true;
}
}