Search code examples
javaeclipsedebuggingjpda

Which Java debugger do *you* use


I spend a lot of time debugging applications in Eclipse using JPDA. There are a few issues with the Eclipse debugger which really annoy me. Can anybody recommend plug-ins, better debuggers or perhaps tricks that I don't know of yet?

  • In the "Variables" tab, you can type in and execute bits of Java code. However, you first need to click on something (I usually click on "this") to give it some context. Then, after you've typed in a lengthy Java expression to debug something and "execute" it, your expression gets replaced with the result, so you need to type it in all over again. Is there some better way, such as a console or something that I'm missing?
  • When you're poking through data structures, the presentation in the debugger leaves much to be desired. You see the internal representation of Lists, Maps, StringBuilders etc. What I want to see is what these objects conceptually contain. Is there a way of doing this, perhaps using some other debugger, or an extension or something?
  • When an Exception is thrown, is there some way of inspecting the state of the application where the Exception was thrown? Currently I need to set breakpoints just before the Exception occurs and then try to reproduce it.
  • When I'm stepping over a line with many statements on it, I can't actually see which of those statements is being executed, except by "stepping in" to each one to see where it takes me.
  • If no source code is found, Eclipse just stares blankly at you. You get a helpful screen saying "Class File Editor / Source code not found" which is completely useless. I'd much prefer to be able to step through the bytecodes so I can at least see what is going on. Does anybody know of a Java debugger that does this better than Eclipse?

Solution

  • I have been using the Eclipse debugger for a while now and share some of your concerns. However some of the points you mention have been solved/addressed in the Eclipse debugger:

    Data structures: The variables view already has the option to show the "logical structure" of lists/sets/arrays etc. There is a button at the top left corner of this view to enable this. You can also add your own custom representations through the Java->Debug->Logical Structures preferences.

    Exceptions: The debugger lets you set exception breakpoints (Add Java Exception breakpoint button in the breakpoints view). These breakpoints are triggered when a particular exception is thrown.

    Source code: If you install a plugin (Eg. asm byte code plugin http://asm.ow2.org/eclipse/index.html) that has a viewer for bytecode, the debugger will step through the bytecode when source code is missing.