views:

243

answers:

3

I have a java process running on a Linux box, but it cannot be started/re-started in debug mode. I read about the jsadebugd command and started the daemon, but I want to connect to it from an IDE(possibly Eclipse) debugger or maybe YourKit or jconsole. How can I do this? The remote JVM is 1.6+.

A: 

I am not sure if I understand your restrictions correctly but you can start JVM with debugging server (serving JDWP) enabled. See for example "Sun VM Invocation Options" in http://java.sun.com/j2se/1.4.2/docs/guide/jpda/conninv.html

Then you can connect your Eclipse debugger to running JVM. See "Remote debugging" section here http://www.ibm.com/developerworks/library/os-ecbug/

Petr Gladkikh
A: 

I'm not sure that this is exposed by Eclipse, but here's how to do it with jdb:

http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/tooldescr.html#gbmog

kschneid
+1  A: 

I assume since you mentioned Yourkit and other tool that what you really want to do is look at object state inside your applications. There are a couple of options, though I don't think it gets you the ability to set break-points like Eclipse or another debugger would (though I'd be intersted in hearing what restricts you from starting the process in debug mode - technical? process?)

  1. have you tried connecting with: VisualVM? I don't believe you need to start in debug mode, and it will give you the ability to navigate the object graph, and inspect objects. You can even use it to take heapdumps and do some ad-hoc analysis through them using OQL queries.

  2. If you're running on JDK6+ - have you tried instrumenting with btrace? Some notes from the sailfin team sounded promising, and like DTrace in Solaris, this seem like it would be useful in a variety of situations.

jayshao
The process was already running and I wanted to see if I could peek into the JVM somehow. It had not been started in debug mode, so I was exploring options for this. In general though, Eclipse debugger and Yourkit are powerful enough to resolve issues as long as you have the processes setup accordingly. I have not tried btrace before, but I'll check it out.
Thimmayya
@thimmayya Did those notes answer your question, or are you still looking?
jayshao
the notes were helpful. I havent tried btrace yet, but the documentation does say that a BTrace program can be run against a running Java process. Thanks.
Thimmayya