Is it possible to step backwards through executed code in a debug session?
For example I step over a method called abc()
expecting to get 12
but after re-checking the value returned I notice it's 5
instead of 12
. How can I step back to where I was before and step into the method to see what is going on? I know you can do this in visual studio but I can't find how to do this in intelliJ.
To navigate backwards, press Ctrl+Alt+Left . To navigate forward, press Ctrl+Alt+Right . To navigate to the last edited location, press Ctrl+Shift+Backspace .
Smart step intoFrom the main menu, select Run | Debugging Actions | Smart Step Into or press Shift+F7 . Click the method. You can also select it using the arrow keys or tabs and press Enter / F7 .
You can use step-back via the new Step Backward and Step Forward icons in the Debug toolbar. These icons navigate the events in the Events Tab. So, if you've just taken a step in live debugging (F10 or F11), you can use the Step Backward button to quickly navigate to the previous step.
You can drop the frames until you reach the point where you want to be. This isn't exactly stepping backwards, but it is quite similar in a lot of respects.
Though as the comments mention below, this will not revert the global state of your application -- which isn't a huge concern if you're developing stateless services, but could be if you're developing swing applications (if anyone actually does that any more).
On the debugger toolbar it looks like this: . In Idea 2016.3
the drop-frame icon changed to look like this , and since 2019.3
it changed to look like this .
Full documentation is available here: IntelliJ Debugger Docs, and there is a StackOverflow Drop Frame Question, with a few useful answers
Check out Chronon Debugger plugin which actually allows you to step back, not just drop the frame http://blog.jetbrains.com/idea/2014/03/try-chronon-debugger-with-intellij-idea-13-1-eap/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With