Skip to content
Advertisement

How to debug backwards in PyCharm?

We all know F9 goes forward in debug mode. But how can we go backward after going a couple steps forward with F9 or is that even possible?

Advertisement

Answer

how can we go backward after going a couple steps forward with F9 or is that possible?

It isn’t possible, you can’t “go back” during debugging. (That is the case in Python and other programming languages/debuggers in general.)

The reason is the debugger would have to restore the state of your program to the previous step. Which using your logic would involve holding a copy of the entire state (memory, stack, temporary files, etc…) at every step of the program. (Not to mention operations protocols that aren’t reversible and require precise timing.) That would be exponential and become easily unfeasible. That’s why it’s not done.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement