return value in Eclipse debugger

Discussion in 'Java' started by Larry, Aug 13, 2007.

  1. Larry

    Larry Guest

    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?
    Larry, Aug 13, 2007
    #1
    1. Advertising

  2. On Aug 13, 1:24 pm, Larry <> wrote:
    > 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
    Manish Pandit, Aug 13, 2007
    #2
    1. Advertising

  3. Larry

    Guest

    On Aug 13, 5:42 pm, Manish Pandit <> wrote:
    > On Aug 13, 1:24 pm,Larry<> wrote:
    >
    > > 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


    No, I knew all that. But suppose there is a complex expression in the
    "return" statement?
    , Aug 14, 2007
    #3
  4. On Aug 13, 4:46 pm, wrote:
    > On Aug 13, 5:42 pm, Manish Pandit <> wrote:
    >
    >
    >
    >
    >
    > > On Aug 13, 1:24 pm,Larry<> wrote:

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

    >
    > 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
    Manish Pandit, Aug 14, 2007
    #4
  5. Larry

    Ben Phillips Guest

    Manish Pandit wrote:
    > 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.)
    Ben Phillips, Aug 14, 2007
    #5
  6. Larry

    Lew Guest

    Ben Phillips wrote:
    > Manish Pandit wrote:
    >> 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.)


    No, because "**" is not Java.

    --
    Lew
    Lew, Aug 14, 2007
    #6
  7. Larry

    Ben Phillips Guest

    Lew wrote:
    > Ben Phillips wrote:
    >
    >> Manish Pandit wrote:
    >>
    >>> 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.)

    >
    > 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()...
    Ben Phillips, Aug 15, 2007
    #7
  8. Larry

    Larry Guest

    On Aug 14, 3:14 pm, Manish Pandit <> wrote:
    > On Aug 13, 4:46 pm, wrote:
    >
    >
    >
    > > On Aug 13, 5:42 pm, Manish Pandit <> wrote:

    >
    > > > On Aug 13, 1:24 pm,Larry<> wrote:

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

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


    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.
    Larry, Aug 15, 2007
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greenhorn
    Replies:
    15
    Views:
    796
    Keith Thompson
    Mar 6, 2005
  2. monkeyboy
    Replies:
    2
    Views:
    514
    Mark Space
    Nov 30, 2007
  3. yary
    Replies:
    3
    Views:
    84
    Peter Scott
    Feb 22, 2007
  4. Robert Oschler
    Replies:
    1
    Views:
    213
    Mcginkel
    Sep 5, 2005
  5. aflat362
    Replies:
    7
    Views:
    211
    naixn
    Dec 7, 2006
Loading...

Share This Page