Improved some error messages for command line processing.
[python/dscho.git] / Lib / pdb.doc
blob6ae54e7e77fa41f1e0bc4ba1b1066a11a77d2353
1 The Python Debugger
2 ===================
4 To use the debugger in its simplest form:
6         >>> import pdb
7         >>> pdb.run('<a statement>')
9 The debugger's prompt is '(Pdb) '.  This will stop in the first
10 function call in <a statement>.
12 Alternatively, if a statement terminated with an unhandled exception,
13 you can use pdb's post-mortem facility to inspect the contents of the
14 traceback:
16         >>> <a statement>
17         <exception traceback>
18         >>> import pdb
19         >>> pdb.pm()
21 The commands recognized by the debugger are listed in the next
22 section.  Most can be abbreviated as indicated; e.g., h(elp) means
23 that 'help' can be typed as 'h' or 'help' (but not as 'he' or 'hel',
24 nor as 'H' or 'Help' or 'HELP').  Optional arguments are enclosed in
25 square brackets.
27 A blank line repeats the previous command literally.  (Except for
28 'list', where it lists the next 11 lines.)
30 Commands that the debugger doesn't recognize are assumed to be Python
31 statements and are executed in the context of the program being
32 debugged.  Python statements can also be prefixed with an exclamation
33 point ('!').  This is a powerful way to inspect the program being
34 debugged; it is even possible to change variables.  When an exception
35 occurs in such a statement, the exception name is printed but the
36 debugger's state is not changed.
38 The debugger is not directly programmable; but it is implemented as a
39 class from which you can derive your own debugger class, so you can
40 make as fancy as you like.
43 Debugger commands
44 =================
46 h(elp)
47         Without argument, print the list of available commands.
48         With a command name as argument, print help about that command
49         "help pdb" pipes the full documentation file to the $PAGER
50         "help exec" gives help on the ! command
52 w(here)
53         Print a stack trace, with the most recent frame at the bottom.
54         An arrow indicates the "current frame", which determines the
55         context of most commands.
57 d(own)
58         Move the current frame one level down in the stack trace
59         (to an older frame).
61 u(p)
62         Move the current frame one level up in the stack trace
63         (to a newer frame).
65 b(reak) ([file:]lineno | function) [, "condition"]
66         With a line number argument, set a break there in the current
67         file.  With a function name, set a break at the entry of that
68         function.  Without argument, list all breaks.  If a second
69         argument is present, it is a string specifying an expression
70         which must evaluate to true before the breakpoint is honored.
72         The line number may be prefixed with a filename and a colon,
73         to specify a breakpoint in another file (probably one that
74         hasn't been loaded yet).  The file is searched on sys.path.
76 cl(ear) [lineno]
77         With a line number argument, clear that break in the current file.
78         Without argument, clear all breaks (but first ask confirmation).
80         The line number may be prefixed with a filename and a colon,
81         to specify a breakpoint in another file (probably one that
82         hasn't been loaded yet).  The file is searched on sys.path.
84 s(tep)
85         Execute the current line, stop at the first possible occasion
86         (either in a function that is called or in the current function).
88 n(ext)
89         Continue execution until the next line in the current function
90         is reached or it returns.
92 r(eturn)
93         Continue execution until the current function returns.
95 c(ont(inue))
96         Continue execution, only stop when a breakpoint is encountered.
98 l(ist) [first [,last]]
99         List source code for the current file.
100         Without arguments, list 11 lines around the current line
101         or continue the previous listing.
102         With one argument, list 11 lines starting at that line.
103         With two arguments, list the given range;
104         if the second argument is less than the first, it is a count.
106 a(rgs)
107         Print the argument list of the current function.
109 p expression
110         Print the value of the expression.
112 (!) statement
113         Execute the (one-line) statement in the context of
114         the current stack frame.
115         The exclamation point can be omitted unless the first word
116         of the statement resembles a debugger command.
117         To assign to a global variable you must always prefix the
118         command with a 'global' command, e.g.:
119         (Pdb) global list_options; list_options = ['-l']
120         (Pdb)
122 q(uit)
123         Quit from the debugger.
124         The program being executed is aborted.