tags:

views:

249

answers:

5

I would love to learn how to debug eclipse IDE. Back to the time when I was using VS for .NET development, I can attach VS to a process at anytime and start to trace down the problem. I hope there would be something similar with eclipse, but as a newbie to the Java world, I don't know about that.

My eclipse recently often hang when I run it together with iBUS (on Ubuntu 9.10). I hope that I can find out what really hang my eclipse and avoid that (Imagine your eclipse hang and every of your opened files were closed. It just drives me crazy).

A: 

Just put your breakpoints, click on "Debug as" and select Java application

nandu
I think he wants to debug Eclipse itself.
Thilo
He can debug Eclipse that way anyway :P
nandu
I think `Debug as` is to run your java application and attach debugger to the newly created process. How can I use it to debug Eclipse?
Phương Nguyễn
+1  A: 

One thing you can do with any Java application to see what is going on right now is send it a kill -QUIT. This will cause the JVM to dump the stack traces for all of its threads to stdout. Do this three times with a second in between and you can see which threads are not moving along nicely.

Another thing to try is to attach a JConsole to the running process.

Thilo
Hi, can you plz show me how to send a `kill - QUIT`?
Phương Nguyễn
You said you are on Ubuntu, so: 1) find the process id, maybe using ps auxw. 2) from the shell `kill -QUIT <process_id>`
Thilo
+1  A: 

Back to the time when I was using VS for .NET development, I can attach VS to a process at anytime and start to trace down the problem.

Remote debugging is also possible in Java with the Java Platform Debugger Architecture (JPDA), you just need to start the application you want to debug with remote debugging enabled. Here is an article showing how to do this and how to configure Eclipse to debug a remove application.

Note that starting from Java 5, you should prefer the -agentlib:jdwp option over the -Xdebug and -Xrunjdwp options as explained in Sun VM Invocation Options.

Update: Eclipse is a Java application so it should be possible to add the options mentioned in the article in eclipse.ini. Never tried that though (I missed the fact that you want to debug Eclipse itself).

Pascal Thivent
The article tell me about debuging a jar file. But I found eclipse to be (look like?) a native executable file. How can I tell eclipse to publish debugging message into a port?
Phương Nguyễn
A: 

There are basically two ways of debugging a Java application (e.g. Eclipse). You can use JConsole, but it won't give you a lot of details. For attaching JConsole you have to enable remote debugging; this needs a JVM argument that you can write into the eclipse.ini file right next to the Eclipse executable.

Another option is to start a runtime workbench from Eclipse: this is used to test your own plug-ins, but as Eclipse plug-ins are the same, it is possible to start a debug session with an Eclipse application. To do this, you need at least one plug-in in your workspace (e.g. create a new hello world plugin project), and you can then debug this as an Eclipse application.

Zoltán Ujhelyi
+2  A: 

Edit your eclipse.ini file an add the following to the bottom (beneath -vmargs):

-Xdebug
-Xnoagent
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,port=8000

Then in another Eclipse of the same version, you can import the plugins you are interested in debugging. File -> Import ... -> Plug-in Development -> Plug-ins and Fragments. Import From the active platform, and Import As "Projects With Source Folders", on the next tab select the plugins you are interested in.

Set breakpoints as appropriate.

Then create in Debug Configurations, create a new "Remote Java Application". localhost, port 8000. Add the Java projects on the source tab, and debug.

Andrew Niefer