Some adventures in road and trail running.
For Running stuff click here. For Eclipse stuff click here.

Thursday, April 3, 2008

Dumb Debugger Trick in Eclipse

I am often attempting to isolate the class or classes that pertain to a bug report. This week while we are pushing towards Jazz M6, I have been knee deep in UI code: wizards, dialogs, and editors, oh my!

Since my code is always golden (ya right!) and/or my memory is getting weak for remembering the names of all the classes involved, I often do not know how to find the source that is causing / exhibiting the problem.
Or I know of some UI within Eclipse or Jazz that has similar or desired behavior that I would like to emulate. Good old monkey see, monkey do.

A dumb or simple Eclipse debugger trick in case it ever might help you out:
  1. Launch a target Eclipse.
  2. Invoke the UI action to realize the wizard, dialog or editor.
  3. Pause the main thread of the target launch. If the code is not run on the main or UI thread, pause the VM while things are chugging away and find the interesting thread.
  4. Find the relevant stack frame and locate the interesting variables.
  5. Jump to the correct code to find the bug or the example you wish to emulate.
This trick requires no addition plug-ins or latest code so please try this at home :-)
Hope this helps someone work faster and smarter.

6 comments:

Eugene Kuleshov said...

Excuse me if I am stating something obvious, but if you are running Eclipse 3.4, you can just hit Alt-Shift-F1 and navigate directly to the dialog or wizard class without running Eclipse in debugger, thanks to Plug-in Spy plugin from Chris Aniszczyk.

It used to be possible to use same plugin for earlier versions, but it seem like update site is gone now.

Darin Swanson said...

We are not currently developing on Eclipse 3.4 and I have not tried the plug-in spy to see if it works on 3.3. Now I will have to :-)

Wayne said...

If you were using Mylyn to create the wizard/dialog/whatever, you could instantly recall all the types and method involved simply by reactivating the task...

Darin Swanson said...

Good point Wayne. With Mylyn or Jazz you can easily recreate the scope of your own work. It is the starting point for the changes/enhancements made by others that I often use this trick for.

Jacek Pospychala said...

that's my favourite method for hunting threads with 100% CPU usage :)

Eugene Kuleshov said...

Jacek, my favorite method for that is Ctrl-Break on java console. Simpler tools are always better. :)

You can also use jstack when running on Java 5 and higher...

It would be nice if Eclipse Debugger provided something like that for all locally running processes.