JVMDI Launching and Thread Suspension

Hi,

I am using JVMDI to debug a java application. I launch the application and debugger with the following command line.

java -Xdebug -Xnoagent -XrunTest:ADA <applicationName>

When I try and suspend the application after a method entry event, everything (including my JVMDI debugger) is suspended. This is not what I had thought would happen. I only want the application thread to suspend so that I can access the stack frames. Is there a problem with the way I am loading the application and debugger ?or am I suspending that application incorrectly (see below).

err = jvmdi->GetMethodLocation((*event).u.frame.clazz,

(*event).u.frame.method,

&startLocationPtr, &endLocationPtr);

err = jvmdi->GetMethodName((*event).u.frame.clazz,

(*event).u.frame.method,

&namePtr, &signaturePtr);

err = jvmdi->GetSourceFileName((*event).u.frame.clazz,&SourceNamePtr);

/* is this the application class or a system class */

if ((strncmp(prefix,SourceNamePtr,prefixLength) == 0))

{

err = jvmdi->SuspendThread((*event).u.frame.thread);

}

Any help would be greatly appreciated.

Chief

[1213 byte] By [Chief_Yeffgenniea] at [2008-2-2]
# 1

Are you running your JVMDI code on the same thread as the

application? If so, then SuspendThread will indeed suspend

everything, and your code will not be able to resume itself.

Is (*event).u.frame.thread

the same as `this` thread in your code?

Then you are suspending yourself. You will need to take pains

to run your code on a Debug thread. See "RunDebugThread" at this URL:

http://java.sun.com/j2se/1.4.1/docs/guide/jpda/jvmdi-spec.html#RunDebugThread

It would be less intrusive on the debugee if you wrote

an out-of-process debugger that attached to the debugee

using the Java Debug Interface (JDI). For more information,

refer to the Architecture Overview document:

http://java.sun.com/j2se/1.4.1/docs/guide/jpda/architecture.html

JDI has an added advantage: it is a Java Language API, which

means you can write your debugger in the Java Language. There

is a reference debugger (jdb) with source available for you to

study. Unpack $JAVA_HOME/demo/jpda/examples.jar, and

then look at

Trace.java

and TTY.java

(and their related support classes).

debugging_teama at 2007-7-14 > top of java,Archived Forums,Debugging Tools and Techniques...