Which Java debugger are you * using *

I spend a lot of time debugging applications in Eclipse using JPDA. There are several issues with the Eclipse debugger that really annoy me. Can anyone recommend plugins, better debuggers or tricks that I don't know about yet?

  • On the Variables tab, you can enter and execute a bit of Java code. However, you first need to click something (I usually click on "this") to give it some context. Then, after you type a long Java expression to debug something and "execute", your expression is replaced by the result, so you need to enter it again and again. Is there a better way, like a console or something that I am missing?
  • When you wade through data structures, the view in the debugger is poor. You see the internal representation of lists, maps, StringBuilders, etc. I want to see what these objects conceptually contain. Is there a way to do this, possibly using some other debugger, or an extension, or something else?
  • When an Exception is thrown, is there a way to check the state of the application in which the Exception was thrown? Currently, I need to set breakpoints just before an exception occurs, and then try to reproduce it.
  • When I step over a line with many instructions on it, I can’t see which of these statements is executed, except that I’ll enter each one to see where it takes me.
  • If no source code is found, Eclipse just stares blankly at you. You get a useful screen saying "File Editor / Source Code Not Found", which is completely useless. I would rather be able to go through the bat codes so that I can at least see what is happening. Does anyone know of a Java debugger that does this better than Eclipse?
+7
source share
8 answers

I have been using the Eclipse debugger for a long time and share some of your problems. However, some of the issues you mentioned were resolved / reviewed in the Eclipse debugger:

Data structures: the representation of variables already has the ability to display the "logical structure" of lists / sets / arrays, etc. To enable this, there is a button in the upper left corner of this window. You can also add your own custom views using the Java-> Debug-> Logical Structures settings.

Exceptions: the debugger allows you to set exception breakpoints (add a Java exception breakpoint as breakpoints). These breakpoints are triggered when a specific exception is thrown.

Source code: if you install the plugin (for example, the asm byte code of the plugin http://asm.ow2.org/eclipse/index.html ), which has a viewer for the bytecode, the debugger will go through the bytecode when not available source.

+11
source

I agree with what Vilas Jagannath says.

Using the Eclipse Debugger Additional points:

1) Type of display. This view allows you to run code in the context of the current stack frame. This allows you to check arbitrary bits of code. In a way, it's a bit primitive, but it works just fine like scratches.

4) If you want to go to the method call in a line with a complex expression, you can go to this function, and then "Run to Line" (Ctrl + R)

5) You can also use step filters to filter classes that you do not need. Right-click on the stack stack that you do not need, and click "Filter Type". Make sure you have "Use step filters." This is the two-arrow icon to the right of the drop-to-frame button in the Debug view.

+4
source

I am using 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 an exception is thrown from a method, the stack frame for this method has been discarded - it is lost, so you cannot check it.

The NetBeans debugger also prevents you from passing bytecode as far as I know.

+3
source

I would usually say that eclipse has a better debugger than my preferred IDE, IntelliJ (free version). For the first four IntelliJs, it may be better with breakpoints on exceptions (which allow you to see the state at the point when the exception is), personalized renderers for object types and constant expressions (i.e. the expression is revised every time the context changes)

I do not know any debugger that will execute byte code.

+1
source

Here is my answer - the bullets are in the same order as your question bullets:

  • There is a better way to do this:
    • Use the Display view to execute statements.
    • Write something on the class itself and "Inspect" it (ctrl + shift + I)
  • See the small icon in the variable view for “Show logical structure”. Perhaps this is what you are looking for.
  • You can set a common breakpoint in Exception to catch the exception as it happens - in the J exception window! icon.
  • I use Ctrl + Alt + left click on the method that I want to enter into, it works like a charm!
  • You can still use jog with keys or buttons (see stack). If you want to see the code, use a decompiler.

I believe that they still have something to improve, but these tips can help you.

+1
source

When I step over the line with many statements about this, I cannot really see which of these statements is executed, with the exception of “stepping in each”, to see where this is required.

Select the function you want to enter and use "Step Into Selection" (I have it on Ctrl-F5, but you can find it in the context menu).

+1
source

Alternatively, you can put your code using log.debug and System.out.println, which means you can do whatever you want!

0
source

For something other than a gui debugger, I have a project called jdiscript that allows the JVM Java Debugger Interface script.I found this especially useful for troubleshooting conflicts and finding problems that seem to occur sporadically during production loads.

0
source

All Articles