mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
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 391e7caf76
)
This commit is contained in:
parent
62ce28e8d5
commit
6dce5c47c6
@ -82,12 +82,20 @@ BOOL dbgtext( char *, ... ) PRINTF_ATTRIBUTE(1,2);
|
|||||||
#define DBGC_TDB 1
|
#define DBGC_TDB 1
|
||||||
#define DBGC_PRINTDRIVERS 2
|
#define DBGC_PRINTDRIVERS 2
|
||||||
#define DBGC_LANMAN 3
|
#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 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
|
/* Debugging macros
|
||||||
*
|
*
|
||||||
@ -105,7 +113,7 @@ extern int DEBUGLEVEL_CLASS[DBGC_LAST];
|
|||||||
* generate a header using the default macros for file, line, and
|
* generate a header using the default macros for file, line, and
|
||||||
* function name. Returns True if the debug level was <= DEBUGLEVEL.
|
* 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()
|
* DEBUG()
|
||||||
* If the 'file specific' debug class level >= level OR the system-wide
|
* 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').
|
* previous debug output was unterminated (i.e. no '\n').
|
||||||
* See debug.c:dbghdr() for more info.
|
* 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()
|
* DEBUGC()
|
||||||
* If the 'macro specified' debug class level >= level OR the system-wide
|
* 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').
|
* previous debug output was unterminated (i.e. no '\n').
|
||||||
* See debug.c:dbghdr() for more info.
|
* 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()
|
* DEBUGADD(), DEBUGADDC()
|
||||||
* Same as DEBUG() and DEBUGC() except the text is appended to the previous
|
* Same as DEBUG() and DEBUGC() except the text is appended to the previous
|
||||||
* DEBUG(), DEBUGC(), DEBUGADD(), DEBUGADDC() with out another interviening
|
* DEBUG(), DEBUGC(), DEBUGADD(), DEBUGADDC() with out another interviening
|
||||||
* header.
|
* header.
|
||||||
*
|
*
|
||||||
* Example: DEBUGADD( 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 valu %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
|
* Note: If the debug class has not be redeined (see above) then the optimizer
|
||||||
* will remove the extra conditional test.
|
* will remove the extra conditional test.
|
||||||
@ -141,36 +149,42 @@ extern int DEBUGLEVEL_CLASS[DBGC_LAST];
|
|||||||
|
|
||||||
#define DEBUGLVL( level ) \
|
#define DEBUGLVL( level ) \
|
||||||
( ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (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__) ) )
|
&& dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) ) )
|
||||||
|
|
||||||
|
|
||||||
#define DEBUGLVLC( dbgc_class, level ) \
|
#define DEBUGLVLC( dbgc_class, level ) \
|
||||||
( ((DEBUGLEVEL_CLASS[ 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__) ) )
|
&& dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) ) )
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG( level, body ) \
|
#define DEBUG( level, body ) \
|
||||||
(void)( ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \
|
(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__) )) \
|
&& (dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) )) \
|
||||||
&& (dbgtext body) )
|
&& (dbgtext body) )
|
||||||
|
|
||||||
#define DEBUGC( dbgc_class, level, body ) \
|
#define DEBUGC( dbgc_class, level, body ) \
|
||||||
(void)( ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \
|
(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__) )) \
|
&& (dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) )) \
|
||||||
&& (dbgtext body) )
|
&& (dbgtext body) )
|
||||||
|
|
||||||
#define DEBUGADD( level, body ) \
|
#define DEBUGADD( level, body ) \
|
||||||
(void)( ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \
|
(void)( ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \
|
||||||
(DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
|
(!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
|
||||||
|
DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
|
||||||
&& (dbgtext body) )
|
&& (dbgtext body) )
|
||||||
|
|
||||||
#define DEBUGADDC( dbgc_class, level, body ) \
|
#define DEBUGADDC( dbgc_class, level, body ) \
|
||||||
(void)( ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \
|
(void)( ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \
|
||||||
(DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
|
(!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
|
||||||
|
DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
|
||||||
&& (dbgtext body) )
|
&& (dbgtext body) )
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -84,6 +84,7 @@ pstring debugf = "";
|
|||||||
BOOL append_log = False;
|
BOOL append_log = False;
|
||||||
|
|
||||||
int DEBUGLEVEL_CLASS[DBGC_LAST];
|
int DEBUGLEVEL_CLASS[DBGC_LAST];
|
||||||
|
BOOL DEBUGLEVEL_CLASS_ISSET[DBGC_LAST];
|
||||||
int DEBUGLEVEL = DEBUGLEVEL_CLASS;
|
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>..
|
* must be in the table in the order of DBGC_<class name>..
|
||||||
*/
|
*/
|
||||||
char *classname_table[] = {
|
char *classname_table[] = {
|
||||||
"all", /* DBGC_ALL; index references traditional DEBUGLEVEL */
|
"all", /* DBGC_ALL; index refs traditional DEBUGLEVEL */
|
||||||
"tdb", /* DBGC_TDB */
|
"tdb", /* DBGC_TDB */
|
||||||
"printdrivers", /* DBGC_PRINTDRIVERS */
|
"printdrivers", /* DBGC_PRINTDRIVERS */
|
||||||
"lanman", /* DBGC_LANMAN */
|
"lanman", /* DBGC_LANMAN */
|
||||||
"smb", /* DBGC_SMB */
|
"smb", /* DBGC_SMB */
|
||||||
"rpc", /* DBGC_RPC */
|
"rpc", /* DBGC_RPC */
|
||||||
"rpc_hdr", /* DBGC_RPC_HDR */
|
"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:
|
parse the debug levels from smbcontrol. Example debug level parameter:
|
||||||
printdrivers:7
|
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;
|
int i, ndx;
|
||||||
char *class_name;
|
char *class_name;
|
||||||
@ -185,10 +188,11 @@ BOOL debug_parse_params(char **params, int *debuglevel_class)
|
|||||||
*/
|
*/
|
||||||
if (isdigit((int)params[0][0])) {
|
if (isdigit((int)params[0][0])) {
|
||||||
debuglevel_class[DBGC_ALL] = atoi(params[0]);
|
debuglevel_class[DBGC_ALL] = atoi(params[0]);
|
||||||
|
debuglevel_class_isset[DBGC_ALL] = True;
|
||||||
i = 1; /* start processing at the next params */
|
i = 1; /* start processing at the next params */
|
||||||
}
|
}
|
||||||
else
|
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 */
|
/* Fill in new debug class levels */
|
||||||
for (; i < DBGC_LAST && params[i]; i++) {
|
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")) &&
|
(class_level=strtok(NULL, "\0")) &&
|
||||||
((ndx = debug_lookup_classname(class_name)) != -1)) {
|
((ndx = debug_lookup_classname(class_name)) != -1)) {
|
||||||
debuglevel_class[ndx] = atoi(class_level);
|
debuglevel_class[ndx] = atoi(class_level);
|
||||||
|
debuglevel_class_isset[ndx] = True;
|
||||||
} else {
|
} else {
|
||||||
DEBUG(0,("debug_parse_params: unrecognized debug class name or format [%s]\n", params[i]));
|
DEBUG(0,("debug_parse_params: unrecognized debug class name or format [%s]\n", params[i]));
|
||||||
return False;
|
return False;
|
||||||
@ -215,9 +220,11 @@ BOOL debug_parse_levels(char *params_str)
|
|||||||
int i;
|
int i;
|
||||||
char *params[DBGC_LAST];
|
char *params[DBGC_LAST];
|
||||||
int debuglevel_class[DBGC_LAST];
|
int debuglevel_class[DBGC_LAST];
|
||||||
|
BOOL debuglevel_class_isset[DBGC_LAST];
|
||||||
|
|
||||||
ZERO_ARRAY(params);
|
ZERO_ARRAY(params);
|
||||||
ZERO_ARRAY(debuglevel_class);
|
ZERO_ARRAY(debuglevel_class);
|
||||||
|
ZERO_ARRAY(debuglevel_class_isset);
|
||||||
|
|
||||||
if ((params[0]=strtok(params_str," ,"))) {
|
if ((params[0]=strtok(params_str," ,"))) {
|
||||||
for (i=1; i<DBGC_LAST;i++) {
|
for (i=1; i<DBGC_LAST;i++) {
|
||||||
@ -228,13 +235,26 @@ BOOL debug_parse_levels(char *params_str)
|
|||||||
else
|
else
|
||||||
return False;
|
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));
|
debug_message(0, getpid(), (void*)debuglevel_class, sizeof(debuglevel_class));
|
||||||
|
|
||||||
#if 0
|
|
||||||
memcpy(DEBUGLEVEL_CLASS, debuglevel_class,
|
memcpy(DEBUGLEVEL_CLASS, debuglevel_class,
|
||||||
sizeof(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;
|
return True;
|
||||||
} else
|
} else
|
||||||
return False;
|
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)
|
void debug_message(int msg_type, pid_t src, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
|
struct debuglevel_message *dm = (struct debuglevel_message *)buf;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Set the new DEBUGLEVEL_CLASS array from the pased array */
|
/* Set the new DEBUGLEVEL_CLASS array from the passed message */
|
||||||
memcpy(DEBUGLEVEL_CLASS, buf, sizeof(DEBUGLEVEL_CLASS));
|
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",
|
DEBUG(1,("INFO: Debug class %s level = %d (pid %u from pid %u)\n",
|
||||||
classname_table[DBGC_ALL],
|
classname_table[DBGC_ALL],
|
||||||
DEBUGLEVEL_CLASS[DBGC_ALL], (unsigned int)getpid(), (unsigned int)src));
|
DEBUGLEVEL_CLASS[DBGC_ALL], (unsigned int)getpid(), (unsigned int)src));
|
||||||
|
@ -180,7 +180,6 @@ static BOOL do_command(char *dest, char *msg_name, char **params)
|
|||||||
int i, n, v;
|
int i, n, v;
|
||||||
int mtype;
|
int mtype;
|
||||||
BOOL retval=False;
|
BOOL retval=False;
|
||||||
int debuglevel_class[DBGC_LAST];
|
|
||||||
|
|
||||||
mtype = parse_type(msg_name);
|
mtype = parse_type(msg_name);
|
||||||
if (mtype == -1) {
|
if (mtype == -1) {
|
||||||
@ -189,19 +188,22 @@ static BOOL do_command(char *dest, char *msg_name, char **params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (mtype) {
|
switch (mtype) {
|
||||||
case MSG_DEBUG:
|
case MSG_DEBUG: {
|
||||||
|
struct debuglevel_message dm;
|
||||||
|
|
||||||
if (!params || !params[0]) {
|
if (!params || !params[0]) {
|
||||||
fprintf(stderr,"MSG_DEBUG needs a parameter\n");
|
fprintf(stderr,"MSG_DEBUG needs a parameter\n");
|
||||||
return(False);
|
return(False);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZERO_ARRAY(debuglevel_class);
|
ZERO_STRUCT(dm);
|
||||||
if (!debug_parse_params(params, debuglevel_class)) {
|
if (!debug_parse_params(params, dm.debuglevel_class, dm.debuglevel_class_isset)) {
|
||||||
fprintf(stderr, "MSG_DEBUG error. Expected <class name>:level\n");
|
fprintf(stderr, "MSG_DEBUG error. Expected <class name>:level\n");
|
||||||
return(False);
|
return(False);
|
||||||
} else
|
} else
|
||||||
send_message(dest, MSG_DEBUG, debuglevel_class, sizeof(debuglevel_class), False);
|
send_message(dest, MSG_DEBUG, &dm, sizeof(dm), False);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MSG_PROFILE:
|
case MSG_PROFILE:
|
||||||
if (!params[0]) {
|
if (!params[0]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user