- Timestamp:
- Mar 1, 2010, 3:05:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/docs/htmldocs/Samba3-Developers-Guide/debug.html
r368 r411 1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 4. The samba DEBUG system</title><link rel="stylesheet" href="../samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.7 5.2"><link rel="home" href="index.html" title="SAMBA Developers Guide"><link rel="up" href="pt02.html" title="Part II. Samba Basics"><link rel="prev" href="architecture.html" title="Chapter 3. Samba Architecture"><link rel="next" href="internals.html" title="Chapter 5. Samba Internals"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. The samba DEBUG system</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="architecture.html">Prev</a> </td><th width="60%" align="center">Part II. Samba Basics</th><td width="20%" align="right"> <a accesskey="n" href="internals.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter 4. The samba DEBUG system"><div class="titlepage"><div><div><h2 class="title"><a name="debug"></a>Chapter 4. The samba DEBUG system</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Chris</span> <span class="surname">Hertel</span></h3></div></div><div><p class="pubdate">July 1998</p></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="debug.html#id2563001">New Output Syntax</a></span></dt><dt><span class="sect1"><a href="debug.html#id2563111">The DEBUG() Macro</a></span></dt><dt><span class="sect1"><a href="debug.html#id2563216">The DEBUGADD() Macro</a></span></dt><dt><span class="sect1"><a href="debug.html#id2563252">The DEBUGLVL() Macro</a></span></dt><dt><span class="sect1"><a href="debug.html#id2563343">New Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="debug.html#id2563348">dbgtext()</a></span></dt><dt><span class="sect2"><a href="debug.html#id2563364">dbghdr()</a></span></dt><dt><span class="sect2"><a href="debug.html#id2563383">format_debug_text()</a></span></dt></dl></dd></dl></div><div class="sect1" title="New Output Syntax"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2563001"></a>New Output Syntax</h2></div></div></div><p>1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 4. The samba DEBUG system</title><link rel="stylesheet" href="../samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><link rel="home" href="index.html" title="SAMBA Developers Guide"><link rel="up" href="pt02.html" title="Part II. Samba Basics"><link rel="prev" href="architecture.html" title="Chapter 3. Samba Architecture"><link rel="next" href="internals.html" title="Chapter 5. Samba Internals"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. The samba DEBUG system</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="architecture.html">Prev</a> </td><th width="60%" align="center">Part II. Samba Basics</th><td width="20%" align="right"> <a accesskey="n" href="internals.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="debug"></a>Chapter 4. The samba DEBUG system</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Chris</span> <span class="surname">Hertel</span></h3></div></div><div><p class="pubdate">July 1998</p></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="debug.html#id2556929">New Output Syntax</a></span></dt><dt><span class="sect1"><a href="debug.html#id2557038">The DEBUG() Macro</a></span></dt><dt><span class="sect1"><a href="debug.html#id2557144">The DEBUGADD() Macro</a></span></dt><dt><span class="sect1"><a href="debug.html#id2557180">The DEBUGLVL() Macro</a></span></dt><dt><span class="sect1"><a href="debug.html#id2557271">New Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="debug.html#id2557276">dbgtext()</a></span></dt><dt><span class="sect2"><a href="debug.html#id2557292">dbghdr()</a></span></dt><dt><span class="sect2"><a href="debug.html#id2557311">format_debug_text()</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2556929"></a>New Output Syntax</h2></div></div></div><p> 2 2 The syntax of a debugging log file is represented as: 3 3 </p><pre class="programlisting"> … … 26 26 LINE is the line number of the debug statement that generated the 27 27 message. 28 </p><p>Basically, what that all means is:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>28 </p><p>Basically, what that all means is:</p><div class="orderedlist"><ol type="1"><li><p> 29 29 A debugging log file is made up of debug messages. 30 </p></li><li class="listitem"><p>30 </p></li><li><p> 31 31 Each debug message is made up of a header and text. The header is 32 32 separated from the text by a newline. 33 </p></li><li class="listitem"><p>33 </p></li><li><p> 34 34 The header begins with the timestamp and debug level of the 35 35 message enclosed in brackets. The filename, function, and line … … 39 39 compiler, the function name may be missing (it is generated by the 40 40 __FUNCTION__ macro, which is not universally implemented, dangit). 41 </p></li><li class="listitem"><p>41 </p></li><li><p> 42 42 The message text is made up of zero or more lines, each terminated 43 43 by a newline. … … 52 52 the header line. That's because the example above was generated on an 53 53 SGI Indy, and the SGI compiler doesn't support the __FUNCTION__ macro. 54 </p></div><div class="sect1" title="The DEBUG() Macro"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2563111"></a>The DEBUG() Macro</h2></div></div></div><p>54 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2557038"></a>The DEBUG() Macro</h2></div></div></div><p> 55 55 Use of the DEBUG() macro is unchanged. DEBUG() takes two parameters. 56 56 The first is the message level, the second is the body of a function … … 103 103 . 104 104 </pre><p>Which isn't much use. The format buffer kludge fixes this problem. 105 </p></div><div class="sect1" title="The DEBUGADD() Macro"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2563216"></a>The DEBUGADD() Macro</h2></div></div></div><p>105 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2557144"></a>The DEBUGADD() Macro</h2></div></div></div><p> 106 106 In addition to the kludgey solution to the broken line problem 107 107 described above, there is a clean solution. The DEBUGADD() macro never … … 117 117 This is the second line. 118 118 This is the third line. 119 </pre></div><div class="sect1" title="The DEBUGLVL() Macro"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2563252"></a>The DEBUGLVL() Macro</h2></div></div></div><p>119 </pre></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2557180"></a>The DEBUGLVL() Macro</h2></div></div></div><p> 120 120 One of the problems with the DEBUG() macro was that DEBUG() lines 121 121 tended to get a bit long. Consider this example from … … 144 144 dbgtext( "for workgroup %s\n", work->work_group ); 145 145 } 146 </pre><p>(The dbgtext() function is explained below.)</p><p>There are a few advantages to this scheme:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>146 </pre><p>(The dbgtext() function is explained below.)</p><p>There are a few advantages to this scheme:</p><div class="orderedlist"><ol type="1"><li><p> 147 147 The test is performed only once. 148 </p></li><li class="listitem"><p>148 </p></li><li><p> 149 149 You can allocate variables off of the stack that will only be used 150 150 within the DEBUGLVL() block. 151 </p></li><li class="listitem"><p>151 </p></li><li><p> 152 152 Processing that is only relevant to debug output can be contained 153 153 within the DEBUGLVL() block. 154 </p></li></ol></div></div><div class="sect1" title="New Functions"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2563343"></a>New Functions</h2></div></div></div><div class="sect2" title="dbgtext()"><div class="titlepage"><div><div><h3 class="title"><a name="id2563348"></a>dbgtext()</h3></div></div></div><p>154 </p></li></ol></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2557271"></a>New Functions</h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2557276"></a>dbgtext()</h3></div></div></div><p> 155 155 This function prints debug message text to the debug file (and 156 156 possibly to syslog) via the format buffer. The function uses a … … 161 161 If you use DEBUGLVL() you will probably print the body of the 162 162 message using dbgtext(). 163 </p></div><div class="sect2" title="dbghdr()"><div class="titlepage"><div><div><h3 class="title"><a name="id2563364"></a>dbghdr()</h3></div></div></div><p>163 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2557292"></a>dbghdr()</h3></div></div></div><p> 164 164 This is the function that writes a debug message header. 165 165 Headers are not processed via the format buffer. Also note that … … 169 169 It is not likely that this function will be called directly. It 170 170 is used by DEBUG() and DEBUGADD(). 171 </p></div><div class="sect2" title="format_debug_text()"><div class="titlepage"><div><div><h3 class="title"><a name="id2563383"></a>format_debug_text()</h3></div></div></div><p>171 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2557311"></a>format_debug_text()</h3></div></div></div><p> 172 172 This is a static function in debug.c. It stores the output text 173 173 for the body of the message in a buffer until it encounters a
Note:
See TracChangeset
for help on using the changeset viewer.