How can I get the python debugger, pdb to break on exit? Also, why I am at it, How can I break on exceptions raised?
To start execution, you use the continue or c command. If the program executes successfully, you will be taken back to the (Pdb) prompt where you can restart the execution again. At this point, you can use quit / q or Ctrl+D to exit the debugger.
Once you get you pdb prompt . Just hit n (next) 10 times to exit the loop.
Disable the breakpoint. from pdb, just type disable N, where N is the breakpoint number you are stuck on. If you don't know the number of your troubling breakpoint, enter tbreak.
Just use python -m pdb <your_script>. py then b <line_number> to set the breakpoint at chosen line number (no function parentheses). Hit c to continue to your breakpoint. You can see all your breakpoints using b command by itself.
Overwrite the function :
old_sys_exit = sys.exit
def new_sys_exit (value) :
print "in sys exit %s" % value
old_sys_exit(value)
sys.exit = new_sys_exit
and then set the breakpoint :
(Pdb) b new_sys_exit
It works, also for other modules that call sys.
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