return value in Eclipse debugger

L

Larry

When using the Eclipse debugger, is there any way to see the value
that was just returned (or is about to be returned) from a method?
 
M

Manish Pandit

When using the Eclipse debugger, is there any way to see the value
that was just returned (or is about to be returned) from a method?

If you set your breakpoint correctly, you should see all the variables
in scope showing up in the Variables subwindow at that breakpoint.
Stepping through the code can give you an idea of how the state
changes and one of those variables could very well be the one that the
method is returning. I hope this answers your question. Make sure you
are in the debug perspective in eclipse (Window->Open Perspective-
Debug) or you'd not be able to see the Variables window.

-cheers,
Manish
 
T

Tzadik.Vanderhoof

If you set your breakpoint correctly, you should see all the variables
in scope showing up in the Variables subwindow at that breakpoint.
Stepping through the code can give you an idea of how the state
changes and one of those variables could very well be the one that the
method is returning. I hope this answers your question. Make sure you
are in the debug perspective in eclipse (Window->Open Perspective-


-cheers,
Manish

No, I knew all that. But suppose there is a complex expression in the
"return" statement?
 
M

Manish Pandit

No, I knew all that. But suppose there is a complex expression in the
"return" statement?- Hide quoted text -

- Show quoted text -

Maybe I did not get your question right, but you can always assign the
return value to a variable that can be watched via debug.

Assuming you mean a complex expression like :

return Math.sin(toRadians(x))*x+y^x%2;

can be replaced with :
double d = Math.sin(toRadians(x))*x+y^x%2;
return d;

-cheers,
Manish
 
B

Ben Phillips

Manish said:
double d = Math.sin(toRadians(x))*x+y^x%2;
return d;

Wouldn't that be

double d = Math.sin(toRadians(x))*x+y**x%2;
return d;

?

;)

(One does not ordinarily use xor when working with doubles.)
 
L

Lew

Ben said:
Wouldn't that be

double d = Math.sin(toRadians(x))*x+y**x%2;
return d;

?

;)

(One does not ordinarily use xor when working with doubles.)

No, because "**" is not Java.
 
B

Ben Phillips

Lew said:
No, because "**" is not Java.

It was a joking reference to the recent Java 7 discussion where several
people suggested adding it for exponentiation. For now of course you'd
have to use Math.pow()...
 
L

Larry

Maybe I did not get your question right, but you can always assign the
return value to a variable that can be watched via debug.

Assuming you mean a complex expression like :

return Math.sin(toRadians(x))*x+y^x%2;

can be replaced with :
double d = Math.sin(toRadians(x))*x+y^x%2;
return d;

-cheers,
Manish

I know... but I was hoping the debugger would have a way to look at
the return value without having to go in and change the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top