dbug.c | dbug.c | |||
---|---|---|---|---|
skipping to change at line 598 | skipping to change at line 598 | |||
c= *control++; | c= *control++; | |||
if (*control == ',') control++; | if (*control == ',') control++; | |||
/* XXX when adding new cases here, don't forget _db_explain_ ! */ | /* XXX when adding new cases here, don't forget _db_explain_ ! */ | |||
switch (c) { | switch (c) { | |||
case 'd': | case 'd': | |||
if (sign < 0 && control == end) | if (sign < 0 && control == end) | |||
{ | { | |||
if (!is_shared(stack, keywords)) | if (!is_shared(stack, keywords)) | |||
FreeList(stack->keywords); | FreeList(stack->keywords); | |||
stack->keywords=NULL; | stack->keywords=NULL; | |||
stack->flags &= ~DEBUG_ON; | stack->flags&= ~DEBUG_ON; | |||
break; | break; | |||
} | } | |||
if (rel && is_shared(stack, keywords)) | if (rel && is_shared(stack, keywords)) | |||
stack->keywords= ListCopy(stack->keywords); | stack->keywords= ListCopy(stack->keywords); | |||
if (sign < 0) | if (sign < 0) | |||
{ | { | |||
if (DEBUGGING) | if (DEBUGGING) | |||
{ | ||||
stack->keywords= ListDel(stack->keywords, control, end); | stack->keywords= ListDel(stack->keywords, control, end); | |||
break; | /* Turn off DEBUG_ON if it is last keyword to be removed. */ | |||
if (stack->keywords == NULL) | ||||
stack->flags&= ~DEBUG_ON; | ||||
} | ||||
break; | ||||
} | ||||
/* Do not add keyword if debugging all is enabled. */ | ||||
if (!(DEBUGGING && stack->keywords == NULL)) | ||||
{ | ||||
stack->keywords= ListAdd(stack->keywords, control, end); | ||||
stack->flags|= DEBUG_ON; | ||||
} | } | |||
stack->keywords= ListAdd(stack->keywords, control, end); | ||||
stack->flags |= DEBUG_ON; | /* If debug all is enabled, make the keyword list empty. */ | |||
if (sign == 1 && control == end) | ||||
{ | ||||
FreeList(stack->keywords); | ||||
stack->keywords= NULL; | ||||
} | ||||
break; | break; | |||
case 'D': | case 'D': | |||
stack->delay= atoi(control); | stack->delay= atoi(control); | |||
break; | break; | |||
case 'f': | case 'f': | |||
f_used= 1; | f_used= 1; | |||
if (sign < 0 && control == end) | if (sign < 0 && control == end) | |||
{ | { | |||
if (!is_shared(stack,functions)) | if (!is_shared(stack,functions)) | |||
FreeList(stack->functions); | FreeList(stack->functions); | |||
skipping to change at line 1034 | skipping to change at line 1052 | |||
* | * | |||
*/ | */ | |||
/* helper macros */ | /* helper macros */ | |||
#define char_to_buf(C) do { \ | #define char_to_buf(C) do { \ | |||
*buf++=(C); \ | *buf++=(C); \ | |||
if (buf >= end) goto overflow; \ | if (buf >= end) goto overflow; \ | |||
} while (0) | } while (0) | |||
#define str_to_buf(S) do { \ | #define str_to_buf(S) do { \ | |||
char_to_buf(','); \ | char_to_buf(','); \ | |||
buf=strnmov(buf, (S), len+1); \ | buf=strnmov(buf, (S), end-buf); \ | |||
if (buf >= end) goto overflow; \ | if (buf >= end) goto overflow; \ | |||
} while (0) | } while (0) | |||
#define list_to_buf(l, f) do { \ | #define list_to_buf(l, f) do { \ | |||
struct link *listp=(l); \ | struct link *listp=(l); \ | |||
while (listp) \ | while (listp) \ | |||
{ \ | { \ | |||
if (listp->flags & (f)) \ | if (listp->flags & (f)) \ | |||
{ \ | { \ | |||
str_to_buf(listp->str); \ | str_to_buf(listp->str); \ | |||
if (listp->flags & SUBDIR) \ | if (listp->flags & SUBDIR) \ | |||
skipping to change at line 1355 | skipping to change at line 1373 | |||
{ | { | |||
CODE_STATE *cs; | CODE_STATE *cs; | |||
get_code_state_or_return; | get_code_state_or_return; | |||
cs->u_line= _line_; | cs->u_line= _line_; | |||
cs->u_keyword= keyword; | cs->u_keyword= keyword; | |||
} | } | |||
/* | /* | |||
* FUNCTION | * FUNCTION | |||
* | * | |||
* _db_enabled_ check if debug is enabled for the keyword used in | ||||
* DBUG_PRINT | ||||
* | ||||
* SYNOPSIS | ||||
* | ||||
* int _db_enabled_(); | ||||
* | ||||
* DESCRIPTION | ||||
* | ||||
* The function checks if the debug output is to be enabled for the keyw | ||||
ord | ||||
* specified in DBUG_PRINT macro. _db_doprnt_ will be called only if thi | ||||
s | ||||
* function evaluates to 1. | ||||
*/ | ||||
int _db_enabled_() | ||||
{ | ||||
CODE_STATE *cs; | ||||
get_code_state_or_return 0; | ||||
if (! DEBUGGING) | ||||
return 0; | ||||
if (_db_keyword_(cs, cs->u_keyword, 0)) | ||||
return 1; | ||||
return 0; | ||||
} | ||||
/* | ||||
* FUNCTION | ||||
* | ||||
* _db_doprnt_ handle print of debug lines | * _db_doprnt_ handle print of debug lines | |||
* | * | |||
* SYNOPSIS | * SYNOPSIS | |||
* | * | |||
* VOID _db_doprnt_(format, va_alist) | * VOID _db_doprnt_(format, va_alist) | |||
* char *format; | * char *format; | |||
* va_dcl; | * va_dcl; | |||
* | * | |||
* DESCRIPTION | * DESCRIPTION | |||
* | * | |||
* When invoked via one of the DBUG macros, tests the current keyword | * This function handles the printing of the arguments via the format | |||
* set by calling _db_pargs_() to see if that macro has been selected | * string. The line number of the DBUG macro in the source is found i | |||
* for processing via the debugger control string, and if so, handles | n | |||
* printing of the arguments via the format string. The line number | * u_line. | |||
* of the DBUG macro in the source is found in u_line. | ||||
* | * | |||
* Note that the format string SHOULD NOT include a terminating | * Note that the format string SHOULD NOT include a terminating | |||
* newline, this is supplied automatically. | * newline, this is supplied automatically. | |||
* | * | |||
*/ | */ | |||
#include <stdarg.h> | #include <stdarg.h> | |||
void _db_doprnt_(const char *format,...) | void _db_doprnt_(const char *format,...) | |||
{ | { | |||
va_list args; | va_list args; | |||
CODE_STATE *cs; | CODE_STATE *cs; | |||
int save_errno; | ||||
get_code_state_or_return; | get_code_state_or_return; | |||
/* Dirty read, for DBUG_PRINT() performance. */ | /* Dirty read, for DBUG_PRINT() performance. */ | |||
if (! DEBUGGING) | if (! DEBUGGING) | |||
return; | return; | |||
va_start(args,format); | va_start(args,format); | |||
read_lock_stack(cs); | read_lock_stack(cs); | |||
if (_db_keyword_(cs, cs->u_keyword, 0)) | save_errno=errno; | |||
{ | if (!cs->locked) | |||
int save_errno=errno; | pthread_mutex_lock(&THR_LOCK_dbug); | |||
if (!cs->locked) | DoPrefix(cs, cs->u_line); | |||
pthread_mutex_lock(&THR_LOCK_dbug); | if (TRACING) | |||
DoPrefix(cs, cs->u_line); | Indent(cs, cs->level + 1); | |||
if (TRACING) | else | |||
Indent(cs, cs->level + 1); | (void) fprintf(cs->stack->out_file, "%s: ", cs->func); | |||
else | (void) fprintf(cs->stack->out_file, "%s: ", cs->u_keyword); | |||
(void) fprintf(cs->stack->out_file, "%s: ", cs->func); | DbugVfprintf(cs->stack->out_file, format, args); | |||
(void) fprintf(cs->stack->out_file, "%s: ", cs->u_keyword); | DbugFlush(cs); | |||
DbugVfprintf(cs->stack->out_file, format, args); | errno=save_errno; | |||
DbugFlush(cs); | ||||
errno=save_errno; | ||||
} | ||||
unlock_stack(cs); | unlock_stack(cs); | |||
va_end(args); | va_end(args); | |||
} | } | |||
/* | /* | |||
* This function is intended as a | * This function is intended as a | |||
* vfprintf clone with consistent, platform independent output for | * vfprintf clone with consistent, platform independent output for | |||
* problematic formats like %p, %zd and %lld. | * problematic formats like %p, %zd and %lld. | |||
*/ | */ | |||
static void DbugVfprintf(FILE *stream, const char* format, va_list args) | static void DbugVfprintf(FILE *stream, const char* format, va_list args) | |||
End of changes. 9 change blocks. | ||||
25 lines changed or deleted | 76 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |