⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch06_02.htm

📁 by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<html><head><title>Debugger Commands (Perl in a Nutshell, 2nd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Stephen Spainhour" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly &amp; Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596002416L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Perl in a Nutshell, 2nd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Java and XSLT" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch06_01.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch06_03.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">6.2. Debugger Commands</h2><p><a name="INDEX-1113" /><a name="INDEX-1114" /><a name="INDEX-1115" />Thedebugger understands the following commands.</p><a name="INDEX-1116" /><a name="INDEX-1117" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>-</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre><tt class="literal">-</tt></pre><p><a name="INDEX-1116" /><a name="INDEX-1117" />Lists the previous few lines.</p></div><a name="INDEX-1118" /><a name="INDEX-1119" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>.</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>.</pre><p><a name="INDEX-1118" /><a name="INDEX-1119" />Returns debugger pointer to thelast-executed line and prints it out.</p></div><a name="INDEX-1120" /><a name="INDEX-1121" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>/pattern/</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>/<em class="replaceable">pattern</em>/</pre><p><a name="INDEX-1120" /><a name="INDEX-1121" />Searches forward for<em class="replaceable"><tt>pattern</tt></em>; final <tt class="literal">/</tt> isoptional.</p></div><a name="INDEX-1122" /><a name="INDEX-1123" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>?pattern?</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>?<em class="replaceable">pattern</em>?</pre><p><a name="INDEX-1122" /><a name="INDEX-1123" />Searchesbackward for <em class="replaceable"><tt>pattern</tt></em>; final<tt class="literal">?</tt> is optional.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>&lt;</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>&lt; [<em class="emphasis">command</em>]</pre><p>Sets a Perl command to run before every debugger prompt. A multiline<em class="replaceable"><tt>command</tt></em> may be entered by backslashing thenewlines. With no <em class="replaceable"><tt>command</tt></em>, the list ofactions is reset.</p></div><a name="INDEX-1124" /><a name="INDEX-1125" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>&lt;&lt;</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><table width="515" border="0" cellpadding="5"><tr><td align="left"><pre><a name="INDEX-1124" /><a name="INDEX-1125" />&lt;&lt; [<em class="emphasis">command</em>]</pre></td><td align="right" /></tr></table><p><p>Adds to the list of Perl commands to run before each debugger prompt.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>&lt;CR&gt;</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>&lt;CR&gt;</pre><p>Repeats last <tt class="literal">n</tt> or <tt class="literal">s</tt> command.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>&gt;</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>&gt; [<em class="emphasis">command</em>]</pre><p>Sets a Perl command to run after the prompt whenyou've just given a command to return to executingthe script. A multiline <em class="replaceable"><tt>command</tt></em> may beentered by backslashing the newlines.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>&gt;&gt;</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>&gt;&gt; [<em class="emphasis">command</em>]</pre><p>Adds to the list of Perl commands to run after each debugger prompt.</p></div><a name="INDEX-1126" /><a name="INDEX-1127" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>{</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>{ [<em class="emphasis">commandline</em>]</pre><p><a name="INDEX-1126" /><a name="INDEX-1127" />Sets adebugger command to run before each prompt.</p></div><a name="INDEX-1128" /><a name="INDEX-1129" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>{{</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>{{ [<em class="emphasis">commandline</em>]</pre><p><a name="INDEX-1128" /><a name="INDEX-1129" />Adds to the list of debugger commandsto run before each prompt.</p></div><a name="INDEX-1130" /><a name="INDEX-1131" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>!</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>! [<em class="emphasis">number</em>]</pre><p><a name="INDEX-1130" /><a name="INDEX-1131" />Reruns a previous command (defaults tothe last command executed).</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>!</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>! -<em class="emphasis">number</em></pre><p> Reruns <em class="replaceable">number</em>th-to-last command.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>!</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>! <em class="emphasis">pattern</em></pre><p>Reruns last command that started with<em class="replaceable"><tt>pattern</tt></em>. See <tt class="literal">OrecallCommand</tt>.</p></div><a name="INDEX-1132" /><a name="INDEX-1133" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>!!</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>!! <em class="emphasis">cmd</em></pre><p><a name="INDEX-1132" /><a name="INDEX-1133" />Runs <em class="replaceable">cmd</em> ina subprocess (which reads from DB::IN and writes to DB::OUT). See<tt class="literal">O</tt> <tt class="literal">shellBang</tt>.</p></div><a name="INDEX-1134" /><a name="INDEX-1135" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>|</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>| <em class="emphasis">dbcmd</em></pre><p><a name="INDEX-1134" /><a name="INDEX-1135" />Runs specified debugger command,piping DB::OUT to <tt class="literal">$ENV{PAGER}</tt>.</p></div><a name="INDEX-1136" /><a name="INDEX-1137" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>||</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>|| <em class="emphasis">dbcmd</em></pre><p><a name="INDEX-1136" /><a name="INDEX-1137" />Same as<tt class="literal">|</tt><em class="replaceable"><tt>dbcmd</tt></em>, but DB::OUT istemporarily <tt class="literal">select</tt> ed as well. Often used withcommands that would otherwise produce long output, such as:</p><blockquote><pre class="code">|V main</pre></blockquote></div><a name="INDEX-1138" /><a name="INDEX-1139" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>=</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>= [<em class="emphasis">alias value</em>]</pre><p><a name="INDEX-1138" /><a name="INDEX-1139" />Defines a command alias. If<em class="replaceable"><tt>alias</em> and <em class="replaceable">value</tt></em>are omitted, lists all current aliases.</p></div><a name="INDEX-1140" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>A</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>A</pre><p><a name="INDEX-1140" />Deletes all installed actions.</p></div><a name="INDEX-1141" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>a</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>a [<em class="emphasis">line</em>] <em class="emphasis">command</em></pre><p><a name="INDEX-1141" />Sets an action to be done before the<em class="replaceable"><tt>line</tt></em> is executed. The following steps aretaken:</p><ul><li><p>Checks for a breakpoint at this line</p></li><li><p>Prints the line if necessary</p></li><li><p>Performs any actions associated with the line</p></li><li><p>Prompts the user if at a breakpoint or in single-step mode</p></li><li><p>Evaluates the line</p></li></ul><p>For example, the following prints the value of<tt class="literal">$foo</tt> (and <tt class="literal">DB FOUND</tt>) every timeline 53 is passed:</p><blockquote><pre class="code">a 53 print "DB FOUND $foo\n"</pre></blockquote></div><a name="INDEX-1142" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>b</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>b [<em class="emphasis">line</em>] [<em class="emphasis">condition</em>]</pre><p><a name="INDEX-1142" />Sets a breakpoint at<em class="replaceable"><tt>line</tt></em>, which must begin an executablestatement. If <em class="replaceable"><tt>line</tt></em> is omitted, sets abreakpoint on the line that is about to be executed.<em class="replaceable"><tt>condition</tt></em>, if given, is evaluated eachtime the statement is reached, and a breakpoint is taken if<em class="replaceable"><tt>condition</tt></em> is true:</p><blockquote><pre class="code">b 237 $x &gt; 30b 33 /pattern/i</pre></blockquote></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>b</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>b <em class="emphasis">subname</em> [<em class="emphasis">condition</em>]</pre><p>Sets a (possibly conditional) breakpoint at the first line of thenamed subroutine.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>b</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>b load <em class="emphasis">filename</em></pre><p>Sets a breakpoint on <tt class="literal">require</tt>ing the given file.</p></div><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>b</b</font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>b postpone <em class="emphasis">subname</em> [<em class="emphasis">condition</em>]</pre><p>Sets a (possibly conditional) breakpoint at the first line ofsubroutine <em class="replaceable"><tt>subname</tt></em> after it has beencompiled.</p></div>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -