I'm seeking an easy way to view the return values for Java methods when stepping through code using the Eclipse debugger.
In MS Visual Studio this is trivial (explicitly displayed by the debugger).
I would prefer a solution that requires little or no setup per debugging session.
The hardest scenario to solve is one where a method returns a computed value to another method which uses it within an expression. Thus there are no variables to debug on either end.
Any help would be appreciated. I've stumped all the Eclipse gurus at my company so now I turn to the Internet! Even Google didn't help. I don't have a lot of hope, but maybe an Eclipse developer (not me!) will see and be inspired.
Thanks.
I'm pretty new to Eclipse debugger, but this is what I do:
In the debug perspective, and given the Java statement
return book1.equals(book2);
I highlight the entire statement (excluding 'return' and ';'), then right-click and select Watch. The statement will now appear in the Expressions View and the value is now visible.
In eclipse, if you break on this line, you can highlight,
say, baz(y) and do Ctrl-Shift-D (equivalent to right-click-Display).
That will pop-up the result. If you press Ctrl-Shift-D, this
result will go into your Display view.
Although these suggestions will work a lot of the time, they cannot be used when you don't want the method to be called twice, (or more often than what is coded). For example, if bar() has side effects of being called more than once, then putting a Watch expression or using Display will call bar() more than once and is therefore not a viable option.
Oftentimes you don't know what the effect of calling the method more than once is, so you'll end up debugging debugger side effects and not what really happens. What is needed is a list of the parameters in the variables window after all the arguments have been evaluated, ie, just before the method is called. Unfortunately, I can't find a way to achieve this.
Good point about side effects. I don't know that any IDE
would support this prior to Mustang, as only in
Mustang the returnValue() method was added to
MethodExitEvent of JPDA; I've run int o this, see:
http://fish37.livejournal.com/1351.html.