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?
The Java Debugger, jdb, is a simple command-line debugger for Java classes. It is a demonstration of the Java Platform Debugger Architecture that provides inspection and debugging of a local or remote Java Virtual Machine.
The Java™ Debugger (JDB) is included in the SDK. The debugger is started with the jdb command; it attaches to the JVM using JPDA. The JVM starts up, but suspends execution before it starts the Java application.
Debugging is the routine process of locating and removing bugs, errors or abnormalities from programs. It's a must have skill for any Java developer because it helps to find subtle bug that are not visible during code reviews or that only happens when a specific condition occurs.
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.
I agree with much of what Vilas Jagannath says.
Using the Eclipse debugger Additional points:
1) The Display view. This view allows you to run code in the context of the current stack frame. This allows you to inspect arbitrary bits of code. In some ways it is a little primitive, but it works great as a scratch pad.
4) If you want to go into some method call in a line with a complex expression, you can navigate to that function and then "Run to Line" (Ctrl + R)
5) You can also use step filters to filter classes you don't care about. Right click on the stack frame you don't care about and hit "Filter Type". Make sure you have "Use Step Filters" on. It is the icon with two arrows just to the right of the drop to frame button on the Debug view.
I use NetBeans and its debugger.
About your third point (exceptions): I don't think there is any other way to see the state at the point where the exception is thrown. When the exception is thrown out of the method, the stack frame for that method has been discarded - it's lost so that you can't inspect it aferwards.
The NetBeans debugger also doesn't let you step through bytecode, as far as I know.
Here is my answer - the bullets are in the same order as your question bullets:
I believe they still have what to improve but these tips might help you a bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With