include/debug.h

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    SMB debug stuff
00004    Copyright (C) Andrew Tridgell 1992-1998
00005    Copyright (C) John H Terpstra 1996-1998
00006    Copyright (C) Luke Kenneth Casson Leighton 1996-1998
00007    Copyright (C) Paul Ashton 1998
00008    
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 2 of the License, or
00012    (at your option) any later version.
00013    
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018    
00019    You should have received a copy of the GNU General Public License
00020    along with this program; if not, write to the Free Software
00021    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022 */
00023 
00024 #ifndef _DEBUG_H
00025 #define _DEBUG_H
00026 
00027 /* -------------------------------------------------------------------------- **
00028  * Debugging code.  See also debug.c
00029  */
00030 
00031 /* mkproto.awk has trouble with ifdef'd function definitions (it ignores
00032  * the #ifdef directive and will read both definitions, thus creating two
00033  * diffferent prototype declarations), so we must do these by hand.
00034  */
00035 /* I know the __attribute__ stuff is ugly, but it does ensure we get the 
00036    arguments to DEBUG() right. We have got them wrong too often in the 
00037    past.
00038    The PRINTFLIKE comment does the equivalent for SGI MIPSPro.
00039  */
00040 /* PRINTFLIKE1 */
00041 int  Debug1( const char *, ... ) PRINTF_ATTRIBUTE(1,2);
00042 /* PRINTFLIKE1 */
00043 BOOL dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2);
00044 BOOL dbghdr( int level, const char *file, const char *func, int line );
00045 
00046 #if defined(sgi) && (_COMPILER_VERSION >= 730)
00047 #pragma mips_frequency_hint NEVER Debug1
00048 #pragma mips_frequency_hint NEVER dbgtext
00049 #pragma mips_frequency_hint NEVER dbghdr
00050 #endif
00051 
00052 extern XFILE *dbf;
00053 extern pstring debugf;
00054 
00055 /* If we have these macros, we can add additional info to the header. */
00056 
00057 #ifdef HAVE_FUNCTION_MACRO
00058 #define FUNCTION_MACRO  (__FUNCTION__)
00059 #else
00060 #define FUNCTION_MACRO  ("")
00061 #endif
00062 
00063 /* 
00064  * Redefine DEBUGLEVEL because so we don't have to change every source file
00065  * that *unnecessarily* references it. Source files neeed not extern reference 
00066  * DEBUGLEVEL, as it's extern in includes.h (which all source files include).
00067  * Eventually, all these references should be removed, and all references to
00068  * DEBUGLEVEL should be references to DEBUGLEVEL_CLASS[DBGC_ALL]. This could
00069  * still be through a macro still called DEBUGLEVEL. This cannot be done now
00070  * because some references would expand incorrectly.
00071  */
00072 #define DEBUGLEVEL *debug_level
00073 extern int DEBUGLEVEL;
00074 
00075 /*
00076  * Define all new debug classes here. A class is represented by an entry in
00077  * the DEBUGLEVEL_CLASS array. Index zero of this arrray is equivalent to the
00078  * old DEBUGLEVEL. Any source file that does NOT add the following lines:
00079  *
00080  *   #undef  DBGC_CLASS
00081  *   #define DBGC_CLASS DBGC_<your class name here>
00082  *
00083  * at the start of the file (after #include "includes.h") will default to
00084  * using index zero, so it will behaive just like it always has. 
00085  */
00086 #define DBGC_ALL                0 /* index equivalent to DEBUGLEVEL */
00087 
00088 #define DBGC_TDB                1
00089 #define DBGC_PRINTDRIVERS       2
00090 #define DBGC_LANMAN             3
00091 #define DBGC_SMB                4
00092 #define DBGC_RPC_PARSE          5
00093 #define DBGC_RPC_SRV            6
00094 #define DBGC_RPC_CLI            7
00095 #define DBGC_PASSDB             8
00096 #define DBGC_SAM                9
00097 #define DBGC_AUTH               10
00098 #define DBGC_WINBIND            11
00099 #define DBGC_VFS                12
00100 #define DBGC_IDMAP              13
00101 #define DBGC_QUOTA              14
00102 #define DBGC_ACLS               15
00103 #define DBGC_LOCKING            16
00104 #define DBGC_MSDFS              17
00105 #define DBGC_DMAPI              18
00106 
00107 /* So you can define DBGC_CLASS before including debug.h */
00108 #ifndef DBGC_CLASS
00109 #define DBGC_CLASS            0     /* override as shown above */
00110 #endif
00111 
00112 extern int  *DEBUGLEVEL_CLASS;
00113 extern BOOL *DEBUGLEVEL_CLASS_ISSET;
00114 
00115 /* Debugging macros
00116  *
00117  * DEBUGLVL()
00118  *   If the 'file specific' debug class level >= level OR the system-wide 
00119  *   DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then
00120  *   generate a header using the default macros for file, line, and 
00121  *   function name. Returns True if the debug level was <= DEBUGLEVEL.
00122  * 
00123  *   Example: if( DEBUGLVL( 2 ) ) dbgtext( "Some text.\n" );
00124  *
00125  * DEBUGLVLC()
00126  *   If the 'macro specified' debug class level >= level OR the system-wide 
00127  *   DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then 
00128  *   generate a header using the default macros for file, line, and 
00129  *   function name. Returns True if the debug level was <= DEBUGLEVEL.
00130  * 
00131  *   Example: if( DEBUGLVLC( DBGC_TDB, 2 ) ) dbgtext( "Some text.\n" );
00132  *
00133  * DEBUG()
00134  *   If the 'file specific' debug class level >= level OR the system-wide 
00135  *   DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then 
00136  *   generate a header using the default macros for file, line, and 
00137  *   function name. Each call to DEBUG() generates a new header *unless* the 
00138  *   previous debug output was unterminated (i.e. no '\n').
00139  *   See debug.c:dbghdr() for more info.
00140  *
00141  *   Example: DEBUG( 2, ("Some text and a value %d.\n", value) );
00142  *
00143  * DEBUGC()
00144  *   If the 'macro specified' debug class level >= level OR the system-wide 
00145  *   DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then 
00146  *   generate a header using the default macros for file, line, and 
00147  *   function name. Each call to DEBUG() generates a new header *unless* the 
00148  *   previous debug output was unterminated (i.e. no '\n').
00149  *   See debug.c:dbghdr() for more info.
00150  *
00151  *   Example: DEBUGC( DBGC_TDB, 2, ("Some text and a value %d.\n", value) );
00152  *
00153  *  DEBUGADD(), DEBUGADDC()
00154  *    Same as DEBUG() and DEBUGC() except the text is appended to the previous
00155  *    DEBUG(), DEBUGC(), DEBUGADD(), DEBUGADDC() with out another interviening 
00156  *    header.
00157  *
00158  *    Example: DEBUGADD( 2, ("Some text and a value %d.\n", value) );
00159  *             DEBUGADDC( DBGC_TDB, 2, ("Some text and a value %d.\n", value) );
00160  *
00161  * Note: If the debug class has not be redeined (see above) then the optimizer 
00162  * will remove the extra conditional test.
00163  */
00164 
00165 #define DEBUGLVL( level ) \
00166   ( ((level) <= MAX_DEBUG_LEVEL) && \
00167      ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
00168      (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
00169       DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
00170    && dbghdr( level, __FILE__, FUNCTION_MACRO, (__LINE__) ) )
00171 
00172 
00173 #define DEBUGLVLC( dbgc_class, level ) \
00174   ( ((level) <= MAX_DEBUG_LEVEL) && \
00175      ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
00176      (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
00177       DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
00178    && dbghdr( level, __FILE__, FUNCTION_MACRO, (__LINE__) ) )
00179 
00180 
00181 #define DEBUG( level, body ) \
00182   (void)( ((level) <= MAX_DEBUG_LEVEL) && \
00183            ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
00184            (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
00185             DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
00186        && (dbghdr( level, __FILE__, FUNCTION_MACRO, (__LINE__) )) \
00187        && (dbgtext body) )
00188 
00189 #define DEBUGC( dbgc_class, level, body ) \
00190   (void)( ((level) <= MAX_DEBUG_LEVEL) && \
00191            ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
00192            (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
00193             DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
00194        && (dbghdr( level, __FILE__, FUNCTION_MACRO, (__LINE__) )) \
00195        && (dbgtext body) )
00196 
00197 #define DEBUGADD( level, body ) \
00198   (void)( ((level) <= MAX_DEBUG_LEVEL) && \
00199            ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
00200            (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
00201             DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
00202        && (dbgtext body) )
00203 
00204 #define DEBUGADDC( dbgc_class, level, body ) \
00205   (void)( ((level) <= MAX_DEBUG_LEVEL) && \
00206           ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
00207            (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
00208             DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
00209        && (dbgtext body) )
00210 
00211 /* Print a separator to the debug log. */
00212 #define DEBUGSEP(level)\
00213         DEBUG((level),("===============================================================\n"))
00214 
00215 #endif

Sambaに対してSat Aug 29 21:22:54 2009に生成されました。  doxygen 1.4.7