Debugging Java apps with dbx

Hi, I have read about the new feature in SunOne Studio 7 that allows to debug an application that's written in Java as well as the underlying native code. I wanted to debug my Java app and the JVM that it's running on. So I downloaded the source code for Sun JVM and compiled it with debug symbols.

Now, however, I am having problems using dbx for debugging a Java app. I tried 2 options: (1) starting the Java app. within the dbx and (2) starting it separately and attaching to the running JVM with dbx. I did not have any luck in either scenario.

In scenario 1 I got the following errors reported to me by dbx:

(dbx) debug HelloWorld.class Debug target is "HelloWorld.class" Will be debugging "HelloWorld" AgentThread: JVM_OnLoad(): debugger not attaching dbx: Unable to start the Java virtual machine

(My LD_LIBRARY_PATH was set correctly so that the JVM could find libdbx_agent.so, and my jvm_invocation environmental variable was set to my jvm with -Xdebug flag).

In scenario (2), when I tried attaching with dbx to an already running JVM, I got the following output from dbx:

Reading java Reading ld.so.1 Reading libthread.so.1 Reading libdl.so.1 Reading libc.so.1 Reading libc_psr.so.1 Reading libjvm.so Reading libCrun.so.1 Reading libsocket.so.1 Reading libnsl.so.1 Reading libm.so.1 Reading libw.so.1 Reading libmp.so.2 Reading libhpi.so Reading libverify.so Reading libjava.so Reading libzip.so Reading libdbx_agent.so detected a multithreaded program Attached to process 6467 with 12 LWPs t@1 (l@1) stopped in _poll at 0xff29990c 0xff29990c: _poll+0x0004: ta 0x8 dbx: panic: "JThreadProxy::refresh"(): Assertion (t_thr != Thread::null) failed - "jvm.cc":1987

Does anyone have any ideas what I could be doing wrong? I understand that cross-language debugging with DBX is a very new feature. So if anyone could share their experience using it, I would greatly appreciate it.

Thanks!

[1972 byte] By [fedorova@eecs.harvard.edu] at [2007-11-25 9:50:41]
# 1

Dbx is not designed for debugging the jvm as such. While it is

possible to set breakpoints in jvm code (use "native stop ..." or

turn java mode off temporarily with "joff"), doing so could lead

to deadlocks. The way java debugging works in dbx is that

dbx makes function calls into the jvm to fetch java information

and to control the java threads. So a jvm breakpoint might be

hit when you do a (java) "threads" command in dbx, for example.

If you still wish to try it, you should be able to tell dbx to start

your java app using your debuggable jvm by setting the env

variable "jvm_invocation" to "/full/path/to/java -Xdebug" before

starting dbx. Then use "native step" or "joff" and "step" to step into

the jvm code.

Hope this helps!

Dave W.

David Weatherford at 2007-7-1 19:01:55 > top of Java-index,Development Tools,Java Tools...