Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDB - stepping out of a function

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?

like image 313
Kludge Avatar asked Feb 01 '18 15:02

Kludge


People also ask

How do you get out of a loop in pdb?

Once you get you pdb prompt . Just hit n (next) 10 times to exit the loop.

How do you go one step back in pdb?

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.

How do you set a breakpoint in pdb?

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.

How do you continue after pdb?

After some scientifically-crafted experimentation, turns out ctrl+Z haults the pdb shell.


1 Answers

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. 
like image 163
davidA Avatar answered Sep 28 '22 04:09

davidA