Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the Eclipse Debugger (for Java), is there a way to inspect arbitrary values?

I'm wondering if there is a way to look at the values of non-declared variables as they get passed into a function, after that function has been executed. For example, if I am debugging and the line

foo.setBar(baz.getBar());

has already been passed (but is still within scope), how can I see the value of what got passed in to setBar()? I know that I can see this many other ways, for instance by stepping into the setBar() call, or by assigning baz.getBar() to a temporary variable - but that's not what I'm asking.

Edit: Basically, I feel penalized (by losing the ability to see certain information) while debugging, just because I'm not declaring every variable.

And, I know I could inspect bar after the fact (if I know it hadn't changed) but in this case it's not so simple because I'm dealing with objects that aren't just POJOs or JavaBeans (the object that brought this question up is an HTTP request - and yes, I already did try inspecting it).

like image 704
Matt Ball Avatar asked Aug 21 '09 17:08

Matt Ball


People also ask

How can check variable value while debugging in Eclipse?

Press Ctrl+Shift+d or Ctrl+Shift+i on a selected variable or expression to show its value. You can also add a permanent watch on an expression/variable that will then be shown in the Expressions view when debugging is on.

How do I show static variables in Eclipse debugger?

Variables. We can see the values of variables during the execution under the Variables view. In order to see the static variables, we can select the drop-down option Java -> Show Static Variables. Using the variables view, it's possible to change any value to the desired value during the execution.

What can the Eclipse debugger do?

Eclipse allows running an application in Debug mode which helps with stepping through each line of code in a program. Eclipse also provides a Debug Perspective which is a set of views grouped together that help inspect code and make the debugging process very effective.


2 Answers

A by far easier way is to select an expression (here: baz.getBar()) and press CTRL+SHIFT+I (for inspect). This opens a tooltip like window with all you want to know.

like image 94
Andreas Dolk Avatar answered Oct 27 '22 07:10

Andreas Dolk


And of course you can use "Expressions" view (Window -> Show View -> Expressions).

like image 33
Serge Bogatyrev Avatar answered Oct 27 '22 05:10

Serge Bogatyrev