Can I step out of a function after stepping into it with step
while using pdb / ipdb debugger?
And if there's no such option - what is the fastest way to get out of the stepped-in function?
Once you get you pdb prompt . Just hit n (next) 10 times to exit the loop.
The docs say: j(ump) lineno Set the next line that will be executed. Only available in the bottom-most frame. This lets you jump back and execute code again, or jump forward to skip code that you don't want to run.
Optionally, you can also tell pdb to break only when a certain condition is true. Use the command b (break) to set a breakpoint. You can specify a line number or a function name where execution is stopped. If filename: is not specified before the line number lineno , then the current source file is used.
After some scientifically-crafted experimentation, turns out ctrl+Z haults the pdb shell.
As mentioned by Arthur in a comment, you can use r(eturn)
to run execution to the end of the current function and then stop, which almost steps out of the current function. Then enter n(ext)
once to complete the step out, returning to the caller.
Documentation is here.
(Pdb) ?r r(eturn) Continue execution until the current function returns.
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