Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
35 views

PDB Commands: Startup and Help

The document describes commands for navigating, controlling execution, and interacting with code in the Python debugger Pdb. Key commands include listing lines of code with 'l', stepping into functions with 's', setting breakpoints with 'b', continuing execution with 'c', printing variables with 'p', and quitting the debugger with 'q'. Pdb can be started on a Python file with the '-m pdb' option or by adding 'import pdb; pdb.set_trace()' in code.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

PDB Commands: Startup and Help

The document describes commands for navigating, controlling execution, and interacting with code in the Python debugger Pdb. Key commands include listing lines of code with 'l', stepping into functions with 's', setting breakpoints with 'b', continuing execution with 'c', printing variables with 'p', and quitting the debugger with 'q'. Pdb can be started on a Python file with the '-m pdb' option or by adding 'import pdb; pdb.set_trace()' in code.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

PdbCommands

Physics91SI,Spring2013
RexGarlandandGabeEhrlich

StartupandHelp

python -m pdb <name>.py[args] beginthedebugger


help [command] viewalistofcommands,orviewhelpforaspecific
command
withinapythonfile:
import pdb
...
pdb.set_trace() beginthedebuggeratthislinewhenthefileisrun
normally

NavigatingCode(withinthePdbinterpreter)

l(ist) list11linessurroundingthecurrentline
w(here) displaythefileandlinenumberofthecurrentline
n(ext) executethecurrentline
s(tep) stepintofunctionscalledatthecurrentline
r(eturn) executeuntilthecurrentfunctionsreturnis
encountered
ControllingExecution

b [#] createabreakpointatline[#]
b listbreakpointsandtheirindices
c(ontinue) executeuntilabreakpointisencountered
clear[#] clearbreakpointofindex[#]

ChangingVariables/InteractingwithCode

p <name> printvalueofthevariable<name>
!<expr> executetheexpression<expr>
NOTE:thisactsjustlikeapythoninterpreter
run [args] restartthedebuggerwithsys.argvarguments[args]

q(uit) exitthedebugger

You might also like