participate


Debugging Tools and Techniques - Debugging Method Return Values in Eclipse
<<   Back to Forum  |   Give us Feedback
This topic has 5 replies on 1 page.
b_gale
Posts:1
Registered: 3/8/06
Debugging Method Return Values in Eclipse   
Mar 8, 2006 8:19 AM

 
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.
 
ajua
Posts:7
Registered: 4/7/06
Re: Debugging Method Return Values in Eclipse   
Apr 7, 2006 1:21 AM (reply 1 of 5)  (In reply to original post )

 
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.

Hope it helps... =)
 
junta
Posts:9
Registered: 3/12/01
Re: Debugging Method Return Values in Eclipse   
Jul 13, 2006 8:01 AM (reply 2 of 5)  (In reply to original post )

 
Let's say you have

foo(bar(x), baz(y);

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.
 
WilliamFulton
Posts:26
Registered: 6/23/03
Re: Debugging Method Return Values in Eclipse   
Jul 24, 2006 4:35 AM (reply 3 of 5)  (In reply to #2 )

 
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.
 
junta
Posts:9
Registered: 3/12/01
Re: Debugging Method Return Values in Eclipse   
Jul 24, 2006 6:44 AM (reply 4 of 5)  (In reply to #3 )

 
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.
 
weberjn
Posts:12
Registered: 6/23/03
Re: Debugging Method Return Values in Eclipse   
Dec 5, 2006 1:40 AM (reply 5 of 5)  (In reply to original post )

 
[java debug] Make method return value visible / inspectable

https://bugs.eclipse.org/bugs/show_bug.cgi?id=75519
 
This topic has 5 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 27
  • Guests : 128

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums