home *** CD-ROM | disk | FTP | other *** search
- <TITLE>Debugger Commands -- Python library reference</TITLE>
- Next: <A HREF="../h/how_it_works" TYPE="Next">How It Works</A>
- Prev: <A HREF="../t/the_python_debugger" TYPE="Prev">The Python Debugger</A>
- Up: <A HREF="../t/the_python_debugger" TYPE="Up">The Python Debugger</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H1>8.1. Debugger Commands</H1>
- The debugger recognizes the following commands. Most commands can be
- abbreviated to one or two letters; e.g. ``<CODE>h(elp)</CODE>'' means that
- either ``<CODE>h</CODE>'' or ``<CODE>help</CODE>'' can be used to enter the help
- command (but not ``<CODE>he</CODE>'' or ``<CODE>hel</CODE>'', nor ``<CODE>H</CODE>'' or
- ``<CODE>Help</CODE> or ``<CODE>HELP</CODE>''). Arguments to commands must be
- separated by whitespace (spaces or tabs). Optional arguments are
- enclosed in square brackets (``<CODE>[]</CODE>'') in the command syntax; the
- square brackets must not be typed. Alternatives in the command syntax
- are separated by a vertical bar (``<CODE>|</CODE>'').
- <P>
- Entering a blank line repeats the last command entered. Exception: if
- the last command was a ``<CODE>list</CODE>'' command, the next 11 lines are
- listed.
- <P>
- Commands that the debugger doesn't recognize are assumed to be Python
- statements and are executed in the context of the program being
- debugged. Python statements can also be prefixed with an exclamation
- point (``<CODE>!</CODE>''). This is a powerful way to inspect the program
- being debugged; it is even possible to change a variable or call a
- function. When an
- exception occurs in such a statement, the exception name is printed
- but the debugger's state is not changed.
- <P>
- <DL>
- <DT><B>h(elp) [<VAR>command</VAR></B><DD>]
- <P>
- Without argument, print the list of available commands.
- With a <VAR>command</VAR> as argument, print help about that command.
- ``<CODE>help pdb</CODE>'' displays the full documentation file; if the
- environment variable <CODE>PAGER</CODE> is defined, the file is piped
- through that command instead. Since the <VAR>command</VAR> argument must be
- an identifier, ``<CODE>help exec</CODE>'' must be entered to get help on the
- ``<CODE>!</CODE>'' command.
- <P>
- <DT><B>w(here)</B><DD>Print a stack trace, with the most recent frame at the bottom.
- An arrow indicates the current frame, which determines the
- context of most commands.
- <P>
- <DT><B>d(own)</B><DD>Move the current frame one level down in the stack trace
- (to an older frame).
- <P>
- <DT><B>u(p)</B><DD>Move the current frame one level up in the stack trace
- (to a newer frame).
- <P>
- <DT><B>b(reak) [<VAR>lineno</VAR><CODE>|</CODE><VAR>function</VAR></B><DD>]
- <P>
- With a <VAR>lineno</VAR> argument, set a break there in the current
- file. With a <VAR>function</VAR> argument, set a break at the entry of
- that function. Without argument, list all breaks.
- <P>
- <DT><B>cl(ear) [<VAR>lineno</VAR></B><DD>]
- <P>
- With a <VAR>lineno</VAR> argument, clear that break in the current file.
- Without argument, clear all breaks (but first ask confirmation).
- <P>
- <DT><B>s(tep)</B><DD>Execute the current line, stop at the first possible occasion
- (either in a function that is called or on the next line in the
- current function).
- <P>
- <DT><B>n(ext)</B><DD>Continue execution until the next line in the current function
- is reached or it returns. (The difference between <CODE>next</CODE> and
- <CODE>step</CODE> is that <CODE>step</CODE> stops inside a called function, while
- <CODE>next</CODE> executes called functions at (nearly) full speed, only
- stopping at the next line in the current function.)
- <P>
- <DT><B>r(eturn)</B><DD>Continue execution until the current function returns.
- <P>
- <DT><B>c(ont(inue))</B><DD>Continue execution, only stop when a breakpoint is encountered.
- <P>
- <DT><B>l(ist) [<VAR>first</VAR> [, <VAR>last</VAR></B><DD>]]
- <P>
- List source code for the current file. Without arguments, list 11
- lines around the current line or continue the previous listing. With
- one argument, list 11 lines around at that line. With two arguments,
- list the given range; if the second argument is less than the first,
- it is interpreted as a count.
- <P>
- <DT><B>a(rgs)</B><DD>Print the argument list of the current function.
- <P>
- <DT><B>p <VAR>expression</VAR></B><DD>Evaluate the <VAR>expression</VAR> in the current context and print its
- value. (Note: <CODE>print</CODE> can also be used, but is not a debugger
- command --- this executes the Python <CODE>print</CODE> statement.)
- <P>
- <DT><B>[!</B><DD><VAR>statement</VAR>]
- <P>
- Execute the (one-line) <VAR>statement</VAR> in the context of
- the current stack frame.
- The exclamation point can be omitted unless the first word
- of the statement resembles a debugger command.
- To set a global variable, you can prefix the assignment
- command with a ``<CODE>global</CODE>'' command on the same line, e.g.:
- <UL COMPACT><CODE>(Pdb) global list_options; list_options = ['-l']<P>
- (Pdb)<P>
- </CODE></UL>
- <DT><B>q(uit)</B><DD>Quit from the debugger.
- The program being executed is aborted.
- <P>
- </DL>
-