perldebug.html
来自「perl教程」· HTML 代码 · 共 1,321 行 · 第 1/4 页
HTML
1,321 行
may be lost.</p>
</dd>
<dd>
<p>The following setting are currently preserved: history, breakpoints,
actions, debugger options, and the Perl command-line
options <strong>-w</strong>, <strong>-I</strong>, and <strong>-e</strong>.</p>
</dd>
</li>
<dt><strong><a name="item__7cdbcmd">|dbcmd</a></strong>
<dd>
<p>Run the debugger command, piping DB::OUT into your current pager.</p>
</dd>
</li>
<dt><strong><a name="item__7c_7cdbcmd">||dbcmd</a></strong>
<dd>
<p>Same as <a href="#item__7cdbcmd"><code>|dbcmd</code></a> but DB::OUT is temporarily <a href="../../lib/Pod/perlfunc.html#item_select"><code>select</code></a>ed as well.</p>
</dd>
</li>
<dt><strong><a name="item__3d__5balias_value_5d">= [alias value]</a></strong>
<dd>
<p>Define a command alias, like</p>
</dd>
<dd>
<pre>
= quit q</pre>
</dd>
<dd>
<p>or list current aliases.</p>
</dd>
</li>
<dt><strong><a name="item_command">command</a></strong>
<dd>
<p>Execute command as a Perl statement. A trailing semicolon will be
supplied. If the Perl statement would otherwise be confused for a
Perl debugger, use a leading semicolon, too.</p>
</dd>
</li>
<dt><strong><a name="item_m_expr">m expr</a></strong>
<dd>
<p>List which methods may be called on the result of the evaluated
expression. The expression may evaluated to a reference to a
blessed object, or to a package name.</p>
</dd>
</li>
<dt><strong><a name="item_m">M</a></strong>
<dd>
<p>Displays all loaded modules and their versions</p>
</dd>
</li>
<dt><strong><a name="item_man__5bmanpage_5d">man [manpage]</a></strong>
<dd>
<p>Despite its name, this calls your system's default documentation
viewer on the given page, or on the viewer itself if <em>manpage</em> is
omitted. If that viewer is <strong>man</strong>, the current <code>Config</code> information
is used to invoke <strong>man</strong> using the proper MANPATH or <strong>-M</strong>
<em>manpath</em> option. Failed lookups of the form <code>XXX</code> that match
known manpages of the form <em>perlXXX</em> will be retried. This lets
you type <code>man debug</code> or <code>man op</code> from the debugger.</p>
</dd>
<dd>
<p>On systems traditionally bereft of a usable <strong>man</strong> command, the
debugger invokes <strong>perldoc</strong>. Occasionally this determination is
incorrect due to recalcitrant vendors or rather more felicitously,
to enterprising users. If you fall into either category, just
manually set the $DB::doccmd variable to whatever viewer to view
the Perl documentation on your system. This may be set in an rc
file, or through direct assignment. We're still waiting for a
working example of something along the lines of:</p>
</dd>
<dd>
<pre>
<span class="variable">$DB::doccmd</span> <span class="operator">=</span> <span class="string">'netscape -remote http://something.here/'</span><span class="operator">;</span>
</pre>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="configurable_options">Configurable Options</a></h2>
<p>The debugger has numerous options settable using the <a href="#item_o"><code>o</code></a> command,
either interactively or from the environment or an rc file.
(./.perldb or ~/.perldb under Unix.)</p>
<dl>
<dt><strong><a name="item_recallcommand_2c_shellbang"><code>recallCommand</code>, <code>ShellBang</code></a></strong>
<dd>
<p>The characters used to recall command or spawn shell. By
default, both are set to <code>!</code>, which is unfortunate.</p>
</dd>
</li>
<dt><strong><a name="item_pager"><code>pager</code></a></strong>
<dd>
<p>Program to use for output of pager-piped commands (those beginning
with a <code>|</code> character.) By default, <code>$ENV{PAGER}</code> will be used.
Because the debugger uses your current terminal characteristics
for bold and underlining, if the chosen pager does not pass escape
sequences through unchanged, the output of some debugger commands
will not be readable when sent through the pager.</p>
</dd>
</li>
<dt><strong><a name="item_tkrunning"><code>tkRunning</code></a></strong>
<dd>
<p>Run Tk while prompting (with ReadLine).</p>
</dd>
</li>
<dt><strong><a name="item_signallevel_2c_warnlevel_2c_dielevel"><code>signalLevel</code>, <code>warnLevel</code>, <code>dieLevel</code></a></strong>
<dd>
<p>Level of verbosity. By default, the debugger leaves your exceptions
and warnings alone, because altering them can break correctly running
programs. It will attempt to print a message when uncaught INT, BUS, or
SEGV signals arrive. (But see the mention of signals in <em>BUGS</em> below.)</p>
</dd>
<dd>
<p>To disable this default safe mode, set these values to something higher
than 0. At a level of 1, you get backtraces upon receiving any kind
of warning (this is often annoying) or exception (this is
often valuable). Unfortunately, the debugger cannot discern fatal
exceptions from non-fatal ones. If <code>dieLevel</code> is even 1, then your
non-fatal exceptions are also traced and unceremoniously altered if they
came from <code>eval'd</code> strings or from any kind of <a href="../../lib/Pod/perlfunc.html#item_eval"><code>eval</code></a> within modules
you're attempting to load. If <code>dieLevel</code> is 2, the debugger doesn't
care where they came from: It usurps your exception handler and prints
out a trace, then modifies all exceptions with its own embellishments.
This may perhaps be useful for some tracing purposes, but tends to hopelessly
destroy any program that takes its exception handling seriously.</p>
</dd>
</li>
<dt><strong><a name="item_autotrace"><code>AutoTrace</code></a></strong>
<dd>
<p>Trace mode (similar to <a href="#item_t"><code>t</code></a> command, but can be put into
<code>PERLDB_OPTS</code>).</p>
</dd>
</li>
<dt><strong><a name="item_lineinfo"><code>LineInfo</code></a></strong>
<dd>
<p>File or pipe to print line number info to. If it is a pipe (say,
<code>|visual_perl_db</code>), then a short message is used. This is the
mechanism used to interact with a slave editor or visual debugger,
such as the special <code>vi</code> or <code>emacs</code> hooks, or the <code>ddd</code> graphical
debugger.</p>
</dd>
</li>
<dt><strong><a name="item_inhibit_exit"><code>inhibit_exit</code></a></strong>
<dd>
<p>If 0, allows <em>stepping off</em> the end of the script.</p>
</dd>
</li>
<dt><strong><a name="item_printret"><code>PrintRet</code></a></strong>
<dd>
<p>Print return value after <a href="#item_r"><code>r</code></a> command if set (default).</p>
</dd>
</li>
<dt><strong><a name="item_ornaments"><code>ornaments</code></a></strong>
<dd>
<p>Affects screen appearance of the command line (see <a href="../../lib/Term/ReadLine.html">the Term::ReadLine manpage</a>).
There is currently no way to disable these, which can render
some output illegible on some displays, or with some pagers.
This is considered a bug.</p>
</dd>
</li>
<dt><strong><a name="item_frame"><code>frame</code></a></strong>
<dd>
<p>Affects the printing of messages upon entry and exit from subroutines. If
<a href="#item_frame"><code>frame & 2</code></a> is false, messages are printed on entry only. (Printing
on exit might be useful if interspersed with other messages.)</p>
</dd>
<dd>
<p>If <a href="#item_frame"><code>frame & 4</code></a>, arguments to functions are printed, plus context
and caller info. If <a href="#item_frame"><code>frame & 8</code></a>, overloaded <code>stringify</code> and
<a href="../../lib/Pod/perlfunc.html#item_tie"><code>tie</code></a>d <code>FETCH</code> is enabled on the printed arguments. If <a href="#item_frame"><code>frame
& 16</code></a>, the return value from the subroutine is printed.</p>
</dd>
<dd>
<p>The length at which the argument list is truncated is governed by the
next option:</p>
</dd>
</li>
<dt><strong><a name="item_maxtracelen"><code>maxTraceLen</code></a></strong>
<dd>
<p>Length to truncate the argument list when the <a href="#item_frame"><code>frame</code></a> option's
bit 4 is set.</p>
</dd>
</li>
<dt><strong><a name="item_windowsize"><code>windowSize</code></a></strong>
<dd>
<p>Change the size of code list window (default is 10 lines).</p>
</dd>
</li>
</dl>
<p>The following options affect what happens with <code>V</code>, <a href="../../lib/Pod/perlguts.html#item_x"><code>X</code></a>, and <a href="../../lib/Pod/perlguts.html#item_x"><code>x</code></a>
commands:</p>
<dl>
<dt><strong><a name="item_arraydepth_2c_hashdepth"><code>arrayDepth</code>, <code>hashDepth</code></a></strong>
<dd>
<p>Print only first N elements ('' for all).</p>
</dd>
</li>
<dt><strong><a name="item_dumpdepth"><code>dumpDepth</code></a></strong>
<dd>
<p>Limit recursion depth to N levels when dumping structures.
Negative values are interpreted as infinity. Default: infinity.</p>
</dd>
</li>
<dt><strong><a name="item_compactdump_2c_verycompact"><code>compactDump</code>, <code>veryCompact</code></a></strong>
<dd>
<p>Change the style of array and hash output. If <code>compactDump</code>, short array
may be printed on one line.</p>
</dd>
</li>
<dt><strong><a name="item_globprint"><code>globPrint</code></a></strong>
<dd>
<p>Whether to print contents of globs.</p>
</dd>
</li>
<dt><strong><a name="item_dumpdbfiles"><code>DumpDBFiles</code></a></strong>
<dd>
<p>Dump arrays holding debugged files.</p>
</dd>
</li>
<dt><strong><a name="item_dumppackages"><code>DumpPackages</code></a></strong>
<dd>
<p>Dump symbol tables of packages.</p>
</dd>
</li>
<dt><strong><a name="item_dumpreused"><code>DumpReused</code></a></strong>
<dd>
<p>Dump contents of "reused" addresses.</p>
</dd>
</li>
<dt><strong><a name="item_quote_2c_highbit_2c_undefprint"><code>quote</code>, <code>HighBit</code>, <code>undefPrint</code></a></strong>
<dd>
<p>Change the style of string dump. The default value for <code>quote</code>
is <code>auto</code>; one can enable double-quotish or single-quotish format
by setting it to <code>"</code> or <code>'</code>, respectively. By default, characters
with their high bit set are printed verbatim.</p>
</dd>
</li>
<dt><strong><a name="item_usageonly"><code>UsageOnly</code></a></strong>
<dd>
<p>Rudimentary per-package memory usage dump. Calculates total
size of strings found in variables in the package. This does not
include lexicals in a module's file scope, or lost in closures.</p>
</dd>
</li>
</dl>
<p>After the rc file is read, the debugger reads the <code>$ENV{PERLDB_OPTS}</code>
environment variable and parses this as the remainder of a "O ..."
line as one might enter at the debugger prompt. You may place the
initialization options <a href="#item_tty"><code>TTY</code></a>, <a href="#item_notty"><code>noTTY</code></a>, <a href="#item_readline"><code>ReadLine</code></a>, and <a href="#item_nonstop"><code>NonStop</code></a>
there.</p>
<p>If your rc file contains:</p>
<pre>
<span class="variable">parse_options</span><span class="operator">(</span><span class="string">"NonStop=1 LineInfo=db.out AutoTrace"</span><span class="operator">);</span>
</pre>
<p>then your script will run without human intervention, putting trace
information into the file <em>db.out</em>. (If you interrupt it, you'd
better reset <a href="#item_lineinfo"><code>LineInfo</code></a> to <em>/dev/tty</em> if you expect to see anything.)</p>
<dl>
<dt><strong><a name="item_tty"><code>TTY</code></a></strong>
<dd>
<p>The TTY to use for debugging I/O.</p>
</dd>
</li>
<dt><strong><a name="item_notty"><code>noTTY</code></a></strong>
<dd>
<p>If set, the debugger goes into <a href="#item_nonstop"><code>NonStop</code></a> mode and will not connect to a TTY. If
interrupted (or if control goes to the debugger via explicit setting of
$DB::signal or $DB::single from the Perl script), it connects to a TTY
specified in the <a href="#item_tty"><code>TTY</code></a> option at startup, or to a tty found at
runtime using the <code>Term::Rendezvous</code> module of your choice.</p>
</dd>
<dd>
<p>This module should implement a method named <code>new</code> that returns an object
with two methods: <code>IN</code> and <code>OUT</code>. These should return filehandles to use
for debugging input and output correspondingly. The <code>new</code> method should
inspect an argument containing the value of <code>$ENV{PERLDB_NOTTY}</code> at
startup, or <code>"$ENV{HOME}/.perldbtty$$"</code> otherwise. This file is not
inspected for proper ownership, so security hazards are theoretically
possible.</p>
</dd>
</li>
<dt><strong><a name="item_readline"><code>ReadLine</code></a></strong>
<dd>
<p>If false, readline support in the debugger is disabled in order
to debug applications that themselves use ReadLine.</p>
</dd>
</li>
<dt><strong><a name="item_nonstop"><code>NonStop</code></a></strong>
<dd>
<p>If set, the debugger goes into non-interactive mode until interrupted, or
programmatically by setting $DB::signal or $DB::single.</p>
</dd>
</li>
</dl>
<p>Here's an example of using the <code>$ENV{PERLDB_OPTS}</code> variable:</p>
<pre>
$ PERLDB_OPTS="NonStop frame=2" perl -d myprogram</pre>
<p>That will run the script <strong>myprogram</strong> without human intervention,
printing out the call tree with entry and exit points. Note that
<code>NonStop=1 frame=2</code> is equivalent to <code>N f=2</code>, and that originally,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?