diff options
author | Tim Potter <tpot@samba.org> | 2001-06-01 12:04:44 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2001-06-01 12:04:44 +0000 |
commit | 6dce5c47c62d6ad3d74489bde3824fbfb02d8616 (patch) | |
tree | 88e3cb5f75994eea6dce71b6c3eec20b4961dd78 | |
parent | 62ce28e8d5f414d1728ec9e592f13dbccec10bad (diff) | |
download | samba-6dce5c47c62d6ad3d74489bde3824fbfb02d8616.tar.gz samba-6dce5c47c62d6ad3d74489bde3824fbfb02d8616.tar.bz2 samba-6dce5c47c62d6ad3d74489bde3824fbfb02d8616.zip |
If a debug class was explicitly set to zero the debug system would not
recognise it as there was no distinction made between zeroing a debug
class and just not setting it to anything. I've added a
debuglevel_isset array in parallel with the debuglevel_class array to
fix this.
Added a couple of new debug classes which I might start filling out
to get smb, rpc header and rpc marshall/unmarshalling debugs tidied
up.
Fixed a bunch of cut&paste bugs in include/debug.h
Modified smbcontrol and the messaging system debug handler to like the
debuglevel_isset stuff.
(This used to be commit 391e7caf76cbc22021629ef0ec5e0c32806edfd7)
-rw-r--r-- | source3/include/debug.h | 40 | ||||
-rw-r--r-- | source3/lib/debug.c | 50 | ||||
-rw-r--r-- | source3/utils/smbcontrol.c | 12 |
3 files changed, 70 insertions, 32 deletions
diff --git a/source3/include/debug.h b/source3/include/debug.h index 240da0d6fc..0bde9e69cf 100644 --- a/source3/include/debug.h +++ b/source3/include/debug.h @@ -82,12 +82,20 @@ BOOL dbgtext( char *, ... ) PRINTF_ATTRIBUTE(1,2); #define DBGC_TDB 1 #define DBGC_PRINTDRIVERS 2 #define DBGC_LANMAN 3 +#define DBGC_SMB 4 +#define DBGC_RPC 5 +#define DBGC_RPC_HDR 6 +#define DBGC_BDC 7 -#define DBGC_LAST 4 /* MUST be last class value + 1 */ - +#define DBGC_LAST 8 /* MUST be last class value + 1 */ extern int DEBUGLEVEL_CLASS[DBGC_LAST]; +extern BOOL DEBUGLEVEL_CLASS_ISSET[DBGC_LAST]; +struct debuglevel_message { + int debuglevel_class[DBGC_LAST]; + BOOL debuglevel_class_isset[DBGC_LAST]; +}; /* Debugging macros * @@ -105,7 +113,7 @@ extern int DEBUGLEVEL_CLASS[DBGC_LAST]; * generate a header using the default macros for file, line, and * function name. Returns True if the debug level was <= DEBUGLEVEL. * - * Example: if( DEBUGLVL( DBGC_TDB, 2 ) ) dbgtext( "Some text.\n" ); + * Example: if( DEBUGLVLC( DBGC_TDB, 2 ) ) dbgtext( "Some text.\n" ); * * DEBUG() * If the 'file specific' debug class level >= level OR the system-wide @@ -115,7 +123,7 @@ extern int DEBUGLEVEL_CLASS[DBGC_LAST]; * previous debug output was unterminated (i.e. no '\n'). * See debug.c:dbghdr() for more info. * - * Example: DEBUG( 2, ("Some text and a valu %d.\n", value) ); + * Example: DEBUG( 2, ("Some text and a value %d.\n", value) ); * * DEBUGC() * If the 'macro specified' debug class level >= level OR the system-wide @@ -125,15 +133,15 @@ extern int DEBUGLEVEL_CLASS[DBGC_LAST]; * previous debug output was unterminated (i.e. no '\n'). * See debug.c:dbghdr() for more info. * - * Example: DEBUG( DBGC_TDB, 2, ("Some text and a valu %d.\n", value) ); + * Example: DEBUGC( DBGC_TDB, 2, ("Some text and a value %d.\n", value) ); * * DEBUGADD(), DEBUGADDC() * Same as DEBUG() and DEBUGC() except the text is appended to the previous * DEBUG(), DEBUGC(), DEBUGADD(), DEBUGADDC() with out another interviening * header. * - * Example: DEBUGADD( 2, ("Some text and a valu %d.\n", value) ); - * DEBUGADDC( DBGC_TDB, 2, ("Some text and a valu %d.\n", value) ); + * Example: DEBUGADD( 2, ("Some text and a value %d.\n", value) ); + * DEBUGADDC( DBGC_TDB, 2, ("Some text and a value %d.\n", value) ); * * Note: If the debug class has not be redeined (see above) then the optimizer * will remove the extra conditional test. @@ -141,36 +149,42 @@ extern int DEBUGLEVEL_CLASS[DBGC_LAST]; #define DEBUGLVL( level ) \ ( ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \ - (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ + (!DEBUGLEVEL_CLASS[ DBGC_CLASS ] && \ + DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ && dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) ) ) #define DEBUGLVLC( dbgc_class, level ) \ ( ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \ - (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ + (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \ + DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ && dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) ) ) #define DEBUG( level, body ) \ (void)( ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \ - (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ + (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \ + DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ && (dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) )) \ && (dbgtext body) ) #define DEBUGC( dbgc_class, level, body ) \ (void)( ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \ - (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ + (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \ + DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ && (dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) )) \ && (dbgtext body) ) #define DEBUGADD( level, body ) \ (void)( ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \ - (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ + (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \ + DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ && (dbgtext body) ) #define DEBUGADDC( dbgc_class, level, body ) \ (void)( ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \ - (DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ + (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \ + DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ && (dbgtext body) ) #endif diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 934110a4d7..bd8babf827 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -84,6 +84,7 @@ pstring debugf = ""; BOOL append_log = False; int DEBUGLEVEL_CLASS[DBGC_LAST]; +BOOL DEBUGLEVEL_CLASS_ISSET[DBGC_LAST]; int DEBUGLEVEL = DEBUGLEVEL_CLASS; @@ -129,13 +130,14 @@ static BOOL log_overflow = False; * must be in the table in the order of DBGC_<class name>.. */ char *classname_table[] = { - "all", /* DBGC_ALL; index references traditional DEBUGLEVEL */ - "tdb", /* DBGC_TDB */ + "all", /* DBGC_ALL; index refs traditional DEBUGLEVEL */ + "tdb", /* DBGC_TDB */ "printdrivers", /* DBGC_PRINTDRIVERS */ - "lanman", /* DBGC_LANMAN */ - "smb", /* DBGC_SMB */ - "rpc", /* DBGC_RPC */ - "rpc_hdr", /* DBGC_RPC_HDR */ + "lanman", /* DBGC_LANMAN */ + "smb", /* DBGC_SMB */ + "rpc", /* DBGC_RPC */ + "rpc_hdr", /* DBGC_RPC_HDR */ + "bdc", /* DBGC_BDC */ }; @@ -171,7 +173,8 @@ int debug_lookup_classname(char* classname) parse the debug levels from smbcontrol. Example debug level parameter: printdrivers:7 ****************************************************************************/ -BOOL debug_parse_params(char **params, int *debuglevel_class) +BOOL debug_parse_params(char **params, int *debuglevel_class, + BOOL *debuglevel_class_isset) { int i, ndx; char *class_name; @@ -185,10 +188,11 @@ BOOL debug_parse_params(char **params, int *debuglevel_class) */ if (isdigit((int)params[0][0])) { debuglevel_class[DBGC_ALL] = atoi(params[0]); + debuglevel_class_isset[DBGC_ALL] = True; i = 1; /* start processing at the next params */ } else - i = 0; /* DBGC_ALL not specified OR calss name was included */ + i = 0; /* DBGC_ALL not specified OR class name was included */ /* Fill in new debug class levels */ for (; i < DBGC_LAST && params[i]; i++) { @@ -196,6 +200,7 @@ BOOL debug_parse_params(char **params, int *debuglevel_class) (class_level=strtok(NULL, "\0")) && ((ndx = debug_lookup_classname(class_name)) != -1)) { debuglevel_class[ndx] = atoi(class_level); + debuglevel_class_isset[ndx] = True; } else { DEBUG(0,("debug_parse_params: unrecognized debug class name or format [%s]\n", params[i])); return False; @@ -215,9 +220,11 @@ BOOL debug_parse_levels(char *params_str) int i; char *params[DBGC_LAST]; int debuglevel_class[DBGC_LAST]; + BOOL debuglevel_class_isset[DBGC_LAST]; ZERO_ARRAY(params); ZERO_ARRAY(debuglevel_class); + ZERO_ARRAY(debuglevel_class_isset); if ((params[0]=strtok(params_str," ,"))) { for (i=1; i<DBGC_LAST;i++) { @@ -228,13 +235,26 @@ BOOL debug_parse_levels(char *params_str) else return False; - if (debug_parse_params(params, debuglevel_class)) { + if (debug_parse_params(params, debuglevel_class, + debuglevel_class_isset)) { debug_message(0, getpid(), (void*)debuglevel_class, sizeof(debuglevel_class)); -#if 0 memcpy(DEBUGLEVEL_CLASS, debuglevel_class, sizeof(debuglevel_class)); -#endif + + memcpy(DEBUGLEVEL_CLASS_ISSET, debuglevel_class_isset, + sizeof(debuglevel_class_isset)); + + { + int q; + + for (q = 0; q < DBGC_LAST; q++) + DEBUG(0, ("%s: %d/%d\n", + classname_table[q], + DEBUGLEVEL_CLASS[q], + DEBUGLEVEL_CLASS_ISSET[q])); + } + return True; } else return False; @@ -245,11 +265,13 @@ receive a "set debug level" message ****************************************************************************/ void debug_message(int msg_type, pid_t src, void *buf, size_t len) { + struct debuglevel_message *dm = (struct debuglevel_message *)buf; int i; - /* Set the new DEBUGLEVEL_CLASS array from the pased array */ - memcpy(DEBUGLEVEL_CLASS, buf, sizeof(DEBUGLEVEL_CLASS)); - + /* Set the new DEBUGLEVEL_CLASS array from the passed message */ + memcpy(DEBUGLEVEL_CLASS, dm->debuglevel_class, sizeof(dm->debuglevel_class)); + memcpy(DEBUGLEVEL_CLASS_ISSET, dm->debuglevel_class_isset, sizeof(dm->debuglevel_class_isset)); + DEBUG(1,("INFO: Debug class %s level = %d (pid %u from pid %u)\n", classname_table[DBGC_ALL], DEBUGLEVEL_CLASS[DBGC_ALL], (unsigned int)getpid(), (unsigned int)src)); diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 30861030d8..b940b4006a 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -180,7 +180,6 @@ static BOOL do_command(char *dest, char *msg_name, char **params) int i, n, v; int mtype; BOOL retval=False; - int debuglevel_class[DBGC_LAST]; mtype = parse_type(msg_name); if (mtype == -1) { @@ -189,19 +188,22 @@ static BOOL do_command(char *dest, char *msg_name, char **params) } switch (mtype) { - case MSG_DEBUG: + case MSG_DEBUG: { + struct debuglevel_message dm; + if (!params || !params[0]) { fprintf(stderr,"MSG_DEBUG needs a parameter\n"); return(False); } - ZERO_ARRAY(debuglevel_class); - if (!debug_parse_params(params, debuglevel_class)) { + ZERO_STRUCT(dm); + if (!debug_parse_params(params, dm.debuglevel_class, dm.debuglevel_class_isset)) { fprintf(stderr, "MSG_DEBUG error. Expected <class name>:level\n"); return(False); } else - send_message(dest, MSG_DEBUG, debuglevel_class, sizeof(debuglevel_class), False); + send_message(dest, MSG_DEBUG, &dm, sizeof(dm), False); break; + } case MSG_PROFILE: if (!params[0]) { |