Introduction to thePython debugger (pdb)                @raulcumplido
Usages of pdbInvoked as a scriptPost Mortem ModeRun ModeTrace Mode
Invoked as a script                           Only                           Python~$ python -m pdb test.py               ...
Post Mortem Mode    pdb.pm()
Post Mortem Mode>>> import pdb>>> import mymodule>>> mymodule.test()Traceback (most recent call   last): File "<stdin>", l...
Run Modepdb.run(statement[, globals[, locals])pdb.runeval(expression[globals[, locals])pdb.runcall(function[, argument, .....
Run Mode>>> import pdb>>> import mymodule>>> pdb.run(mymodule.test())> <string>(0)?()(Pdb) continueNameError: spam> <strin...
Trace Modepdb.set_trace()
Debugger tips• Entering a blank line  repeats(except list)• Commands not recognized are  executed  – When exception nothin...
Debugger commandsh(elp) [command]
Debugger commandsw(here)
Debugger commandsd(own)u(p)
Debugger commandss(tep)
Debugger commandsn(ext)
Debugger commandsunt(il)
Debugger commandsc(ont(inue))
Debugger commandsj(ump) lineno
Debugger commandsl(ist) [first[, last]]
Debugger commandsa(rgs)
Debugger commandsp expressionpp expression
Debugger commands[!]statement
Debugger commandsq(uit)
Debug over the network or to an existing processhttp://dev.man-online.org/man1/rpdb2/http://code.activestate.com/recipes/5...
We’re hiring!                     Raúl Cumplido | @raulcumplido                raul@catchoom.com | +34 627566095          ...
Upcoming SlideShare
Loading in …5
×

Introduction to the Python Debugger (pdb)

2,083 views

Published on

Python pdb-meetup-bcn

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,083
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
37
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Introduction to the Python Debugger (pdb)

  1. 1. Introduction to thePython debugger (pdb) @raulcumplido
  2. 2. Usages of pdbInvoked as a scriptPost Mortem ModeRun ModeTrace Mode
  3. 3. Invoked as a script Only Python~$ python -m pdb test.py 3.2+~$ python -m pdb –c continue test.py~$ python -i test.py
  4. 4. Post Mortem Mode pdb.pm()
  5. 5. Post Mortem Mode>>> import pdb>>> import mymodule>>> mymodule.test()Traceback (most recent call last): File "<stdin>", line 1, in ? File "./mymodule.py", line 4, in test test2() File "./mymodule.py", line 3, intest2 print spamNameError: spam>>> pdb.pm()> ./mymodule.py(3)test2()> -> print spam(Pdb)
  6. 6. Run Modepdb.run(statement[, globals[, locals])pdb.runeval(expression[globals[, locals])pdb.runcall(function[, argument, ...])
  7. 7. Run Mode>>> import pdb>>> import mymodule>>> pdb.run(mymodule.test())> <string>(0)?()(Pdb) continueNameError: spam> <string>(1)?()(Pdb)
  8. 8. Trace Modepdb.set_trace()
  9. 9. Debugger tips• Entering a blank line repeats(except list)• Commands not recognized are executed – When exception nothing changes• Support for aliases
  10. 10. Debugger commandsh(elp) [command]
  11. 11. Debugger commandsw(here)
  12. 12. Debugger commandsd(own)u(p)
  13. 13. Debugger commandss(tep)
  14. 14. Debugger commandsn(ext)
  15. 15. Debugger commandsunt(il)
  16. 16. Debugger commandsc(ont(inue))
  17. 17. Debugger commandsj(ump) lineno
  18. 18. Debugger commandsl(ist) [first[, last]]
  19. 19. Debugger commandsa(rgs)
  20. 20. Debugger commandsp expressionpp expression
  21. 21. Debugger commands[!]statement
  22. 22. Debugger commandsq(uit)
  23. 23. Debug over the network or to an existing processhttp://dev.man-online.org/man1/rpdb2/http://code.activestate.com/recipes/576515/http://stackoverflow.com/questions/4163964/python-is-it-possible-to-attach-a-console-into-a-running-processAttach to python using gdb $> gdb(gdb) attach (pid)Investigar si se puede hacer algo más conesto Working on github on RPDB
  24. 24. We’re hiring! Raúl Cumplido | @raulcumplido raul@catchoom.com | +34 627566095 catchoom.com | @catchoom

×