blob: cab4569f4f0251e763a9e10e1456ac609af953e3 [file] [log] [blame]
Georg Brandl546e2d62007-09-12 18:04:37 +00001:mod:`pdb` --- The Python Debugger
2==================================
Georg Brandl116aa622007-08-15 14:28:22 +00003
4.. module:: pdb
5 :synopsis: The Python debugger for interactive interpreters.
6
7
8.. index:: single: debugging
9
10The module :mod:`pdb` defines an interactive source code debugger for Python
11programs. It supports setting (conditional) breakpoints and single stepping at
12the source line level, inspection of stack frames, source code listing, and
13evaluation of arbitrary Python code in the context of any stack frame. It also
14supports post-mortem debugging and can be called under program control.
15
16.. index::
17 single: Pdb (class in pdb)
18 module: bdb
19 module: cmd
20
Georg Brandl02053ee2010-07-18 10:11:03 +000021The debugger is extensible -- it is actually defined as the class :class:`Pdb`.
Georg Brandl116aa622007-08-15 14:28:22 +000022This is currently undocumented but easily understood by reading the source. The
Georg Brandl1f70cdf2010-03-21 09:04:24 +000023extension interface uses the modules :mod:`bdb` and :mod:`cmd`.
Georg Brandl116aa622007-08-15 14:28:22 +000024
25The debugger's prompt is ``(Pdb)``. Typical usage to run a program under control
26of the debugger is::
27
28 >>> import pdb
29 >>> import mymodule
30 >>> pdb.run('mymodule.test()')
31 > <string>(0)?()
32 (Pdb) continue
33 > <string>(1)?()
34 (Pdb) continue
35 NameError: 'spam'
36 > <string>(1)?()
Georg Brandl48310cd2009-01-03 21:18:54 +000037 (Pdb)
Georg Brandl116aa622007-08-15 14:28:22 +000038
39:file:`pdb.py` can also be invoked as a script to debug other scripts. For
40example::
41
Georg Brandl45bb63f2009-09-16 09:42:19 +000042 python3 -m pdb myscript.py
Georg Brandl116aa622007-08-15 14:28:22 +000043
44When invoked as a script, pdb will automatically enter post-mortem debugging if
Georg Brandle0230912010-07-30 08:29:39 +000045the program being debugged exits abnormally. After post-mortem debugging (or
46after normal exit of the program), pdb will restart the program. Automatic
Georg Brandl116aa622007-08-15 14:28:22 +000047restarting preserves pdb's state (such as breakpoints) and in most cases is more
48useful than quitting the debugger upon program's exit.
49
Georg Brandle0230912010-07-30 08:29:39 +000050.. versionadded:: 3.2
51 :file:`pdb.py` now accepts a ``-c`` option that executes commands as if given
52 in a :file:`.pdbrc` file, see :ref:`debugger-commands`.
53
Georg Brandl243ad662009-05-05 09:00:19 +000054The typical usage to break into the debugger from a running program is to
55insert ::
56
57 import pdb; pdb.set_trace()
58
59at the location you want to break into the debugger. You can then step through
Georg Brandl02053ee2010-07-18 10:11:03 +000060the code following this statement, and continue running without the debugger
61using the :pdbcmd:`continue` command.
Georg Brandl243ad662009-05-05 09:00:19 +000062
63The typical usage to inspect a crashed program is::
Georg Brandl116aa622007-08-15 14:28:22 +000064
65 >>> import pdb
66 >>> import mymodule
67 >>> mymodule.test()
68 Traceback (most recent call last):
69 File "<stdin>", line 1, in ?
70 File "./mymodule.py", line 4, in test
71 test2()
72 File "./mymodule.py", line 3, in test2
Georg Brandlc9879242007-09-04 07:07:56 +000073 print(spam)
Georg Brandl116aa622007-08-15 14:28:22 +000074 NameError: spam
75 >>> pdb.pm()
76 > ./mymodule.py(3)test2()
Georg Brandlc9879242007-09-04 07:07:56 +000077 -> print(spam)
Georg Brandl48310cd2009-01-03 21:18:54 +000078 (Pdb)
Georg Brandl116aa622007-08-15 14:28:22 +000079
Georg Brandl243ad662009-05-05 09:00:19 +000080
Georg Brandl116aa622007-08-15 14:28:22 +000081The module defines the following functions; each enters the debugger in a
82slightly different way:
83
Georg Brandl18244152009-09-02 20:34:52 +000084.. function:: run(statement, globals=None, locals=None)
Georg Brandl116aa622007-08-15 14:28:22 +000085
Georg Brandl46b9afc2010-07-30 09:14:20 +000086 Execute the *statement* (given as a string or a code object) under debugger
87 control. The debugger prompt appears before any code is executed; you can
88 set breakpoints and type :pdbcmd:`continue`, or you can step through the
89 statement using :pdbcmd:`step` or :pdbcmd:`next` (all these commands are
90 explained below). The optional *globals* and *locals* arguments specify the
91 environment in which the code is executed; by default the dictionary of the
92 module :mod:`__main__` is used. (See the explanation of the built-in
93 :func:`exec` or :func:`eval` functions.)
Georg Brandl116aa622007-08-15 14:28:22 +000094
95
Georg Brandl18244152009-09-02 20:34:52 +000096.. function:: runeval(expression, globals=None, locals=None)
Georg Brandl116aa622007-08-15 14:28:22 +000097
Georg Brandl46b9afc2010-07-30 09:14:20 +000098 Evaluate the *expression* (given as a string or a code object) under debugger
99 control. When :func:`runeval` returns, it returns the value of the
100 expression. Otherwise this function is similar to :func:`run`.
Georg Brandl116aa622007-08-15 14:28:22 +0000101
102
Georg Brandl18244152009-09-02 20:34:52 +0000103.. function:: runcall(function, *args, **kwds)
Georg Brandl116aa622007-08-15 14:28:22 +0000104
Georg Brandl02053ee2010-07-18 10:11:03 +0000105 Call the *function* (a function or method object, not a string) with the
106 given arguments. When :func:`runcall` returns, it returns whatever the
107 function call returned. The debugger prompt appears as soon as the function
108 is entered.
Georg Brandl116aa622007-08-15 14:28:22 +0000109
110
111.. function:: set_trace()
112
113 Enter the debugger at the calling stack frame. This is useful to hard-code a
114 breakpoint at a given point in a program, even if the code is not otherwise
115 being debugged (e.g. when an assertion fails).
116
117
Georg Brandl18244152009-09-02 20:34:52 +0000118.. function:: post_mortem(traceback=None)
Georg Brandl116aa622007-08-15 14:28:22 +0000119
Georg Brandl48310cd2009-01-03 21:18:54 +0000120 Enter post-mortem debugging of the given *traceback* object. If no
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000121 *traceback* is given, it uses the one of the exception that is currently
122 being handled (an exception must be being handled if the default is to be
123 used).
Georg Brandl116aa622007-08-15 14:28:22 +0000124
125
126.. function:: pm()
127
Georg Brandl243ad662009-05-05 09:00:19 +0000128 Enter post-mortem debugging of the traceback found in
129 :data:`sys.last_traceback`.
130
131
132The ``run_*`` functions and :func:`set_trace` are aliases for instantiating the
133:class:`Pdb` class and calling the method of the same name. If you want to
134access further features, you have to do this yourself:
135
136.. class:: Pdb(completekey='tab', stdin=None, stdout=None, skip=None)
137
138 :class:`Pdb` is the debugger class.
139
140 The *completekey*, *stdin* and *stdout* arguments are passed to the
141 underlying :class:`cmd.Cmd` class; see the description there.
142
143 The *skip* argument, if given, must be an iterable of glob-style module name
144 patterns. The debugger will not step into frames that originate in a module
145 that matches one of these patterns. [1]_
146
147 Example call to enable tracing with *skip*::
148
149 import pdb; pdb.Pdb(skip=['django.*']).set_trace()
150
Georg Brandl705d9d52009-05-05 09:29:50 +0000151 .. versionadded:: 3.1
Georg Brandl243ad662009-05-05 09:00:19 +0000152 The *skip* argument.
153
Georg Brandl18244152009-09-02 20:34:52 +0000154 .. method:: run(statement, globals=None, locals=None)
155 runeval(expression, globals=None, locals=None)
156 runcall(function, *args, **kwds)
Georg Brandl243ad662009-05-05 09:00:19 +0000157 set_trace()
158
159 See the documentation for the functions explained above.
Georg Brandl116aa622007-08-15 14:28:22 +0000160
161
162.. _debugger-commands:
163
164Debugger Commands
Alexander Belopolskyf0a0d142010-10-27 03:06:43 +0000165-----------------
Georg Brandl116aa622007-08-15 14:28:22 +0000166
Georg Brandl02053ee2010-07-18 10:11:03 +0000167The commands recognized by the debugger are listed below. Most commands can be
168abbreviated to one or two letters as indicated; e.g. ``h(elp)`` means that
169either ``h`` or ``help`` can be used to enter the help command (but not ``he``
170or ``hel``, nor ``H`` or ``Help`` or ``HELP``). Arguments to commands must be
171separated by whitespace (spaces or tabs). Optional arguments are enclosed in
172square brackets (``[]``) in the command syntax; the square brackets must not be
173typed. Alternatives in the command syntax are separated by a vertical bar
174(``|``).
Georg Brandl116aa622007-08-15 14:28:22 +0000175
176Entering a blank line repeats the last command entered. Exception: if the last
Georg Brandl02053ee2010-07-18 10:11:03 +0000177command was a :pdbcmd:`list` command, the next 11 lines are listed.
Georg Brandl116aa622007-08-15 14:28:22 +0000178
179Commands that the debugger doesn't recognize are assumed to be Python statements
180and are executed in the context of the program being debugged. Python
181statements can also be prefixed with an exclamation point (``!``). This is a
182powerful way to inspect the program being debugged; it is even possible to
183change a variable or call a function. When an exception occurs in such a
184statement, the exception name is printed but the debugger's state is not
185changed.
186
Georg Brandl02053ee2010-07-18 10:11:03 +0000187The debugger supports :ref:`aliases <debugger-aliases>`. Aliases can have
188parameters which allows one a certain level of adaptability to the context under
189examination.
190
Georg Brandl116aa622007-08-15 14:28:22 +0000191Multiple commands may be entered on a single line, separated by ``;;``. (A
192single ``;`` is not used as it is the separator for multiple commands in a line
Georg Brandl02053ee2010-07-18 10:11:03 +0000193that is passed to the Python parser.) No intelligence is applied to separating
Georg Brandl116aa622007-08-15 14:28:22 +0000194the commands; the input is split at the first ``;;`` pair, even if it is in the
195middle of a quoted string.
196
Georg Brandl116aa622007-08-15 14:28:22 +0000197.. index::
198 pair: .pdbrc; file
199 triple: debugger; configuration; file
200
Georg Brandl02053ee2010-07-18 10:11:03 +0000201If a file :file:`.pdbrc` exists in the user's home directory or in the current
Georg Brandl116aa622007-08-15 14:28:22 +0000202directory, it is read in and executed as if it had been typed at the debugger
Georg Brandl02053ee2010-07-18 10:11:03 +0000203prompt. This is particularly useful for aliases. If both files exist, the one
Georg Brandl116aa622007-08-15 14:28:22 +0000204in the home directory is read first and aliases defined there can be overridden
205by the local file.
206
Georg Brandle0230912010-07-30 08:29:39 +0000207.. versionchanged:: 3.2
208 :file:`.pdbrc` can now contain commands that continue debugging, such as
209 :pdbcmd:`continue` or :pdbcmd:`next`. Previously, these commands had no
210 effect.
211
Georg Brandl02053ee2010-07-18 10:11:03 +0000212
213.. pdbcommand:: h(elp) [command]
214
Georg Brandl116aa622007-08-15 14:28:22 +0000215 Without argument, print the list of available commands. With a *command* as
216 argument, print help about that command. ``help pdb`` displays the full
Georg Brandl55353ca2010-07-19 08:02:46 +0000217 documentation (the docstring of the :mod:`pdb` module). Since the *command*
218 argument must be an identifier, ``help exec`` must be entered to get help on
219 the ``!`` command.
Georg Brandl116aa622007-08-15 14:28:22 +0000220
Georg Brandl02053ee2010-07-18 10:11:03 +0000221.. pdbcommand:: w(here)
222
Georg Brandl116aa622007-08-15 14:28:22 +0000223 Print a stack trace, with the most recent frame at the bottom. An arrow
224 indicates the current frame, which determines the context of most commands.
225
Georg Brandl02053ee2010-07-18 10:11:03 +0000226.. pdbcommand:: d(own) [count]
227
Georg Brandleb1f4aa2010-06-27 10:37:48 +0000228 Move the current frame *count* (default one) levels down in the stack trace
229 (to a newer frame).
Georg Brandl116aa622007-08-15 14:28:22 +0000230
Georg Brandl02053ee2010-07-18 10:11:03 +0000231.. pdbcommand:: u(p) [count]
Georg Brandl116aa622007-08-15 14:28:22 +0000232
Georg Brandl02053ee2010-07-18 10:11:03 +0000233 Move the current frame *count* (default one) levels up in the stack trace (to
234 an older frame).
235
236.. pdbcommand:: b(reak) [([filename:]lineno | function) [, condition]]
237
Georg Brandl116aa622007-08-15 14:28:22 +0000238 With a *lineno* argument, set a break there in the current file. With a
Georg Brandl02053ee2010-07-18 10:11:03 +0000239 *function* argument, set a break at the first executable statement within
240 that function. The line number may be prefixed with a filename and a colon,
241 to specify a breakpoint in another file (probably one that hasn't been loaded
242 yet). The file is searched on :data:`sys.path`. Note that each breakpoint
243 is assigned a number to which all the other breakpoint commands refer.
Georg Brandl116aa622007-08-15 14:28:22 +0000244
Georg Brandl02053ee2010-07-18 10:11:03 +0000245 If a second argument is present, it is an expression which must evaluate to
246 true before the breakpoint is honored.
Georg Brandl116aa622007-08-15 14:28:22 +0000247
Georg Brandl02053ee2010-07-18 10:11:03 +0000248 Without argument, list all breaks, including for each breakpoint, the number
249 of times that breakpoint has been hit, the current ignore count, and the
250 associated condition if any.
Georg Brandl116aa622007-08-15 14:28:22 +0000251
Georg Brandl02053ee2010-07-18 10:11:03 +0000252.. pdbcommand:: tbreak [([filename:]lineno | function) [, condition]]
Georg Brandl116aa622007-08-15 14:28:22 +0000253
Georg Brandl02053ee2010-07-18 10:11:03 +0000254 Temporary breakpoint, which is removed automatically when it is first hit.
255 The arguments are the same as for :pdbcmd:`break`.
256
257.. pdbcommand:: cl(ear) [bpnumber [bpnumber ...]]
258
Georg Brandl116aa622007-08-15 14:28:22 +0000259 With a space separated list of breakpoint numbers, clear those breakpoints.
260 Without argument, clear all breaks (but first ask confirmation).
261
Georg Brandl02053ee2010-07-18 10:11:03 +0000262.. pdbcommand:: disable [bpnumber [bpnumber ...]]
Georg Brandl116aa622007-08-15 14:28:22 +0000263
Georg Brandl02053ee2010-07-18 10:11:03 +0000264 Disable the breakpoints given as a space separated list of breakpoint
265 numbers. Disabling a breakpoint means it cannot cause the program to stop
266 execution, but unlike clearing a breakpoint, it remains in the list of
267 breakpoints and can be (re-)enabled.
Georg Brandl116aa622007-08-15 14:28:22 +0000268
Georg Brandl02053ee2010-07-18 10:11:03 +0000269.. pdbcommand:: enable [bpnumber [bpnumber ...]]
Georg Brandl116aa622007-08-15 14:28:22 +0000270
Georg Brandl02053ee2010-07-18 10:11:03 +0000271 Enable the breakpoints specified.
Georg Brandl116aa622007-08-15 14:28:22 +0000272
Georg Brandl02053ee2010-07-18 10:11:03 +0000273.. pdbcommand:: ignore bpnumber [count]
274
275 Set the ignore count for the given breakpoint number. If count is omitted,
276 the ignore count is set to 0. A breakpoint becomes active when the ignore
277 count is zero. When non-zero, the count is decremented each time the
278 breakpoint is reached and the breakpoint is not disabled and any associated
279 condition evaluates to true.
280
281.. pdbcommand:: condition bpnumber [condition]
282
283 Set a new *condition* for the breakpoint, an expression which must evaluate
284 to true before the breakpoint is honored. If *condition* is absent, any
285 existing condition is removed; i.e., the breakpoint is made unconditional.
286
287.. pdbcommand:: commands [bpnumber]
288
Georg Brandl116aa622007-08-15 14:28:22 +0000289 Specify a list of commands for breakpoint number *bpnumber*. The commands
Georg Brandl02053ee2010-07-18 10:11:03 +0000290 themselves appear on the following lines. Type a line containing just
291 ``end`` to terminate the commands. An example::
Georg Brandl116aa622007-08-15 14:28:22 +0000292
293 (Pdb) commands 1
294 (com) print some_variable
295 (com) end
296 (Pdb)
297
298 To remove all commands from a breakpoint, type commands and follow it
Georg Brandl02053ee2010-07-18 10:11:03 +0000299 immediately with ``end``; that is, give no commands.
Georg Brandl116aa622007-08-15 14:28:22 +0000300
301 With no *bpnumber* argument, commands refers to the last breakpoint set.
302
Georg Brandl02053ee2010-07-18 10:11:03 +0000303 You can use breakpoint commands to start your program up again. Simply use
304 the continue command, or step, or any other command that resumes execution.
Georg Brandl116aa622007-08-15 14:28:22 +0000305
306 Specifying any command resuming execution (currently continue, step, next,
307 return, jump, quit and their abbreviations) terminates the command list (as if
308 that command was immediately followed by end). This is because any time you
Georg Brandl9afde1c2007-11-01 20:32:30 +0000309 resume execution (even with a simple next or step), you may encounter another
Georg Brandl116aa622007-08-15 14:28:22 +0000310 breakpoint--which could have its own command list, leading to ambiguities about
311 which list to execute.
312
313 If you use the 'silent' command in the command list, the usual message about
314 stopping at a breakpoint is not printed. This may be desirable for breakpoints
315 that are to print a specific message and then continue. If none of the other
316 commands print anything, you see no sign that the breakpoint was reached.
317
Georg Brandl02053ee2010-07-18 10:11:03 +0000318.. pdbcommand:: s(tep)
319
Georg Brandl116aa622007-08-15 14:28:22 +0000320 Execute the current line, stop at the first possible occasion (either in a
321 function that is called or on the next line in the current function).
322
Georg Brandl02053ee2010-07-18 10:11:03 +0000323.. pdbcommand:: n(ext)
Georg Brandl116aa622007-08-15 14:28:22 +0000324
Georg Brandl02053ee2010-07-18 10:11:03 +0000325 Continue execution until the next line in the current function is reached or
326 it returns. (The difference between :pdbcmd:`next` and :pdbcmd:`step` is
327 that :pdbcmd:`step` stops inside a called function, while :pdbcmd:`next`
328 executes called functions at (nearly) full speed, only stopping at the next
329 line in the current function.)
330
Georg Brandl2dfec552010-07-30 08:43:32 +0000331.. pdbcommand:: unt(il) [lineno]
Georg Brandl02053ee2010-07-18 10:11:03 +0000332
Georg Brandl2dfec552010-07-30 08:43:32 +0000333 Without argument, continue execution until the line with a number greater
334 than the current one is reached.
335
336 With a line number, continue execution until a line with a number greater or
337 equal to that is reached. In both cases, also stop when the current frame
338 returns.
Alexandre Vassalotti5f8ced22008-05-16 00:03:33 +0000339
Georg Brandl26a0f872010-07-30 08:45:26 +0000340 .. versionchanged:: 3.2
341 Allow giving an explicit line number.
342
Georg Brandl02053ee2010-07-18 10:11:03 +0000343.. pdbcommand:: r(eturn)
344
Georg Brandl116aa622007-08-15 14:28:22 +0000345 Continue execution until the current function returns.
346
Georg Brandl02053ee2010-07-18 10:11:03 +0000347.. pdbcommand:: c(ont(inue))
348
Georg Brandl116aa622007-08-15 14:28:22 +0000349 Continue execution, only stop when a breakpoint is encountered.
350
Georg Brandl02053ee2010-07-18 10:11:03 +0000351.. pdbcommand:: j(ump) lineno
Georg Brandl116aa622007-08-15 14:28:22 +0000352
Georg Brandl02053ee2010-07-18 10:11:03 +0000353 Set the next line that will be executed. Only available in the bottom-most
354 frame. This lets you jump back and execute code again, or jump forward to
355 skip code that you don't want to run.
356
357 It should be noted that not all jumps are allowed -- for instance it is not
Georg Brandl116aa622007-08-15 14:28:22 +0000358 possible to jump into the middle of a :keyword:`for` loop or out of a
359 :keyword:`finally` clause.
360
Georg Brandl02053ee2010-07-18 10:11:03 +0000361.. pdbcommand:: l(ist) [first[, last]]
Georg Brandl116aa622007-08-15 14:28:22 +0000362
Georg Brandl02053ee2010-07-18 10:11:03 +0000363 List source code for the current file. Without arguments, list 11 lines
Georg Brandla5eacee2010-07-23 16:55:26 +0000364 around the current line or continue the previous listing. With ``.`` as
365 argument, list 11 lines around the current line. With one argument,
Georg Brandl02053ee2010-07-18 10:11:03 +0000366 list 11 lines around at that line. With two arguments, list the given range;
367 if the second argument is less than the first, it is interpreted as a count.
368
Georg Brandl0a9c3e92010-07-30 18:46:38 +0000369 The current line in the current frame is indicated by ``->``. If an
370 exception is being debugged, the line where the exception was originally
371 raised or propagated is indicated by ``>>``, if it differs from the current
372 line.
373
374 .. versionadded:: 3.2
375 The ``>>`` marker.
376
Georg Brandle59ca2a2010-07-30 17:04:28 +0000377.. pdbcommand:: ll | longlist
378
Georg Brandl0a9c3e92010-07-30 18:46:38 +0000379 List all source code for the current function or frame. Interesting lines
380 are marked as for :pdbcmd:`list`.
Georg Brandle59ca2a2010-07-30 17:04:28 +0000381
382 .. versionadded:: 3.2
383
Georg Brandl02053ee2010-07-18 10:11:03 +0000384.. pdbcommand:: a(rgs)
385
Georg Brandl116aa622007-08-15 14:28:22 +0000386 Print the argument list of the current function.
387
Georg Brandl02053ee2010-07-18 10:11:03 +0000388.. pdbcommand:: p(rint) expression
389
Georg Brandl116aa622007-08-15 14:28:22 +0000390 Evaluate the *expression* in the current context and print its value.
391
Georg Brandl02053ee2010-07-18 10:11:03 +0000392.. pdbcommand:: pp expression
Georg Brandl116aa622007-08-15 14:28:22 +0000393
Georg Brandl02053ee2010-07-18 10:11:03 +0000394 Like the :pdbcmd:`print` command, except the value of the expression is
395 pretty-printed using the :mod:`pprint` module.
Georg Brandl116aa622007-08-15 14:28:22 +0000396
Georg Brandl02053ee2010-07-18 10:11:03 +0000397.. pdbcommand:: whatis expression
398
399 Print the type of the *expression*.
400
Georg Brandle59ca2a2010-07-30 17:04:28 +0000401.. pdbcommand:: source expression
402
403 Try to get source code for the given object and display it.
404
405 .. versionadded:: 3.2
406
Georg Brandl02053ee2010-07-18 10:11:03 +0000407.. _debugger-aliases:
408
409.. pdbcommand:: alias [name [command]]
410
411 Create an alias called *name* that executes *command*. The command must
412 *not* be enclosed in quotes. Replaceable parameters can be indicated by
413 ``%1``, ``%2``, and so on, while ``%*`` is replaced by all the parameters.
414 If no command is given, the current alias for *name* is shown. If no
415 arguments are given, all aliases are listed.
416
417 Aliases may be nested and can contain anything that can be legally typed at
418 the pdb prompt. Note that internal pdb commands *can* be overridden by
419 aliases. Such a command is then hidden until the alias is removed. Aliasing
420 is recursively applied to the first word of the command line; all other words
421 in the line are left alone.
Georg Brandl116aa622007-08-15 14:28:22 +0000422
423 As an example, here are two useful aliases (especially when placed in the
424 :file:`.pdbrc` file)::
425
Georg Brandle0230912010-07-30 08:29:39 +0000426 # Print instance variables (usage "pi classInst")
Georg Brandlc9879242007-09-04 07:07:56 +0000427 alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])
Georg Brandle0230912010-07-30 08:29:39 +0000428 # Print instance variables in self
Georg Brandl116aa622007-08-15 14:28:22 +0000429 alias ps pi self
430
Georg Brandl02053ee2010-07-18 10:11:03 +0000431.. pdbcommand:: unalias name
Georg Brandl116aa622007-08-15 14:28:22 +0000432
Georg Brandl02053ee2010-07-18 10:11:03 +0000433 Delete the specified alias.
434
435.. pdbcommand:: ! statement
436
Georg Brandl116aa622007-08-15 14:28:22 +0000437 Execute the (one-line) *statement* in the context of the current stack frame.
438 The exclamation point can be omitted unless the first word of the statement
Georg Brandl02053ee2010-07-18 10:11:03 +0000439 resembles a debugger command. To set a global variable, you can prefix the
440 assignment command with a :keyword:`global` statement on the same line,
441 e.g.::
Georg Brandl116aa622007-08-15 14:28:22 +0000442
443 (Pdb) global list_options; list_options = ['-l']
444 (Pdb)
445
Georg Brandl02053ee2010-07-18 10:11:03 +0000446.. pdbcommand:: run [args ...]
447 restart [args ...]
Georg Brandl116aa622007-08-15 14:28:22 +0000448
Georg Brandl02053ee2010-07-18 10:11:03 +0000449 Restart the debugged Python program. If an argument is supplied, it is split
450 with :mod:`shlex` and the result is used as the new :data:`sys.argv`.
451 History, breakpoints, actions and debugger options are preserved.
452 :pdbcmd:`restart` is an alias for :pdbcmd:`run`.
453
454.. pdbcommand:: q(uit)
455
456 Quit from the debugger. The program being executed is aborted.
Georg Brandl243ad662009-05-05 09:00:19 +0000457
458
459.. rubric:: Footnotes
460
461.. [1] Whether a frame is considered to originate in a certain module
462 is determined by the ``__name__`` in the frame globals.