0

There is a statement like this

double pow(double num, int exp){
    if(exp < 0)
        return (1/power2(num, -exp));
    else
        return power2(num,exp);
}

I want to view the value returned by power2(num,exp) function in the debugger window, without having to store the returned value in an intermediate variable. How is this done?

Twin
  • 45
  • 7

1 Answers1

2

In the Eclipse debug perspective, open the Display view and write the expression that calls the method. You can then evaluate it by selecting it and pressing the key combination (on Windows) Ctrl+Shift+I.

Of if you want to "watch" the value of the expression, you can use the Expressions view instead.

Note that this will actually run the code behind the method. So make sure you invoke expressions that don't affect the execution flow of your program while debugging. If you want to minimize side effects, it's better to just write a reduced expression. For example, instead of evaluating the whole method invocation, which could do side effects in its body, you can evaluate just the temporary expression you want to watch.

M A
  • 71,713
  • 13
  • 134
  • 174