📄 ch08_51.htm
字号:
<html><head><title>DB (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 & 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="ch08_50.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="ch08_52.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">8.51. DB</h2><p><a name="INDEX-1350" />The DB moduleabstracts and provides all of the hooks into Perl internal debuggingfunctionality, so that various implementations of Perl debuggers (orpackages that want simply to get at the"privileged" debugging data) canall benefit from the development of this common code. The following"public" global names can be readby clients of this API, but should be considered read-only:</p><dl><dt><b><tt class="literal">$DB_HASH</tt></b></dt><dd>Stores key/data pairs in data files; equivalent to other hashingpackages such as DBM, NDBM, ODBM, GDBM, and SDBM.</p></dd><dt><b><tt class="literal">$DB::sub</tt></b></dt><dd>Name of current executing subroutine.</p></dd><dt><b><tt class="literal">%DB::sub</tt></b></dt><dd>The keys of this hash are the names of all the known subroutines.Each value is an encoded string that has the<tt class="literal">sprintf</tt> format <tt class="literal">("%s:%d-%d",filename,</tt> <tt class="literal">fromline, toline)</tt>.</p></dd><dt><b><tt class="literal">$DB::single</tt></b></dt><dd>Single-step flag. Will be true if the API will stop at the nextstatement.</p></dd><dt><b><tt class="literal">$DB::signal</tt></b></dt><dd>Signal flag. Will be true if a signal was caught.</p></dd><dt><b><tt class="literal">$DB::trace</tt></b></dt><dd>This flag is set to true if the API is tracing through subroutinecalls.</p></dd><dt><b><tt class="literal">@DB::args</tt></b></dt><dd>Contains the arguments of current subroutine, or the<tt class="literal">@ARGV</tt> array if in the toplevel context.</p></dd><dt><b><tt class="literal">@DB::dbline</tt></b></dt><dd>List of lines in currently loaded file.</p></dd><dt><b><tt class="literal">%DB::dbline</tt></b></dt><dd>Actions in current file (keys are line numbers). The values arestrings that have the <tt class="literal">sprintf</tt> format<tt class="literal">("%s\000%s", breakcondition, actioncode)</tt>.</p></dd><dt><b><tt class="literal">$DB::package</tt></b></dt><dd>Package namespace of currently executing code.</p></dd><dt><b><tt class="literal">$DB::filename</tt></b></dt><dd>Currently loaded filename.</p></dd><dt><b><tt class="literal">$DB::subname</tt></b></dt><dd>Fully qualified name of currently executing subroutine.</p></dd><dt><b><tt class="literal">$DB::lineno</tt></b></dt><dd>Line number that will be executed next.</p></dd></dl><a name="perlnut2-CHP-8-SECT-51.1" /><div class="sect2"><h3 class="sect2">8.51.1. API Methods</h3><p>The following are methods in the DB base class. A client must accessthese methods by inheritance, since the API keeps track of clientsthrough the inheritance mechanism.</p><dl><dt><b><tt class="literal">CLIENT->register( )</tt></b></dt><dd>Registers a client object/package</p></dd><dt><b><tt class="literal">CLIENT->evalcode(</tt><em class="replaceable">STRING</em><tt class="literal">)</tt></b></dt><dd><tt class="literal">eval</tt> s <em class="replaceable"><tt>STRING</tt></em> inexecuting code context</p></dd><dt><b><tt class="literal">CLIENT->skippkg('</tt><em class="replaceable">Skip::Me</em><tt class="literal">')</tt></b></dt><dd>Asks DB not to stop in these packages</p></dd><dt><b><tt class="literal">CLIENT->run( )</tt></b></dt><dd>Runs some more (until a breakpt is reached)</p></dd><dt><b><tt class="literal">CLIENT->step( )</tt></b></dt><dd>Single step</p></dd><dt><b><tt class="literal">CLIENT->next( )</tt></b></dt><dd>Steps over</p></dd><dt><b><tt class="literal">CLIENT->done( )</tt></b></dt><dd>Deregisters from the debugging API</p></dd></dl></div><a name="perlnut2-CHP-8-SECT-51.2" /><div class="sect2"><h3 class="sect2">8.51.2. Client Callback Methods</h3><p>The following "virtual" methods arecalled by the API at appropriate points. The API provides only emptyversions of these methods by default, but they can be defined by theclient as needed.</p><dl><dt><b><tt class="literal">CLIENT->init( )</tt></b></dt><dd>Called after debug API initializes itself.</p></dd><dt><b><tt class="literal">CLIENT->prestop([</tt><em class="replaceable">STRING</em><tt class="literal">])</tt></b></dt><dd>Usually inherited from DB package. If no arguments are passed,returns the prestop action string.</p></dd><dt><b><tt class="literal">CLIENT->stop( )</tt></b></dt><dd>Called when execution stops, with the filename and line number asarguments.</p></dd><dt><b><tt class="literal">CLIENT->idle( )</tt></b></dt><dd>Called while stopped, e.g., in a client event loop.</p></dd><dt><b><tt class="literal">CLIENT->poststop([</tt><em class="replaceable">STRING</em><tt class="literal">])</tt></b></dt><dd>Usually inherited from DB package. If no arguments are passed,returns the poststop action string.</p></dd><dt><b><tt class="literal">CLIENT->evalcode(</tt><em class="replaceable">STRING</em><tt class="literal">)</tt></b></dt><dd>Usually inherited from DB package. Asks for a<em class="replaceable"><tt>STRING</tt></em> to be <tt class="literal">eval</tt> ed inexecuting code context.</p></dd><dt><b><tt class="literal">CLIENT->cleanup( )</tt></b></dt><dd>Called just before exit.</p></dd><dt><b><tt class="literal">CLIENT->output(</tt><em class="replaceable">LIST</em><tt class="literal">)</tt></b></dt><dd>Called when API must show a message (warnings, errors etc.).</p></dd></dl></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch08_50.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch08_52.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">8.50. Data::Dumper</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">8.52. DB_File</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2002</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -