Matt Ball
Matt Ball

Reputation: 359966

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).

Upvotes: 11

Views: 10245

Answers (4)

Ahmed Adel Ismail
Ahmed Adel Ismail

Reputation: 2184

in your Expressions view, add the following expression

baz.getBar()

and it will be dispayed while debugging (if it is visible to the debugger ofcourse)

Upvotes: 0

Andreas Dolk
Andreas Dolk

Reputation: 114797

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.

Upvotes: 11

Serge Bogatyrev
Serge Bogatyrev

Reputation: 816

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

Upvotes: 5

João Silva
João Silva

Reputation: 91349

In the Debug perspective, open the display window (Window => Show View => Display), write the code that you want to display (e.g., baz.getBar()), select it, and then right click and choose "Display" or use the shortcut to display its value.

Upvotes: 14

Related Questions