FaqDebugBackup

While debugging, how can I back up and repeat a step without starting over?

While debugging, it is sometimes needed to step back into the current method. Here's a typical scenario:

  void foo() {
    int x = bar();
    int y = baz();
  }

The process of debugging usually involves stepping through the code, mentally comparing what you think should happen with what is actually happening. When you get into method foo(), you need to decide if you want to step into the bar() method. If you don't actually step into bar() and it returns the expected result for x, you have saved some time.

But if the expected result is wrong, you'll want to go back and see what's happening in bar(). Instead of doing all the setup work to get into this method again, perhaps restarting the debugging session, you can go back in the call stack (pop the top stackframe) and step into the foo() method again. Then you're back in the foo() method and can proceed to step into bar().

To pop one stackframe in order to be able to re-enter a method again, you can either:

  • from main menu invoke Debug | Stack | Pop Topmost Call,
  • or go to the main debugging view which shows the current stack, right click the frame just below the top one and select Pop To Here.

Then press F7 to do Step Into again into your method.

This works as long as there haven't been any side effects in the method which affects execution; luckily that's usually the case.

See also FaqDebuggingStackOperations.


  Applies to: NetBeans 6.x
  Platforms: All
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo