summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/library%2Fpdb.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/python~3.12/library%2Fpdb.html
new repository
Diffstat (limited to 'devdocs/python~3.12/library%2Fpdb.html')
-rw-r--r--devdocs/python~3.12/library%2Fpdb.html229
1 files changed, 229 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Fpdb.html b/devdocs/python~3.12/library%2Fpdb.html
new file mode 100644
index 00000000..2ba6467c
--- /dev/null
+++ b/devdocs/python~3.12/library%2Fpdb.html
@@ -0,0 +1,229 @@
+ <span id="pdb-the-python-debugger"></span><span id="debugger"></span><h1>pdb — The Python Debugger</h1> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/pdb.py">Lib/pdb.py</a></p> <p>The module <a class="reference internal" href="#module-pdb" title="pdb: The Python debugger for interactive interpreters."><code>pdb</code></a> defines an interactive source code debugger for Python programs. It supports setting (conditional) breakpoints and single stepping at the source line level, inspection of stack frames, source code listing, and evaluation of arbitrary Python code in the context of any stack frame. It also supports post-mortem debugging and can be called under program control.</p> <p id="index-1">The debugger is extensible – it is actually defined as the class <a class="reference internal" href="#pdb.Pdb" title="pdb.Pdb"><code>Pdb</code></a>. This is currently undocumented but easily understood by reading the source. The extension interface uses the modules <a class="reference internal" href="bdb#module-bdb" title="bdb: Debugger framework."><code>bdb</code></a> and <a class="reference internal" href="cmd#module-cmd" title="cmd: Build line-oriented command interpreters."><code>cmd</code></a>.</p> <div class="admonition seealso"> <p class="admonition-title">See also</p> <dl class="simple"> <dt>
+<code>Module</code> <a class="reference internal" href="faulthandler#module-faulthandler" title="faulthandler: Dump the Python traceback."><code>faulthandler</code></a>
+</dt>
+<dd>
+<p>Used to dump Python tracebacks explicitly, on a fault, after a timeout, or on a user signal.</p> </dd> <dt>
+<code>Module</code> <a class="reference internal" href="traceback#module-traceback" title="traceback: Print or retrieve a stack traceback."><code>traceback</code></a>
+</dt>
+<dd>
+<p>Standard interface to extract, format and print stack traces of Python programs.</p> </dd> </dl> </div> <p>The typical usage to break into the debugger is to insert:</p> <pre data-language="python">import pdb; pdb.set_trace()
+</pre> <p>Or:</p> <pre data-language="python">breakpoint()
+</pre> <p>at the location you want to break into the debugger, and then run the program. You can then step through the code following this statement, and continue running without the debugger using the <a class="reference internal" href="#pdbcommand-continue"><code>continue</code></a> command.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.7: </span>The built-in <a class="reference internal" href="functions#breakpoint" title="breakpoint"><code>breakpoint()</code></a>, when called with defaults, can be used instead of <code>import pdb; pdb.set_trace()</code>.</p> </div> <pre data-language="python">def double(x):
+ breakpoint()
+ return x * 2
+val = 3
+print(f"{val} * 2 is {double(val)}")
+</pre> <p>The debugger’s prompt is <code>(Pdb)</code>, which is the indicator that you are in debug mode:</p> <pre data-language="python">&gt; ...(3)double()
+-&gt; return x * 2
+(Pdb) p x
+3
+(Pdb) continue
+3 * 2 is 6
+</pre> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.3: </span>Tab-completion via the <a class="reference internal" href="readline#module-readline" title="readline: GNU readline support for Python. (Unix)"><code>readline</code></a> module is available for commands and command arguments, e.g. the current global and local names are offered as arguments of the <code>p</code> command.</p> </div> <p>You can also invoke <a class="reference internal" href="#module-pdb" title="pdb: The Python debugger for interactive interpreters."><code>pdb</code></a> from the command line to debug other scripts. For example:</p> <pre data-language="python">python -m pdb myscript.py
+</pre> <p>When invoked as a module, pdb will automatically enter post-mortem debugging if the program being debugged exits abnormally. After post-mortem debugging (or after normal exit of the program), pdb will restart the program. Automatic restarting preserves pdb’s state (such as breakpoints) and in most cases is more useful than quitting the debugger upon program’s exit.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2: </span><code>-c</code> option is introduced to execute commands as if given in a <code>.pdbrc</code> file, see <a class="reference internal" href="#debugger-commands"><span class="std std-ref">Debugger Commands</span></a>.</p> </div> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.7: </span><code>-m</code> option is introduced to execute modules similar to the way <code>python -m</code> does. As with a script, the debugger will pause execution just before the first line of the module.</p> </div> <p>Typical usage to execute a statement under control of the debugger is:</p> <pre data-language="python">&gt;&gt;&gt; import pdb
+&gt;&gt;&gt; def f(x):
+... print(1 / x)
+&gt;&gt;&gt; pdb.run("f(2)")
+&gt; &lt;string&gt;(1)&lt;module&gt;()
+(Pdb) continue
+0.5
+&gt;&gt;&gt;
+</pre> <p>The typical usage to inspect a crashed program is:</p> <pre data-language="python">&gt;&gt;&gt; import pdb
+&gt;&gt;&gt; def f(x):
+... print(1 / x)
+...
+&gt;&gt;&gt; f(0)
+Traceback (most recent call last):
+ File "&lt;stdin&gt;", line 1, in &lt;module&gt;
+ File "&lt;stdin&gt;", line 2, in f
+ZeroDivisionError: division by zero
+&gt;&gt;&gt; pdb.pm()
+&gt; &lt;stdin&gt;(2)f()
+(Pdb) p x
+0
+(Pdb)
+</pre> <p>The module defines the following functions; each enters the debugger in a slightly different way:</p> <dl class="py function"> <dt class="sig sig-object py" id="pdb.run">
+<code>pdb.run(statement, globals=None, locals=None)</code> </dt> <dd>
+<p>Execute the <em>statement</em> (given as a string or a code object) under debugger control. The debugger prompt appears before any code is executed; you can set breakpoints and type <a class="reference internal" href="#pdbcommand-continue"><code>continue</code></a>, or you can step through the statement using <a class="reference internal" href="#pdbcommand-step"><code>step</code></a> or <a class="reference internal" href="#pdbcommand-next"><code>next</code></a> (all these commands are explained below). The optional <em>globals</em> and <em>locals</em> arguments specify the environment in which the code is executed; by default the dictionary of the module <a class="reference internal" href="__main__#module-__main__" title="__main__: The environment where top-level code is run. Covers command-line interfaces, import-time behavior, and ``__name__ == '__main__'``."><code>__main__</code></a> is used. (See the explanation of the built-in <a class="reference internal" href="functions#exec" title="exec"><code>exec()</code></a> or <a class="reference internal" href="functions#eval" title="eval"><code>eval()</code></a> functions.)</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="pdb.runeval">
+<code>pdb.runeval(expression, globals=None, locals=None)</code> </dt> <dd>
+<p>Evaluate the <em>expression</em> (given as a string or a code object) under debugger control. When <a class="reference internal" href="#pdb.runeval" title="pdb.runeval"><code>runeval()</code></a> returns, it returns the value of the <em>expression</em>. Otherwise this function is similar to <a class="reference internal" href="#pdb.run" title="pdb.run"><code>run()</code></a>.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="pdb.runcall">
+<code>pdb.runcall(function, *args, **kwds)</code> </dt> <dd>
+<p>Call the <em>function</em> (a function or method object, not a string) with the given arguments. When <a class="reference internal" href="#pdb.runcall" title="pdb.runcall"><code>runcall()</code></a> returns, it returns whatever the function call returned. The debugger prompt appears as soon as the function is entered.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="pdb.set_trace">
+<code>pdb.set_trace(*, header=None)</code> </dt> <dd>
+<p>Enter the debugger at the calling stack frame. This is useful to hard-code a breakpoint at a given point in a program, even if the code is not otherwise being debugged (e.g. when an assertion fails). If given, <em>header</em> is printed to the console just before debugging begins.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.7: </span>The keyword-only argument <em>header</em>.</p> </div> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="pdb.post_mortem">
+<code>pdb.post_mortem(traceback=None)</code> </dt> <dd>
+<p>Enter post-mortem debugging of the given <em>traceback</em> object. If no <em>traceback</em> is given, it uses the one of the exception that is currently being handled (an exception must be being handled if the default is to be used).</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="pdb.pm">
+<code>pdb.pm()</code> </dt> <dd>
+<p>Enter post-mortem debugging of the traceback found in <a class="reference internal" href="sys#sys.last_traceback" title="sys.last_traceback"><code>sys.last_traceback</code></a>.</p> </dd>
+</dl> <p>The <code>run*</code> functions and <a class="reference internal" href="#pdb.set_trace" title="pdb.set_trace"><code>set_trace()</code></a> are aliases for instantiating the <a class="reference internal" href="#pdb.Pdb" title="pdb.Pdb"><code>Pdb</code></a> class and calling the method of the same name. If you want to access further features, you have to do this yourself:</p> <dl class="py class"> <dt class="sig sig-object py" id="pdb.Pdb">
+<code>class pdb.Pdb(completekey='tab', stdin=None, stdout=None, skip=None, nosigint=False, readrc=True)</code> </dt> <dd>
+<p><a class="reference internal" href="#pdb.Pdb" title="pdb.Pdb"><code>Pdb</code></a> is the debugger class.</p> <p>The <em>completekey</em>, <em>stdin</em> and <em>stdout</em> arguments are passed to the underlying <a class="reference internal" href="cmd#cmd.Cmd" title="cmd.Cmd"><code>cmd.Cmd</code></a> class; see the description there.</p> <p>The <em>skip</em> argument, if given, must be an iterable of glob-style module name patterns. The debugger will not step into frames that originate in a module that matches one of these patterns. <a class="footnote-reference brackets" href="#id3" id="id1">1</a></p> <p>By default, Pdb sets a handler for the SIGINT signal (which is sent when the user presses <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Ctrl</kbd>-<kbd class="kbd docutils literal notranslate">C</kbd></kbd> on the console) when you give a <a class="reference internal" href="#pdbcommand-continue"><code>continue</code></a> command. This allows you to break into the debugger again by pressing <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Ctrl</kbd>-<kbd class="kbd docutils literal notranslate">C</kbd></kbd>. If you want Pdb not to touch the SIGINT handler, set <em>nosigint</em> to true.</p> <p>The <em>readrc</em> argument defaults to true and controls whether Pdb will load .pdbrc files from the filesystem.</p> <p>Example call to enable tracing with <em>skip</em>:</p> <pre data-language="python">import pdb; pdb.Pdb(skip=['django.*']).set_trace()
+</pre> <p class="audit-hook">Raises an <a class="reference internal" href="sys#auditing"><span class="std std-ref">auditing event</span></a> <code>pdb.Pdb</code> with no arguments.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.1: </span>The <em>skip</em> argument.</p> </div> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2: </span>The <em>nosigint</em> argument. Previously, a SIGINT handler was never set by Pdb.</p> </div> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.6: </span>The <em>readrc</em> argument.</p> </div> <dl class="py method"> <dt class="sig sig-object py" id="pdb.Pdb.run">
+<code>run(statement, globals=None, locals=None)</code> </dt> <dt class="sig sig-object py" id="pdb.Pdb.runeval">
+<code>runeval(expression, globals=None, locals=None)</code> </dt> <dt class="sig sig-object py" id="pdb.Pdb.runcall">
+<code>runcall(function, *args, **kwds)</code> </dt> <dt class="sig sig-object py" id="pdb.Pdb.set_trace">
+<code>set_trace()</code> </dt> <dd>
+<p>See the documentation for the functions explained above.</p> </dd>
+</dl> </dd>
+</dl> <section id="debugger-commands"> <span id="id2"></span><h2>Debugger Commands</h2> <p>The commands recognized by the debugger are listed below. Most commands can be abbreviated to one or two letters as indicated; 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> <p>Entering a blank line repeats the last command entered. Exception: if the last command was a <a class="reference internal" href="#pdbcommand-list"><code>list</code></a> command, the next 11 lines are listed.</p> <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> <p>The debugger supports <a class="reference internal" href="#debugger-aliases"><span class="std std-ref">aliases</span></a>. Aliases can have parameters which allows one a certain level of adaptability to the context under examination.</p> <p>Multiple commands may be entered on a single line, separated by <code>;;</code>. (A single <code>;</code> is not used as it is the separator for multiple commands in a line that is passed to the Python parser.) No intelligence is applied to separating the commands; the input is split at the first <code>;;</code> pair, even if it is in the middle of a quoted string. A workaround for strings with double semicolons is to use implicit string concatenation <code>';'';'</code> or <code>";"";"</code>.</p> <p>To set a temporary global variable, use a <em>convenience variable</em>. A <em>convenience variable</em> is a variable whose name starts with <code>$</code>. For example, <code>$foo = 1</code> sets a global variable <code>$foo</code> which you can use in the debugger session. The <em>convenience variables</em> are cleared when the program resumes execution so it’s less likely to interfere with your program compared to using normal variables like <code>foo = 1</code>.</p> <p>There are three preset <em>convenience variables</em>:</p> <ul class="simple"> <li>
+<code>$_frame</code>: the current frame you are debugging</li> <li>
+<code>$_retval</code>: the return value if the frame is returning</li> <li>
+<code>$_exception</code>: the exception if the frame is raising an exception</li> </ul> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.12.</span></p> </div> <p id="index-2">If a file <code>.pdbrc</code> exists in the user’s home directory or in the current directory, it is read with <code>'utf-8'</code> encoding and executed as if it had been typed at the debugger prompt. This is particularly useful for aliases. If both files exist, the one in the home directory is read first and aliases defined there can be overridden by the local file.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.11: </span><code>.pdbrc</code> is now read with <code>'utf-8'</code> encoding. Previously, it was read with the system locale encoding.</p> </div> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.2: </span><code>.pdbrc</code> can now contain commands that continue debugging, such as <a class="reference internal" href="#pdbcommand-continue"><code>continue</code></a> or <a class="reference internal" href="#pdbcommand-next"><code>next</code></a>. Previously, these commands had no effect.</p> </div> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-help">
+<code>h(elp) [command]</code> </dt> <dd>
+<p>Without argument, print the list of available commands. With a <em>command</em> as argument, print help about that command. <code>help pdb</code> displays the full documentation (the docstring of the <a class="reference internal" href="#module-pdb" title="pdb: The Python debugger for interactive interpreters."><code>pdb</code></a> module). Since the <em>command</em> argument must be an identifier, <code>help exec</code> must be entered to get help on the <code>!</code> command.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-where">
+<code>w(here)</code> </dt> <dd>
+<p>Print a stack trace, with the most recent frame at the bottom. An arrow (<code>&gt;</code>) indicates the current frame, which determines the context of most commands.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-down">
+<code>d(own) [count]</code> </dt> <dd>
+<p>Move the current frame <em>count</em> (default one) levels down in the stack trace (to a newer frame).</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-up">
+<code>u(p) [count]</code> </dt> <dd>
+<p>Move the current frame <em>count</em> (default one) levels up in the stack trace (to an older frame).</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-break">
+<code>b(reak) [([filename:]lineno | function) [, condition]]</code> </dt> <dd>
+<p>With a <em>lineno</em> argument, set a break there in the current file. With a <em>function</em> argument, set a break at the first executable statement within that function. The line number may be prefixed with a filename and a colon, to specify a breakpoint in another file (probably one that hasn’t been loaded yet). The file is searched on <a class="reference internal" href="sys#sys.path" title="sys.path"><code>sys.path</code></a>. Note that each breakpoint is assigned a number to which all the other breakpoint commands refer.</p> <p>If a second argument is present, it is an expression which must evaluate to true before the breakpoint is honored.</p> <p>Without argument, list all breaks, including for each breakpoint, the number of times that breakpoint has been hit, the current ignore count, and the associated condition if any.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-tbreak">
+<code>tbreak [([filename:]lineno | function) [, condition]]</code> </dt> <dd>
+<p>Temporary breakpoint, which is removed automatically when it is first hit. The arguments are the same as for <a class="reference internal" href="#pdbcommand-break"><code>break</code></a>.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-clear">
+<code>cl(ear) [filename:lineno | bpnumber ...]</code> </dt> <dd>
+<p>With a <em>filename:lineno</em> argument, clear all the breakpoints at this line. With a space separated list of breakpoint numbers, clear those breakpoints. Without argument, clear all breaks (but first ask confirmation).</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-disable">
+<code>disable bpnumber [bpnumber ...]</code> </dt> <dd>
+<p>Disable the breakpoints given as a space separated list of breakpoint numbers. Disabling a breakpoint means it cannot cause the program to stop execution, but unlike clearing a breakpoint, it remains in the list of breakpoints and can be (re-)enabled.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-enable">
+<code>enable bpnumber [bpnumber ...]</code> </dt> <dd>
+<p>Enable the breakpoints specified.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-ignore">
+<code>ignore bpnumber [count]</code> </dt> <dd>
+<p>Set the ignore count for the given breakpoint number. If <em>count</em> is omitted, the ignore count is set to 0. A breakpoint becomes active when the ignore count is zero. When non-zero, the <em>count</em> is decremented each time the breakpoint is reached and the breakpoint is not disabled and any associated condition evaluates to true.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-condition">
+<code>condition bpnumber [condition]</code> </dt> <dd>
+<p>Set a new <em>condition</em> for the breakpoint, an expression which must evaluate to true before the breakpoint is honored. If <em>condition</em> is absent, any existing condition is removed; i.e., the breakpoint is made unconditional.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-commands">
+<code>commands [bpnumber]</code> </dt> <dd>
+<p>Specify a list of commands for breakpoint number <em>bpnumber</em>. The commands themselves appear on the following lines. Type a line containing just <code>end</code> to terminate the commands. An example:</p> <pre data-language="python">(Pdb) commands 1
+(com) p some_variable
+(com) end
+(Pdb)
+</pre> <p>To remove all commands from a breakpoint, type <code>commands</code> and follow it immediately with <code>end</code>; that is, give no commands.</p> <p>With no <em>bpnumber</em> argument, <code>commands</code> refers to the last breakpoint set.</p> <p>You can use breakpoint commands to start your program up again. Simply use the <a class="reference internal" href="#pdbcommand-continue"><code>continue</code></a> command, or <a class="reference internal" href="#pdbcommand-step"><code>step</code></a>, or any other command that resumes execution.</p> <p>Specifying any command resuming execution (currently <a class="reference internal" href="#pdbcommand-continue"><code>continue</code></a>, <a class="reference internal" href="#pdbcommand-step"><code>step</code></a>, <a class="reference internal" href="#pdbcommand-next"><code>next</code></a>, <a class="reference internal" href="#pdbcommand-return"><code>return</code></a>, <a class="reference internal" href="#pdbcommand-jump"><code>jump</code></a>, <a class="reference internal" href="#pdbcommand-quit"><code>quit</code></a> and their abbreviations) terminates the command list (as if that command was immediately followed by end). This is because any time you resume execution (even with a simple next or step), you may encounter another breakpoint—which could have its own command list, leading to ambiguities about which list to execute.</p> <p>If you use the <code>silent</code> command in the command list, the usual message about stopping at a breakpoint is not printed. This may be desirable for breakpoints that are to print a specific message and then continue. If none of the other commands print anything, you see no sign that the breakpoint was reached.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-step">
+<code>s(tep)</code> </dt> <dd>
+<p>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> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-next">
+<code>n(ext)</code> </dt> <dd>
+<p>Continue execution until the next line in the current function is reached or it returns. (The difference between <a class="reference internal" href="#pdbcommand-next"><code>next</code></a> and <a class="reference internal" href="#pdbcommand-step"><code>step</code></a> is that <a class="reference internal" href="#pdbcommand-step"><code>step</code></a> stops inside a called function, while <a class="reference internal" href="#pdbcommand-next"><code>next</code></a> executes called functions at (nearly) full speed, only stopping at the next line in the current function.)</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-until">
+<code>unt(il) [lineno]</code> </dt> <dd>
+<p>Without argument, continue execution until the line with a number greater than the current one is reached.</p> <p>With <em>lineno</em>, continue execution until a line with a number greater or equal to <em>lineno</em> is reached. In both cases, also stop when the current frame returns.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.2: </span>Allow giving an explicit line number.</p> </div> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-return">
+<code>r(eturn)</code> </dt> <dd>
+<p>Continue execution until the current function returns.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-continue">
+<code>c(ont(inue))</code> </dt> <dd>
+<p>Continue execution, only stop when a breakpoint is encountered.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-jump">
+<code>j(ump) lineno</code> </dt> <dd>
+<p>Set the next line that will be executed. Only available in the bottom-most frame. This lets you jump back and execute code again, or jump forward to skip code that you don’t want to run.</p> <p>It should be noted that not all jumps are allowed – for instance it is not possible to jump into the middle of a <a class="reference internal" href="../reference/compound_stmts#for"><code>for</code></a> loop or out of a <a class="reference internal" href="../reference/compound_stmts#finally"><code>finally</code></a> clause.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-list">
+<code>l(ist) [first[, last]]</code> </dt> <dd>
+<p>List source code for the current file. Without arguments, list 11 lines around the current line or continue the previous listing. With <code>.</code> as argument, list 11 lines around the current line. 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> <p>The current line in the current frame is indicated by <code>-&gt;</code>. If an exception is being debugged, the line where the exception was originally raised or propagated is indicated by <code>&gt;&gt;</code>, if it differs from the current line.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2: </span>The <code>&gt;&gt;</code> marker.</p> </div> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-ll">
+<code>ll | longlist</code> </dt> <dd>
+<p>List all source code for the current function or frame. Interesting lines are marked as for <a class="reference internal" href="#pdbcommand-list"><code>list</code></a>.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2.</span></p> </div> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-args">
+<code>a(rgs)</code> </dt> <dd>
+<p>Print the arguments of the current function and their current values.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-p">
+<code>p expression</code> </dt> <dd>
+<p>Evaluate <em>expression</em> in the current context and print its value.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p><code>print()</code> can also be used, but is not a debugger command — this executes the Python <a class="reference internal" href="functions#print" title="print"><code>print()</code></a> function.</p> </div> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-pp">
+<code>pp expression</code> </dt> <dd>
+<p>Like the <a class="reference internal" href="#pdbcommand-p"><code>p</code></a> command, except the value of <em>expression</em> is pretty-printed using the <a class="reference internal" href="pprint#module-pprint" title="pprint: Data pretty printer."><code>pprint</code></a> module.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-whatis">
+<code>whatis expression</code> </dt> <dd>
+<p>Print the type of <em>expression</em>.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-source">
+<code>source expression</code> </dt> <dd>
+<p>Try to get source code of <em>expression</em> and display it.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2.</span></p> </div> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-display">
+<code>display [expression]</code> </dt> <dd>
+<p>Display the value of <em>expression</em> if it changed, each time execution stops in the current frame.</p> <p>Without <em>expression</em>, list all display expressions for the current frame.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>Display evaluates <em>expression</em> and compares to the result of the previous evaluation of <em>expression</em>, so when the result is mutable, display may not be able to pick up the changes.</p> </div> <p>Example:</p> <pre data-language="python">lst = []
+breakpoint()
+pass
+lst.append(1)
+print(lst)
+</pre> <p>Display won’t realize <code>lst</code> has been changed because the result of evaluation is modified in place by <code>lst.append(1)</code> before being compared:</p> <pre data-language="python">&gt; example.py(3)&lt;module&gt;()
+-&gt; pass
+(Pdb) display lst
+display lst: []
+(Pdb) n
+&gt; example.py(4)&lt;module&gt;()
+-&gt; lst.append(1)
+(Pdb) n
+&gt; example.py(5)&lt;module&gt;()
+-&gt; print(lst)
+(Pdb)
+</pre> <p>You can do some tricks with copy mechanism to make it work:</p> <pre data-language="python">&gt; example.py(3)&lt;module&gt;()
+-&gt; pass
+(Pdb) display lst[:]
+display lst[:]: []
+(Pdb) n
+&gt; example.py(4)&lt;module&gt;()
+-&gt; lst.append(1)
+(Pdb) n
+&gt; example.py(5)&lt;module&gt;()
+-&gt; print(lst)
+display lst[:]: [1] [old: []]
+(Pdb)
+</pre> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2.</span></p> </div> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-undisplay">
+<code>undisplay [expression]</code> </dt> <dd>
+<p>Do not display <em>expression</em> anymore in the current frame. Without <em>expression</em>, clear all display expressions for the current frame.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2.</span></p> </div> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-interact">
+<code>interact</code> </dt> <dd>
+<p>Start an interactive interpreter (using the <a class="reference internal" href="code#module-code" title="code: Facilities to implement read-eval-print loops."><code>code</code></a> module) whose global namespace contains all the (global and local) names found in the current scope.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2.</span></p> </div> </dd>
+</dl> <span class="target" id="debugger-aliases"></span><dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-alias">
+<code>alias [name [command]]</code> </dt> <dd>
+<p>Create an alias called <em>name</em> that executes <em>command</em>. The <em>command</em> must <em>not</em> be enclosed in quotes. Replaceable parameters can be indicated by <code>%1</code>, <code>%2</code>, and so on, while <code>%*</code> is replaced by all the parameters. If <em>command</em> is omitted, the current alias for <em>name</em> is shown. If no arguments are given, all aliases are listed.</p> <p>Aliases may be nested and can contain anything that can be legally typed at the pdb prompt. Note that internal pdb commands <em>can</em> be overridden by aliases. Such a command is then hidden until the alias is removed. Aliasing is recursively applied to the first word of the command line; all other words in the line are left alone.</p> <p>As an example, here are two useful aliases (especially when placed in the <code>.pdbrc</code> file):</p> <pre data-language="python"># Print instance variables (usage "pi classInst")
+alias pi for k in %1.__dict__.keys(): print(f"%1.{k} = {%1.__dict__[k]}")
+# Print instance variables in self
+alias ps pi self
+</pre> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-unalias">
+<code>unalias name</code> </dt> <dd>
+<p>Delete the specified alias <em>name</em>.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-0">
+<code>! statement</code> </dt> <dd>
+<p>Execute the (one-line) <em>statement</em> 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, e.g.:</p> <pre data-language="none">(Pdb) ! n=42
+(Pdb)
+</pre> <p>To set a global variable, you can prefix the assignment command with a <a class="reference internal" href="../reference/simple_stmts#global"><code>global</code></a> statement on the same line, e.g.:</p> <pre data-language="none">(Pdb) global list_options; list_options = ['-l']
+(Pdb)
+</pre> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-run">
+<code>run [args ...]</code> </dt> <dt class="sig sig-object std" id="pdbcommand-restart">
+<code>restart [args ...]</code> </dt> <dd>
+<p>Restart the debugged Python program. If <em>args</em> is supplied, it is split with <a class="reference internal" href="shlex#module-shlex" title="shlex: Simple lexical analysis for Unix shell-like languages."><code>shlex</code></a> and the result is used as the new <a class="reference internal" href="sys#sys.argv" title="sys.argv"><code>sys.argv</code></a>. History, breakpoints, actions and debugger options are preserved. <a class="reference internal" href="#pdbcommand-restart"><code>restart</code></a> is an alias for <a class="reference internal" href="#pdbcommand-run"><code>run</code></a>.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-quit">
+<code>q(uit)</code> </dt> <dd>
+<p>Quit from the debugger. The program being executed is aborted.</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-debug">
+<code>debug code</code> </dt> <dd>
+<p>Enter a recursive debugger that steps through <em>code</em> (which is an arbitrary expression or statement to be executed in the current environment).</p> </dd>
+</dl> <dl class="std pdbcommand"> <dt class="sig sig-object std" id="pdbcommand-retval">
+<code>retval</code> </dt> <dd>
+<p>Print the return value for the last return of the current function.</p> </dd>
+</dl> <h4 class="rubric">Footnotes</h4> <dl class="footnote brackets"> <dt class="label" id="id3">
+<code>1</code> </dt> <dd>
+<p>Whether a frame is considered to originate in a certain module is determined by the <code>__name__</code> in the frame globals.</p> </dd> </dl> </section> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
+ <a href="https://docs.python.org/3.12/library/pdb.html" class="_attribution-link">https://docs.python.org/3.12/library/pdb.html</a>
+ </p>
+</div>