📄 ch20_02.htm
字号:
<dt><b><tt class="literal">></tt></b></dt><dt><b><tt class="literal">> ?</tt></b></dt><dt><b><tt class="literal">></tt> <em class="replaceable">EXPR</em></b></dt><dt><b><tt class="literal">>></tt> <em class="replaceable">EXPR</em></b></dt><dd><p><a name="INDEX-3562"></a>The <tt class="literal">></tt> commands behave just like their<tt class="literal"><</tt> cousins but are executed after the debuggerprompt instead of before.</p></dd><dt><b><tt class="literal">{</tt></b></dt><dt><b><tt class="literal">{ ?</tt></b></dt><dt><b><tt class="literal">{</tt> <em class="replaceable">COMMAND</em></b></dt><dt><b><tt class="literal">{{</tt> <em class="replaceable">COMMAND</em></b></dt><dd><p><a name="INDEX-3563"></a>The <tt class="literal">{</tt> debugger commands behave just like<tt class="literal"><</tt> but specify a debugger command to be executedbefore the debugger prompt instead of a Perl expression. A warning isissued if you appear to have accidentally entered a block of codeinstead. If that's what you really mean to do, write it with<tt class="literal">;{ ... }</tt> or even <tt class="literal">do { ... }</tt>.</p></dd><dt><b><tt class="literal">!</tt></b></dt><dt><b><tt class="literal">!</tt> <em class="replaceable">NUMBER</em></b></dt><dt><b><tt class="literal">! -</tt><em class="replaceable">NUMBER</em></b></dt><dt><b><tt class="literal">!</tt><em class="replaceable">PATTERN</em></b></dt><dd><p><a name="INDEX-3564"></a>A lone <tt class="literal">!</tt> repeats the previous command. The<em class="replaceable">NUMBER</em> specifies which command from thehistory to execute; for instance, <tt class="literal">! 3</tt> executes thethird command typed into the debugger. If a minus sign precedes the<em class="replaceable">NUMBER</em>, the commands are counted backward:<tt class="literal">! -3</tt> executes the third-to-last command. If a<em class="replaceable">PATTERN</em> (no slashes) is provided instead ofa <em class="replaceable">NUMBER</em>, the last command that began with<em class="replaceable">PATTERN</em> is executed. See also the<tt class="literal">recallCommand</tt> debugger option.)</p></dd><dt><b><tt class="literal">!!</tt> <em class="replaceable">CMD</em></b></dt><dd><p><a name="INDEX-3565"></a><a name="INDEX-3566"></a>This debugger command runs the external command <em class="replaceable">CMD</em> in asubprocess, which will read from <tt class="literal">DB::IN</tt> and write to <tt class="literal">DB::OUT</tt>.See also the <tt class="literal">shellBang</tt> debugger option. This command uses whatevershell is named in <tt class="literal">$ENV{SHELL}</tt>, which can sometimes interfere withproper interpretation of status, signal, and core dump information.If you want a consistent exit value from the command, set<tt class="literal">$ENV{SHELL}</tt> to <tt class="literal">/bin/sh</tt>.</p></dd><dt><b><tt class="literal">|</tt></b></dt><dt><b><tt class="literal">|</tt><em class="replaceable">DBCMD</em></b></dt><dt><b><tt class="literal">||</tt><em class="replaceable">PERLCMD</em></b></dt><dd><p><a name="INDEX-3567"></a><a name="INDEX-3568"></a>The <tt class="literal">|</tt><em class="replaceable">DBCMD</em> command runsthe debugger command <em class="replaceable">DBCMD</em>, piping<tt class="literal">DB::OUT</tt> to <tt class="literal">$ENV{PAGER}</tt>. This isoften used with commands that would otherwise produce long output,such as:<blockquote><pre class="programlisting">DB<1> <b class="emphasis-bold">|V main</b></pre></blockquote>Note that this is for debugger commands, not commands you'd type fromyour shell. If you wanted to pipe the external command<em class="emphasis">who</em> through your pager, you could do somethinglike this:</p><blockquote><pre class="programlisting">DB<1> <b class="emphasis-bold">!!who | more</b></pre></blockquote><p>The <tt class="literal">||</tt><em class="replaceable">PERLCMD</em> command islike <tt class="literal">|</tt><em class="replaceable">DBCMD</em>, but<tt class="literal">DB::OUT</tt> is temporarily <tt class="literal">select</tt>edas well, so any commands that call <tt class="literal">print</tt>,<tt class="literal">printf</tt>, or <tt class="literal">write</tt> without afilehandle will also be sent down the pipe. For example, if you had afunction that generated loads of output by calling<tt class="literal">print</tt>, you'd use this command instead of theprevious one to page through that output:<blockquote><pre class="programlisting">DB<1> <tt class="userinput"><b>sub saywho { print "Users: ", `who` }</b></tt>DB<2> <tt class="userinput"><b>||sawwho()</b></tt></pre></blockquote></p></dd></dl><h3 class="sect2">20.2.7. Miscellaneous Commands</h3><dl><dt><b><tt class="literal">q</tt> and <tt class="literal">^D</tt></b></dt><dd><p><a name="INDEX-3569"></a><a name="INDEX-3570"></a><a name="INDEX-3571"></a>These commands quit the debugger. This is the recommended way toexit, although typing <tt class="literal">exit</tt> twice sometimes works.Set the <tt class="literal">inhibit_exit</tt> option to <tt class="literal">0</tt>if you want to be able to step off the end of the program and remainin the debugger anyway. You may also need to set<tt class="literal">$DB::finished</tt> to <tt class="literal">0</tt> if you wantto step through global destruction.</p></dd><dt><b><tt class="literal">R</tt></b></dt><dd><p><a name="INDEX-3572"></a>Restart the debugger by <tt class="literal">exec</tt>ing a new session. Thedebugger tries to maintain your history across sessions, but someinternal settings and command-line options may be lost. The followingsettings are currently preserved: history, breakpoints, actions,debugger options, and the Perl command-line options<span class="option">-w</span>, <span class="option">-I</span>, and <span class="option">-e</span>.</p></dd><dt><b><tt class="literal">=</tt></b></dt><dt><b><tt class="literal">=</tt> <em class="replaceable">ALIAS</em></b></dt><dt><b><tt class="literal">=</tt> <em class="replaceable">ALIAS</em> <em class="replaceable">VALUE</em></b></dt><dd><p><a name="INDEX-3573"></a><a name="INDEX-3574"></a>This command prints out the current value of <em class="replaceable">ALIAS</em> if no <em class="replaceable">VALUE</em> is given. With a <em class="replaceable">VALUE</em>, it defines a new debugger command with the name <em class="replaceable">ALIAS</em>. If both<em class="replaceable">ALIAS</em> and <em class="replaceable">VALUE</em> are omitted, all current aliases are listed.For example:<blockquote><pre class="programlisting">= quit q</pre></blockquote>An <em class="replaceable">ALIAS</em> should be a simple identifier, and should translate to a simpleidentifier as well. You can do more sophisticated aliasing by addingyour own entries to <tt class="literal">%DB::aliases</tt> directly. See "DebuggerCustomization" later in this chapter.</p></dd><dt><b><tt class="literal">man</tt></b></dt><dt><b><tt class="literal">man</tt> <em class="replaceable">MANPAGE</em></b></dt><dd><p><a name="INDEX-3575"></a><a name="INDEX-3576"></a><a name="INDEX-3577"></a>This command calls your system's default documentation viewer on thegiven page or on the viewer itself if <em class="replaceable">MANPAGE</em> is omitted. If thatviewer is <em class="emphasis">man</em>, the current <tt class="literal">%Config</tt> information is used to invokeit. The "<tt class="literal">perl</tt>" prefix will be automatically supplied for you whennecessary; this lets you type <tt class="literal">man debug</tt> and <tt class="literal">man op</tt> from thedebugger.</p><p><a name="INDEX-3578"></a>On systems that do not normally have the <em class="emphasis">man</em> utility, the debuggerinvokes <em class="emphasis">perldoc</em>; if you want to change that behavior, set<tt class="literal">$DB::doccmd</tt> to whatever viewer you like. This may be set in an <em class="emphasis">rc</em>file or through direct assignment.</p></dd><dt><b><tt class="literal">O</tt></b></dt><dt><b><tt class="literal">O</tt> <em class="replaceable">OPTION</em><tt class="literal"> ...</tt></b></dt><dt><b><tt class="literal">O</tt> <em class="replaceable">OPTION</em><tt class="literal">? ...</tt></b></dt><dt><b><tt class="literal">O</tt> <em class="replaceable">OPTION</em>=<em class="replaceable">VALUE</em><tt class="literal">...</tt></b></dt><dd><p><a name="INDEX-3579"></a>The <tt class="literal">O</tt> command lets you manipulate debugger options, which arelisted in <a href="ch20_03.htm#ch20-sect-do">Section 20.3.3, "Debugger Options"</a> later in this chapter. The <tt class="literal">O</tt><em class="replaceable">OPTION</em> form sets eachof the listed debugger options to <tt class="literal">1</tt>. If a question mark followsan <em class="replaceable">OPTION</em>, its current value is displayed.</p><p>The <tt class="literal">O</tt><em class="replaceable">OPTION</em>=<em class="replaceable">VALUE</em> form sets the values; if <em class="replaceable">VALUE</em> hasinternal whitespace, it should be quoted. For example, you could set<tt class="literal">O pager="less -MQeicsNfr" </tt> to use <em class="emphasis">less</em> with those specific flags.You may use either single or double quotes, but if you do, you mustescape embedded instances of the same sort of quote that you began with.You must also escape any backslash that immediately precedes the quotebut is not meant to escape the quote itself. In other words,just follow single-quoting rules irrespective of the quote actuallyused. The debugger responds by showing you the value of the optionjust set, always using single-quoted notation for its output:<blockquote><pre class="programlisting">DB<1> <tt class="userinput"><b>O</b></tt> <em class="replaceable">OPTION</em><tt class="userinput"><b>='this isn\'t bad'</b></tt> <em class="replaceable">OPTION</em> = 'this isn\'t bad'DB<2> <b class="emphasis-bold">O</b> <em class="replaceable">OPTION</em><tt class="userinput"><b>="She said, \" Isn't it?\""</b></tt> <em class="replaceable">OPTION</em> = 'She said, "Isn\'t it?"'</pre></blockquote>For historical reasons, the <tt class="literal">=</tt><em class="replaceable">VALUE</em> is optional, but defaultsto <tt class="literal">1</tt> only where safe to do so--that is, mostly for Booleanoptions. It is better to assign a specific <em class="replaceable">VALUE</em> using <tt class="literal">=</tt>.The <em class="replaceable">OPTION</em> can be abbreviated, but unless you're trying to beintentionally cryptic, it probably should not be. Several options canbe set together. See the section <a href="ch20_03.htm#ch20-sect-do">Section 20.3.3, "Debugger Options"</a> for a listof these.</p></dd></dl><a name="INDEX-3580"></a><a name="INDEX-3581"></a><!-- BOTTOM NAV BAR --><hr width="515" align="left"><div class="navbar"><table width="515" border="0"><tr><td align="left" valign="top" width="172"><a href="ch20_01.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0"></a></td><td align="center" valign="top" width="171"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0"></a></td><td align="right" valign="top" width="172"><a href="ch20_03.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0"></a></td></tr><tr><td align="left" valign="top" width="172">20.1. Using the Debugger</td><td align="center" valign="top" width="171"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0"></a></td><td align="right" valign="top" width="172">20.3. Debugger Customization</td></tr></table></div><hr width="515" align="left"><!-- LIBRARY NAV BAR --><img src="../gifs/smnavbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links"><p><font size="-1"><a href="copyrght.htm">Copyright © 2001</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"> <area shape="rect" coords="2,-1,79,99" href="../index.htm"><area shape="rect" coords="84,1,157,108" href="../perlnut/index.htm"><area shape="rect" coords="162,2,248,125" href="../prog/index.htm"><area shape="rect" coords="253,2,326,130" href="../advprog/index.htm"><area shape="rect" coords="332,1,407,112" href="../cookbook/index.htm"><area shape="rect" coords="414,2,523,103" href="../sysadmin/index.htm"></map><!-- END OF BODY --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -