#include <my_global.h>#include <m_string.h>#include <errno.h>#include <stdarg.h>Include dependency graph for dbug.c:

Go to the source code of this file.
Classes | |
| struct | link |
| struct | settings |
| struct | _db_code_state_ |
Defines | |
| #define | PRINTBUF 1024 |
| #define | INDENT 2 |
| #define | MAXDEPTH 200 |
| #define | TRACE_ON 000001 |
| #define | DEBUG_ON 000002 |
| #define | FILE_ON 000004 |
| #define | LINE_ON 000010 |
| #define | DEPTH_ON 000020 |
| #define | PROCESS_ON 000040 |
| #define | NUMBER_ON 000100 |
| #define | PROFILE_ON 000200 |
| #define | PID_ON 000400 |
| #define | TIMESTAMP_ON 001000 |
| #define | SANITY_CHECK_ON 002000 |
| #define | FLUSH_ON_WRITE 004000 |
| #define | OPEN_APPEND 010000 |
| #define | TRACING (cs->stack->flags & TRACE_ON) |
| #define | DEBUGGING (cs->stack->flags & DEBUG_ON) |
| #define | PROFILING (cs->stack->flags & PROFILE_ON) |
| #define | IMPORT extern |
| #define | EXPORT |
| #define | AUTO auto |
| #define | REGISTER register |
| #define | PROF_FILE "dbugmon.out" |
| #define | PROF_EFMT "E\t%ld\t%s\n" |
| #define | PROF_SFMT "S\t%lx\t%lx\t%s\n" |
| #define | PROF_XFMT "X\t%ld\t%s\n" |
| #define | is_shared(S, V) ((S)->next && (S)->next->V == (S)->V) |
| #define | get_code_state_or_return if (!cs && !((cs=code_state()))) return |
| #define | ERR_MISSING_RETURN "%s: missing DBUG_RETURN or DBUG_VOID_RETURN macro in function \"%s\"\n" |
| #define | ERR_OPEN "%s: can't open debug output stream \"%s\": " |
| #define | ERR_CLOSE "%s: can't close debug file: " |
| #define | ERR_ABORT "%s: debugger aborting because %s\n" |
| #define | ERR_CHOWN "%s: can't change owner/group of \"%s\": " |
| #define | EXISTS(pathname) (FALSE) |
| #define | Writable(name) (TRUE) |
| #define | ChangeOwner(cs, name) |
| #define | pthread_mutex_lock(A) {} |
| #define | pthread_mutex_unlock(A) {} |
| #define | Delay(A) (0) |
| #define | char_to_buf(C) |
| #define | str_to_buf(S) |
| #define | list_to_buf(l) |
| #define | int_to_buf(i) |
| #define | colon_to_buf |
| #define | op_int_to_buf(C, val, def) |
| #define | op_intf_to_buf(C, val, def, cond) |
| #define | op_str_to_buf(C, val, cond) |
| #define | op_list_to_buf(C, val, cond) |
| #define | op_bool_to_buf(C, cond) |
Typedefs | |
| typedef int | BOOLEAN |
| typedef _db_code_state_ | CODE_STATE |
Functions | |
| static void | perror () |
| IMPORT int | _sanity (const char *file, uint line) |
| static struct link * | ListAdd (struct link *, const char *, const char *) |
| static struct link * | ListDel (struct link *, const char *, const char *) |
| static struct link * | ListCopy (struct link *) |
| static void | FreeList (struct link *linkp) |
| static void | DBUGOpenFile (CODE_STATE *, const char *, const char *, int) |
| static void | DBUGCloseFile (CODE_STATE *cs, FILE *fp) |
| static void | PushState (CODE_STATE *cs) |
| static void | FreeState (CODE_STATE *cs, struct settings *state) |
| static BOOLEAN | DoTrace (CODE_STATE *cs) |
| static void | DoPrefix (CODE_STATE *cs, uint line) |
| static char * | DbugMalloc (size_t size) |
| static const char * | BaseName (const char *pathname) |
| static void | Indent (CODE_STATE *cs, int indent) |
| static BOOLEAN | InList (struct link *linkp, const char *cp) |
| static void | dbug_flush (CODE_STATE *) |
| static void | DbugExit (const char *why) |
| static const char * | DbugStrTok (const char *s) |
| static FILE * | OpenProfile (CODE_STATE *cs, const char *name) |
| static BOOLEAN | DoProfile (CODE_STATE *) |
| static unsigned long | Clock (void) |
| static CODE_STATE * | code_state (void) |
| void | _db_process_ (const char *name) |
| void | _db_set_ (CODE_STATE *cs, const char *control) |
| void | _db_push_ (const char *control) |
| void | _db_set_init_ (const char *control) |
| void | _db_pop_ () |
| int | _db_explain_ (CODE_STATE *cs, char *buf, int len) |
| int | _db_explain_init_ (char *buf, int len) |
| void | _db_enter_ (const char *_func_, const char *_file_, uint _line_, const char **_sfunc_, const char **_sfile_, uint *_slevel_, char ***_sframep_ __attribute__((unused))) |
| void | _db_return_ (uint _line_, const char **_sfunc_, const char **_sfile_, uint *_slevel_) |
| void | _db_pargs_ (uint _line_, const char *keyword) |
| void | _db_doprnt_ (const char *format,...) |
| void | _db_dump_ (uint _line_, const char *keyword, const char *memory, uint length) |
| void | _db_end_ () |
| FILE * | _db_fp_ (void) |
| BOOLEAN | _db_strict_keyword_ (const char *keyword) |
| BOOLEAN | _db_keyword_ (CODE_STATE *cs, const char *keyword) |
| static void | perror (char *s) |
| void | _db_lock_file_ () |
| void | _db_unlock_file_ () |
Variables | |
| static BOOLEAN | init_done = FALSE |
| static struct settings | init_settings |
| static const char * | db_process = 0 |
| static CODE_STATE | static_code_state |
| #define ChangeOwner | ( | cs, | |||
| name | ) |
| #define char_to_buf | ( | C | ) |
| #define colon_to_buf |
Value:
do { \ if (buf != start) char_to_buf(':'); \ } while(0)
| #define DEBUG_ON 000002 |
| #define DEBUGGING (cs->stack->flags & DEBUG_ON) |
Definition at line 116 of file dbug.c.
Referenced by _db_explain_(), _db_keyword_(), _db_set_(), and _db_strict_keyword_().
| #define Delay | ( | A | ) | (0) |
| #define DEPTH_ON 000020 |
| #define ERR_ABORT "%s: debugger aborting because %s\n" |
| #define ERR_CLOSE "%s: can't close debug file: " |
| #define ERR_MISSING_RETURN "%s: missing DBUG_RETURN or DBUG_VOID_RETURN macro in function \"%s\"\n" |
| #define ERR_OPEN "%s: can't open debug output stream \"%s\": " |
Definition at line 298 of file dbug.c.
Referenced by dbug_flush(), DBUGOpenFile(), and OpenProfile().
| #define EXISTS | ( | pathname | ) | (FALSE) |
| #define FILE_ON 000004 |
| #define FLUSH_ON_WRITE 004000 |
Definition at line 112 of file dbug.c.
Referenced by _db_explain_(), _db_set_(), dbug_flush(), and DBUGOpenFile().
| #define get_code_state_or_return if (!cs && !((cs=code_state()))) return |
Definition at line 248 of file dbug.c.
Referenced by _db_doprnt_(), _db_dump_(), _db_end_(), _db_enter_(), _db_explain_(), _db_fp_(), _db_keyword_(), _db_lock_file_(), _db_pargs_(), _db_pop_(), _db_process_(), _db_push_(), _db_return_(), _db_set_(), _db_strict_keyword_(), and _db_unlock_file_().
| #define INDENT 2 |
| #define int_to_buf | ( | i | ) |
Value:
do { \ char b[50]; \ int10_to_str((i), b, 10); \ str_to_buf(b); \ } while (0)
| #define is_shared | ( | S, | |||
| V | ) | ((S)->next && (S)->next->V == (S)->V) |
| #define LINE_ON 000010 |
| #define list_to_buf | ( | l | ) |
| #define MAXDEPTH 200 |
| #define NUMBER_ON 000100 |
| #define op_bool_to_buf | ( | C, | |||
| cond | ) |
Value:
do { \ if ((cond)) \ { \ colon_to_buf; \ char_to_buf((C)); \ } \ } while (0)
Definition at line 823 of file dbug.c.
Referenced by _db_explain_().
| #define op_int_to_buf | ( | C, | |||
| val, | |||||
| def | ) |
Value:
do { \ if ((val) != (def)) \ { \ colon_to_buf; \ char_to_buf((C)); \ int_to_buf(val); \ } \ } while (0)
Definition at line 790 of file dbug.c.
Referenced by _db_explain_().
| #define op_intf_to_buf | ( | C, | |||
| val, | |||||
| def, | |||||
| cond | ) |
Value:
do { \ if ((cond)) \ { \ colon_to_buf; \ char_to_buf((C)); \ if ((val) != (def)) int_to_buf(val); \ } \ } while (0)
Definition at line 798 of file dbug.c.
Referenced by _db_explain_().
| #define op_list_to_buf | ( | C, | |||
| val, | |||||
| cond | ) |
Value:
do { \ if ((cond)) \ { \ colon_to_buf; \ char_to_buf((C)); \ list_to_buf(val); \ } \ } while (0)
Definition at line 815 of file dbug.c.
Referenced by _db_explain_().
| #define op_str_to_buf | ( | C, | |||
| val, | |||||
| cond | ) |
Value:
do { \ if ((cond)) \ { \ char *s=(val); \ colon_to_buf; \ char_to_buf((C)); \ if (*s) str_to_buf(s); \ } \ } while (0)
Definition at line 806 of file dbug.c.
Referenced by _db_explain_().
| #define OPEN_APPEND 010000 |
| #define PID_ON 000400 |
| #define PROCESS_ON 000040 |
| #define PROF_EFMT "E\t%ld\t%s\n" |
| #define PROF_FILE "dbugmon.out" |
| #define PROF_SFMT "S\t%lx\t%lx\t%s\n" |
| #define PROF_XFMT "X\t%ld\t%s\n" |
| #define PROFILE_ON 000200 |
| #define PROFILING (cs->stack->flags & PROFILE_ON) |
| #define REGISTER register |
Definition at line 136 of file dbug.c.
Referenced by DBUGOpenFile(), FreeList(), Indent(), InList(), and OpenProfile().
| #define SANITY_CHECK_ON 002000 |
Definition at line 111 of file dbug.c.
Referenced by _db_enter_(), _db_explain_(), _db_return_(), and _db_set_().
| #define str_to_buf | ( | S | ) |
| #define TIMESTAMP_ON 001000 |
| #define TRACE_ON 000001 |
| #define TRACING (cs->stack->flags & TRACE_ON) |
Definition at line 115 of file dbug.c.
Referenced by _db_doprnt_(), _db_dump_(), _db_explain_(), _db_keyword_(), and DoTrace().
| #define Writable | ( | name | ) | (TRUE) |
| typedef struct _db_code_state_ CODE_STATE |
| void _db_doprnt_ | ( | const char * | format, | |
| ... | ||||
| ) |
Definition at line 1114 of file dbug.c.
References _db_keyword_(), args, dbug_flush(), DoPrefix(), errno, get_code_state_or_return, Indent(), _db_code_state_::level, _db_code_state_::locked, pthread_mutex_lock, TRACING, _db_code_state_::u_keyword, and _db_code_state_::u_line.
01115 { 01116 va_list args; 01117 01118 CODE_STATE *cs=0; 01119 get_code_state_or_return; 01120 01121 va_start(args,format); 01122 01123 if (_db_keyword_(cs, cs->u_keyword)) 01124 { 01125 int save_errno=errno; 01126 if (!cs->locked) 01127 pthread_mutex_lock(&THR_LOCK_dbug); 01128 DoPrefix(cs, cs->u_line); 01129 if (TRACING) 01130 Indent(cs, cs->level + 1); 01131 else 01132 (void) fprintf(cs->stack->out_file, "%s: ", cs->func); 01133 (void) fprintf(cs->stack->out_file, "%s: ", cs->u_keyword); 01134 (void) vfprintf(cs->stack->out_file, format, args); 01135 (void) fputc('\n',cs->stack->out_file); 01136 dbug_flush(cs); 01137 errno=save_errno; 01138 } 01139 va_end(args); 01140 }
Here is the call graph for this function:

Definition at line 1161 of file dbug.c.
References _db_keyword_(), _dig_vec_upper, dbug_flush(), DoPrefix(), _db_code_state_::func, get_code_state_or_return, INDENT, Indent(), _db_code_state_::level, _db_code_state_::locked, max, min, settings::out_file, pos(), pthread_mutex_lock, _db_code_state_::stack, and TRACING.
01162 { 01163 int pos; 01164 char dbuff[90]; 01165 01166 CODE_STATE *cs=0; 01167 get_code_state_or_return; 01168 01169 if (_db_keyword_(cs, (char*) keyword)) 01170 { 01171 if (!cs->locked) 01172 pthread_mutex_lock(&THR_LOCK_dbug); 01173 DoPrefix(cs, _line_); 01174 if (TRACING) 01175 { 01176 Indent(cs, cs->level + 1); 01177 pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80); 01178 } 01179 else 01180 { 01181 fprintf(cs->stack->out_file, "%s: ", cs->func); 01182 } 01183 sprintf(dbuff,"%s: Memory: 0x%lx Bytes: (%d)\n", 01184 keyword,(ulong) memory, length); 01185 (void) fputs(dbuff,cs->stack->out_file); 01186 01187 pos=0; 01188 while (length-- > 0) 01189 { 01190 uint tmp= *((unsigned char*) memory++); 01191 if ((pos+=3) >= 80) 01192 { 01193 fputc('\n',cs->stack->out_file); 01194 pos=3; 01195 } 01196 fputc(_dig_vec_upper[((tmp >> 4) & 15)], cs->stack->out_file); 01197 fputc(_dig_vec_upper[tmp & 15], cs->stack->out_file); 01198 fputc(' ',cs->stack->out_file); 01199 } 01200 (void) fputc('\n',cs->stack->out_file); 01201 dbug_flush(cs); 01202 } 01203 }
Here is the call graph for this function:

| void _db_end_ | ( | void | ) |
Definition at line 1473 of file dbug.c.
References FreeState(), get_code_state_or_return, init_settings, settings::next, NULL, and _db_code_state_::stack.
01474 { 01475 struct settings *discard; 01476 CODE_STATE *cs=0; 01477 01478 get_code_state_or_return; 01479 01480 while((discard= cs->stack) != NULL) { 01481 if(discard == &init_settings) 01482 break; 01483 cs->stack= discard->next; 01484 FreeState (cs, discard); 01485 } 01486 }
Here is the call graph for this function:

| void _db_enter_ | ( | const char * | _func_, | |
| const char * | _file_, | |||
| uint | _line_, | |||
| const char ** | _sfunc_, | |||
| const char ** | _sfile_, | |||
| uint * | _slevel_, | |||
| char ***_sframep_ | __attribute__((unused)) | |||
| ) |
Definition at line 934 of file dbug.c.
References _sanity(), Clock(), dbug_flush(), DoPrefix(), DoProfile(), DoTrace(), errno, _db_code_state_::file, _db_code_state_::framep, _db_code_state_::func, get_code_state_or_return, Indent(), _db_code_state_::level, NULL, PROF_EFMT, PROF_SFMT, pthread_mutex_lock, and SANITY_CHECK_ON.
00937 { 00938 int save_errno=errno; 00939 CODE_STATE *cs=0; 00940 get_code_state_or_return; 00941 00942 *_sfunc_= cs->func; 00943 *_sfile_= cs->file; 00944 cs->func= _func_; 00945 cs->file= _file_; 00946 *_slevel_= ++cs->level; 00947 #ifndef THREAD 00948 *_sframep_= cs->framep; 00949 cs->framep= (char **) _sframep_; 00950 if (DoProfile(cs)) 00951 { 00952 long stackused; 00953 if (*cs->framep == NULL) 00954 stackused= 0; 00955 else 00956 { 00957 stackused= ((long)(*cs->framep)) - ((long)(cs->framep)); 00958 stackused= stackused > 0 ? stackused : -stackused; 00959 } 00960 (void) fprintf(cs->stack->prof_file, PROF_EFMT , Clock(), cs->func); 00961 #ifdef AUTOS_REVERSE 00962 (void) fprintf(cs->stack->prof_file, PROF_SFMT, cs->framep, stackused, *_sfunc_); 00963 #else 00964 (void) fprintf(cs->stack->prof_file, PROF_SFMT, (ulong) cs->framep, stackused, 00965 cs->func); 00966 #endif 00967 (void) fflush(cs->stack->prof_file); 00968 } 00969 #endif 00970 if (DoTrace(cs)) 00971 { 00972 if (!cs->locked) 00973 pthread_mutex_lock(&THR_LOCK_dbug); 00974 DoPrefix(cs, _line_); 00975 Indent(cs, cs->level); 00976 (void) fprintf(cs->stack->out_file, ">%s\n", cs->func); 00977 dbug_flush(cs); /* This does a unlock */ 00978 } 00979 #ifdef SAFEMALLOC 00980 if (cs->stack->flags & SANITY_CHECK_ON) 00981 if (_sanity(_file_,_line_)) /* Check of safemalloc */ 00982 cs->stack->flags &= ~SANITY_CHECK_ON; 00983 #endif 00984 errno=save_errno; 00985 }
Here is the call graph for this function:

| int _db_explain_ | ( | CODE_STATE * | cs, | |
| char * | buf, | |||
| int | len | |||
| ) |
Definition at line 831 of file dbug.c.
References DEBUGGING, settings::delay, DEPTH_ON, FILE_ON, settings::flags, FLUSH_ON_WRITE, settings::functions, get_code_state_or_return, settings::keywords, LINE_ON, MAXDEPTH, settings::maxdepth, settings::name, NUMBER_ON, op_bool_to_buf, op_int_to_buf, op_intf_to_buf, op_list_to_buf, op_str_to_buf, OPEN_APPEND, settings::out_file, settings::p_functions, PID_ON, PROCESS_ON, settings::processes, PROFILING, SANITY_CHECK_ON, _db_code_state_::stack, start(), settings::sub_level, TIMESTAMP_ON, and TRACING.
00832 { 00833 char *start=buf, *end=buf+len-4; 00834 00835 get_code_state_or_return *buf=0; 00836 00837 op_list_to_buf('d', cs->stack->keywords, DEBUGGING); 00838 op_int_to_buf ('D', cs->stack->delay, 0); 00839 op_list_to_buf('f', cs->stack->functions, cs->stack->functions); 00840 op_bool_to_buf('F', cs->stack->flags & FILE_ON); 00841 op_bool_to_buf('i', cs->stack->flags & PID_ON); 00842 op_list_to_buf('g', cs->stack->p_functions, PROFILING); 00843 op_bool_to_buf('L', cs->stack->flags & LINE_ON); 00844 op_bool_to_buf('n', cs->stack->flags & DEPTH_ON); 00845 op_bool_to_buf('N', cs->stack->flags & NUMBER_ON); 00846 op_str_to_buf( 00847 ((cs->stack->flags & FLUSH_ON_WRITE ? 0 : 32) | 00848 (cs->stack->flags & OPEN_APPEND ? 'A' : 'O')), 00849 cs->stack->name, cs->stack->out_file != stderr); 00850 op_list_to_buf('p', cs->stack->processes, cs->stack->processes); 00851 op_bool_to_buf('P', cs->stack->flags & PROCESS_ON); 00852 op_bool_to_buf('r', cs->stack->sub_level != 0); 00853 op_intf_to_buf('t', cs->stack->maxdepth, MAXDEPTH, TRACING); 00854 op_bool_to_buf('T', cs->stack->flags & TIMESTAMP_ON); 00855 op_bool_to_buf('S', cs->stack->flags & SANITY_CHECK_ON); 00856 00857 *buf= '\0'; 00858 return 0; 00859 00860 overflow: 00861 *end++= '.'; 00862 *end++= '.'; 00863 *end++= '.'; 00864 *end= '\0'; 00865 return 1; 00866 }
Here is the call graph for this function:

| int _db_explain_init_ | ( | char * | buf, | |
| int | len | |||
| ) |
Definition at line 888 of file dbug.c.
References _db_explain_(), bzero, and init_settings.
00889 { 00890 CODE_STATE cs; 00891 bzero((char*) &cs,sizeof(cs)); 00892 cs.stack=&init_settings; 00893 return _db_explain_(&cs, buf, len); 00894 }
Here is the call graph for this function:

| FILE* _db_fp_ | ( | void | ) |
Definition at line 1545 of file dbug.c.
References get_code_state_or_return, NULL, settings::out_file, and _db_code_state_::stack.
01546 { 01547 CODE_STATE *cs=0; 01548 get_code_state_or_return NULL; 01549 return cs->stack->out_file; 01550 }
| BOOLEAN _db_keyword_ | ( | CODE_STATE * | cs, | |
| const char * | keyword | |||
| ) |
Definition at line 1607 of file dbug.c.
References DEBUGGING, FALSE, _db_code_state_::func, settings::functions, get_code_state_or_return, InList(), settings::keywords, _db_code_state_::level, settings::maxdepth, _db_code_state_::process, settings::processes, _db_code_state_::stack, and TRACING.
01608 { 01609 get_code_state_or_return FALSE; 01610 01611 return (DEBUGGING && 01612 (!TRACING || cs->level <= cs->stack->maxdepth) && 01613 InList(cs->stack->functions, cs->func) && 01614 InList(cs->stack->keywords, keyword) && 01615 InList(cs->stack->processes, cs->process)); 01616 }
Here is the call graph for this function:

| void _db_lock_file_ | ( | void | ) |
Definition at line 2236 of file dbug.c.
References get_code_state_or_return, _db_code_state_::locked, and pthread_mutex_lock.
02237 { 02238 CODE_STATE *cs=0; 02239 get_code_state_or_return; 02240 pthread_mutex_lock(&THR_LOCK_dbug); 02241 cs->locked=1; 02242 }
| void _db_pargs_ | ( | uint | _line_, | |
| const char * | keyword | |||
| ) |
Definition at line 1079 of file dbug.c.
References get_code_state_or_return, _db_code_state_::u_keyword, and _db_code_state_::u_line.
01080 { 01081 CODE_STATE *cs=0; 01082 get_code_state_or_return; 01083 cs->u_line= _line_; 01084 cs->u_keyword= (char*) keyword; 01085 }
| void _db_pop_ | ( | void | ) |
Definition at line 738 of file dbug.c.
References FreeState(), get_code_state_or_return, settings::next, NULL, and _db_code_state_::stack.
00739 { 00740 struct settings *discard; 00741 CODE_STATE *cs=0; 00742 00743 get_code_state_or_return; 00744 00745 discard= cs->stack; 00746 if (discard->next != NULL) 00747 { 00748 cs->stack= discard->next; 00749 FreeState(cs, discard); 00750 } 00751 }
Here is the call graph for this function:

| void _db_process_ | ( | const char * | name | ) |
Definition at line 404 of file dbug.c.
References db_process, get_code_state_or_return, and _db_code_state_::process.
00405 { 00406 CODE_STATE *cs=0; 00407 00408 if (!db_process) 00409 db_process= name; 00410 00411 get_code_state_or_return; 00412 cs->process= name; 00413 }
| void _db_push_ | ( | const char * | control | ) |
Definition at line 690 of file dbug.c.
References _db_set_(), get_code_state_or_return, and PushState().
00691 { 00692 CODE_STATE *cs=0; 00693 get_code_state_or_return; 00694 PushState(cs); 00695 _db_set_(cs, control); 00696 }
Here is the call graph for this function:

Definition at line 1010 of file dbug.c.
References _sanity(), Clock(), dbug_flush(), DoPrefix(), DoProfile(), DoTrace(), ERR_MISSING_RETURN, errno, _db_code_state_::file, settings::flags, _db_code_state_::framep, _db_code_state_::func, get_code_state_or_return, Indent(), _db_code_state_::level, _db_code_state_::locked, NULL, settings::out_file, _db_code_state_::process, settings::prof_file, PROF_XFMT, pthread_mutex_lock, SANITY_CHECK_ON, and _db_code_state_::stack.
01012 { 01013 int save_errno=errno; 01014 CODE_STATE *cs=0; 01015 get_code_state_or_return; 01016 01017 if (cs->level != (int) *_slevel_) 01018 { 01019 if (!cs->locked) 01020 pthread_mutex_lock(&THR_LOCK_dbug); 01021 (void) fprintf(cs->stack->out_file, ERR_MISSING_RETURN, cs->process, 01022 cs->func); 01023 dbug_flush(cs); 01024 } 01025 else 01026 { 01027 #ifdef SAFEMALLOC 01028 if (cs->stack->flags & SANITY_CHECK_ON) 01029 { 01030 if (_sanity(*_sfile_,_line_)) 01031 cs->stack->flags &= ~SANITY_CHECK_ON; 01032 } 01033 #endif 01034 #ifndef THREAD 01035 if (DoProfile(cs)) 01036 (void) fprintf(cs->stack->prof_file, PROF_XFMT, Clock(), cs->func); 01037 #endif 01038 if (DoTrace(cs)) 01039 { 01040 if (!cs->locked) 01041 pthread_mutex_lock(&THR_LOCK_dbug); 01042 DoPrefix(cs, _line_); 01043 Indent(cs, cs->level); 01044 (void) fprintf(cs->stack->out_file, "<%s\n", cs->func); 01045 dbug_flush(cs); 01046 } 01047 } 01048 cs->level= *_slevel_-1; 01049 cs->func= *_sfunc_; 01050 cs->file= *_sfile_; 01051 #ifndef THREAD 01052 if (cs->framep != NULL) 01053 cs->framep= (char **) *cs->framep; 01054 #endif 01055 errno=save_errno; 01056 }
Here is the call graph for this function:

| void _db_set_ | ( | CODE_STATE * | cs, | |
| const char * | control | |||
| ) |
Definition at line 447 of file dbug.c.
References atoi(), DBUGCloseFile(), DBUGOpenFile(), DbugStrTok(), DEBUG_ON, DEBUGGING, settings::delay, DEPTH_ON, FILE_ON, settings::flags, FLUSH_ON_WRITE, FreeList(), functions, settings::functions, get_code_state_or_return, init_settings, is_shared, settings::keywords, LINE_ON, ListAdd(), ListCopy(), ListDel(), MAXDEPTH, settings::maxdepth, settings::name, settings::next, NULL, NUMBER_ON, OPEN_APPEND, OpenProfile(), settings::out_file, settings::p_functions, PID_ON, PROCESS_ON, settings::processes, PROF_FILE, settings::prof_file, PROFILE_ON, SANITY_CHECK_ON, _db_code_state_::stack, settings::sub_level, TIMESTAMP_ON, and TRACE_ON.
00448 { 00449 const char *end; 00450 int rel=0; 00451 00452 get_code_state_or_return; 00453 00454 if (control[0] == '-' && control[1] == '#') 00455 control+=2; 00456 00457 rel= control[0] == '+' || control[0] == '-'; 00458 if (!rel || (!cs->stack->out_file && !cs->stack->next)) 00459 { 00460 cs->stack->flags= 0; 00461 cs->stack->delay= 0; 00462 cs->stack->maxdepth= 0; 00463 cs->stack->sub_level= 0; 00464 cs->stack->out_file= stderr; 00465 cs->stack->prof_file= NULL; 00466 cs->stack->functions= NULL; 00467 cs->stack->p_functions= NULL; 00468 cs->stack->keywords= NULL; 00469 cs->stack->processes= NULL; 00470 } 00471 else if (!cs->stack->out_file) 00472 { 00473 cs->stack->flags= cs->stack->next->flags; 00474 cs->stack->delay= cs->stack->next->delay; 00475 cs->stack->maxdepth= cs->stack->next->maxdepth; 00476 cs->stack->sub_level= cs->stack->next->sub_level; 00477 strcpy(cs->stack->name, cs->stack->next->name); 00478 cs->stack->out_file= cs->stack->next->out_file; 00479 cs->stack->prof_file= cs->stack->next->prof_file; 00480 if (cs->stack->next == &init_settings) 00481 { 00482 /* never share with the global parent - it can change under your feet */ 00483 cs->stack->functions= ListCopy(init_settings.functions); 00484 cs->stack->p_functions= ListCopy(init_settings.p_functions); 00485 cs->stack->keywords= ListCopy(init_settings.keywords); 00486 cs->stack->processes= ListCopy(init_settings.processes); 00487 } 00488 else 00489 { 00490 cs->stack->functions= cs->stack->next->functions; 00491 cs->stack->p_functions= cs->stack->next->p_functions; 00492 cs->stack->keywords= cs->stack->next->keywords; 00493 cs->stack->processes= cs->stack->next->processes; 00494 } 00495 } 00496 00497 end= DbugStrTok(control); 00498 while (1) 00499 { 00500 int c, sign= (*control == '+') ? 1 : (*control == '-') ? -1 : 0; 00501 if (sign) control++; 00502 if (!rel) sign=0; 00503 c= *control++; 00504 if (*control == ',') control++; 00505 /* XXX when adding new cases here, don't forget _db_explain_ ! */ 00506 switch (c) { 00507 case 'd': 00508 if (sign < 0 && control == end) 00509 { 00510 if (!is_shared(cs->stack, keywords)) 00511 FreeList(cs->stack->keywords); 00512 cs->stack->keywords=NULL; 00513 cs->stack->flags &= ~DEBUG_ON; 00514 break; 00515 } 00516 if (rel && is_shared(cs->stack, keywords)) 00517 cs->stack->keywords= ListCopy(cs->stack->keywords); 00518 if (sign < 0) 00519 { 00520 if (DEBUGGING) 00521 cs->stack->keywords= ListDel(cs->stack->keywords, control, end); 00522 break; 00523 } 00524 cs->stack->keywords= ListAdd(cs->stack->keywords, control, end); 00525 cs->stack->flags |= DEBUG_ON; 00526 break; 00527 case 'D': 00528 cs->stack->delay= atoi(control); 00529 break; 00530 case 'f': 00531 if (sign < 0 && control == end) 00532 { 00533 if (!is_shared(cs->stack,functions)) 00534 FreeList(cs->stack->functions); 00535 cs->stack->functions=NULL; 00536 break; 00537 } 00538 if (rel && is_shared(cs->stack,functions)) 00539 cs->stack->functions= ListCopy(cs->stack->functions); 00540 if (sign < 0) 00541 cs->stack->functions= ListDel(cs->stack->functions, control, end); 00542 else 00543 cs->stack->functions= ListAdd(cs->stack->functions, control, end); 00544 break; 00545 case 'F': 00546 if (sign < 0) 00547 cs->stack->flags &= ~FILE_ON; 00548 else 00549 cs->stack->flags |= FILE_ON; 00550 break; 00551 case 'i': 00552 if (sign < 0) 00553 cs->stack->flags &= ~PID_ON; 00554 else 00555 cs->stack->flags |= PID_ON; 00556 break; 00557 #ifndef THREAD 00558 case 'g': 00559 if (OpenProfile(cs, PROF_FILE)) 00560 { 00561 cs->stack->flags |= PROFILE_ON; 00562 cs->stack->p_functions= ListAdd(cs->stack->p_functions, control, end); 00563 } 00564 break; 00565 #endif 00566 case 'L': 00567 if (sign < 0) 00568 cs->stack->flags &= ~LINE_ON; 00569 else 00570 cs->stack->flags |= LINE_ON; 00571 break; 00572 case 'n': 00573 if (sign < 0) 00574 cs->stack->flags &= ~DEPTH_ON; 00575 else 00576 cs->stack->flags |= DEPTH_ON; 00577 break; 00578 case 'N': 00579 if (sign < 0) 00580 cs->stack->flags &= ~NUMBER_ON; 00581 else 00582 cs->stack->flags |= NUMBER_ON; 00583 break; 00584 case 'A': 00585 case 'O': 00586 cs->stack->flags |= FLUSH_ON_WRITE; 00587 /* fall through */ 00588 case 'a': 00589 case 'o': 00590 if (sign < 0) 00591 { 00592 if (!is_shared(cs->stack, out_file)) 00593 DBUGCloseFile(cs, cs->stack->out_file); 00594 cs->stack->flags &= ~FLUSH_ON_WRITE; 00595 cs->stack->out_file= stderr; 00596 break; 00597 } 00598 if (c == 'a' || c == 'A') 00599 cs->stack->flags |= OPEN_APPEND; 00600 else 00601 cs->stack->flags &= ~OPEN_APPEND; 00602 if (control != end) 00603 DBUGOpenFile(cs, control, end, cs->stack->flags & OPEN_APPEND); 00604 else 00605 DBUGOpenFile(cs, "-",0,0); 00606 break; 00607 case 'p': 00608 if (sign < 0 && control == end) 00609 { 00610 if (!is_shared(cs->stack,processes)) 00611 FreeList(cs->stack->processes); 00612 cs->stack->processes=NULL; 00613 break; 00614 } 00615 if (rel && is_shared(cs->stack, processes)) 00616 cs->stack->processes= ListCopy(cs->stack->processes); 00617 if (sign < 0) 00618 cs->stack->processes= ListDel(cs->stack->processes, control, end); 00619 else 00620 cs->stack->processes= ListAdd(cs->stack->processes, control, end); 00621 break; 00622 case 'P': 00623 if (sign < 0) 00624 cs->stack->flags &= ~PROCESS_ON; 00625 else 00626 cs->stack->flags |= PROCESS_ON; 00627 break; 00628 case 'r': 00629 cs->stack->sub_level= cs->level; 00630 break; 00631 case 't': 00632 if (sign < 0) 00633 { 00634 if (control != end) 00635 cs->stack->maxdepth-= atoi(control); 00636 else 00637 cs->stack->maxdepth= 0; 00638 } 00639 else 00640 { 00641 if (control != end) 00642 cs->stack->maxdepth+= atoi(control); 00643 else 00644 cs->stack->maxdepth= MAXDEPTH; 00645 } 00646 if (cs->stack->maxdepth > 0) 00647 cs->stack->flags |= TRACE_ON; 00648 else 00649 cs->stack->flags &= ~TRACE_ON; 00650 break; 00651 case 'T': 00652 if (sign < 0) 00653 cs->stack->flags &= ~TIMESTAMP_ON; 00654 else 00655 cs->stack->flags |= TIMESTAMP_ON; 00656 break; 00657 case 'S': 00658 if (sign < 0) 00659 cs->stack->flags &= ~SANITY_CHECK_ON; 00660 else 00661 cs->stack->flags |= SANITY_CHECK_ON; 00662 break; 00663 } 00664 if (!*end) 00665 break; 00666 control=end+1; 00667 end= DbugStrTok(control); 00668 } 00669 }
Here is the call graph for this function:

| void _db_set_init_ | ( | const char * | control | ) |
Definition at line 713 of file dbug.c.
References _db_set_(), bzero, and init_settings.
00714 { 00715 CODE_STATE cs; 00716 bzero((char*) &cs,sizeof(cs)); 00717 cs.stack=&init_settings; 00718 _db_set_(&cs, control); 00719 }
Here is the call graph for this function:

| BOOLEAN _db_strict_keyword_ | ( | const char * | keyword | ) |
Definition at line 1573 of file dbug.c.
References _db_keyword_(), DEBUGGING, FALSE, get_code_state_or_return, settings::keywords, NULL, and _db_code_state_::stack.
01574 { 01575 CODE_STATE *cs=0; 01576 get_code_state_or_return FALSE; 01577 if (!DEBUGGING || cs->stack->keywords == NULL) 01578 return FALSE; 01579 return _db_keyword_(cs, keyword); 01580 }
Here is the call graph for this function:

| void _db_unlock_file_ | ( | void | ) |
Definition at line 2244 of file dbug.c.
References get_code_state_or_return, _db_code_state_::locked, and pthread_mutex_unlock.
02245 { 02246 CODE_STATE *cs=0; 02247 get_code_state_or_return; 02248 cs->locked=0; 02249 pthread_mutex_unlock(&THR_LOCK_dbug); 02250 }
| IMPORT int _sanity | ( | const char * | file, | |
| uint | line | |||
| ) |
Definition at line 477 of file safemalloc.c.
00478 { 00479 reg1 struct st_irem *irem; 00480 reg2 int flag=0; 00481 uint count=0; 00482 00483 pthread_mutex_lock(&THR_LOCK_malloc); 00484 #ifndef PEDANTIC_SAFEMALLOC 00485 if (sf_malloc_tampered && (int) sf_malloc_count < 0) 00486 sf_malloc_count=0; 00487 #endif 00488 count=sf_malloc_count; 00489 for (irem= sf_malloc_root; irem != NULL && count-- ; irem= irem->next) 00490 flag+= _checkchunk (irem, filename, lineno); 00491 pthread_mutex_unlock(&THR_LOCK_malloc); 00492 if (count || irem) 00493 { 00494 const char *format="Error: Safemalloc link list destroyed, discovered at '%s:%d'"; 00495 fprintf(stderr, format, filename, lineno); fputc('\n',stderr); 00496 fprintf(stderr, "root=%p,count=%d,irem=%p\n", sf_malloc_root,count,irem); 00497 (void) fflush(stderr); 00498 DBUG_PRINT("safe",(format, filename, lineno)); 00499 flag=1; 00500 } 00501 return flag; 00502 } /* _sanity */
| static const char * BaseName | ( | const char * | pathname | ) | [static] |
Definition at line 2007 of file dbug.c.
References FN_LIBCHAR, NullS, and strrchr().
Referenced by DoPrefix().
02008 { 02009 register const char *base; 02010 02011 base= strrchr(pathname, FN_LIBCHAR); 02012 if (base++ == NullS) 02013 base= pathname; 02014 return base; 02015 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static unsigned long Clock | ( | void | ) | [static] |
Definition at line 2320 of file dbug.c.
Referenced by _db_enter_(), and _db_return_().
Here is the caller graph for this function:

| static CODE_STATE* code_state | ( | void | ) | [static] |
Definition at line 365 of file dbug.c.
References bzero, init_done, init_settings, OPEN_APPEND, static_code_state, and TRUE.
Referenced by DbugExit().
00366 { 00367 if (!init_done) 00368 { 00369 bzero(&init_settings, sizeof(init_settings)); 00370 init_settings.out_file=stderr; 00371 init_settings.flags=OPEN_APPEND; 00372 init_done=TRUE; 00373 } 00374 return &static_code_state; 00375 }
Here is the caller graph for this function:

| static void dbug_flush | ( | CODE_STATE * | ) | [static] |
Definition at line 2207 of file dbug.c.
References Delay, settings::delay, ERR_OPEN, settings::flags, FLUSH_ON_WRITE, _db_code_state_::locked, settings::name, settings::out_file, _db_code_state_::process, pthread_mutex_unlock, and _db_code_state_::stack.
Referenced by _db_doprnt_(), _db_dump_(), _db_enter_(), _db_return_(), DBUGCloseFile(), and OpenProfile().
02208 { 02209 #ifndef THREAD 02210 if (cs->stack->flags & FLUSH_ON_WRITE) 02211 #endif 02212 { 02213 #if defined(MSDOS) || defined(__WIN__) 02214 if (cs->stack->out_file != stdout && cs->stack->out_file != stderr) 02215 { 02216 if (!(freopen(cs->stack->name,"a",cs->stack->out_file))) 02217 { 02218 (void) fprintf(stderr, ERR_OPEN, cs->process, cs->stack->name); 02219 fflush(stderr); 02220 cs->stack->out_file= stderr; 02221 } 02222 } 02223 else 02224 #endif 02225 { 02226 (void) fflush(cs->stack->out_file); 02227 if (cs->stack->delay) 02228 (void) Delay(cs->stack->delay); 02229 } 02230 } 02231 if (!cs->locked) 02232 pthread_mutex_unlock(&THR_LOCK_dbug); 02233 } /* dbug_flush */
Here is the caller graph for this function:

| static void DBUGCloseFile | ( | CODE_STATE * | cs, | |
| FILE * | fp | |||
| ) | [static] |
Definition at line 1906 of file dbug.c.
References dbug_flush(), ERR_CLOSE, settings::out_file, perror(), _db_code_state_::process, pthread_mutex_lock, and _db_code_state_::stack.
Referenced by _db_set_(), and FreeState().
01907 { 01908 if (fp != stderr && fp != stdout && fclose(fp) == EOF) 01909 { 01910 pthread_mutex_lock(&THR_LOCK_dbug); 01911 (void) fprintf(cs->stack->out_file, ERR_CLOSE, cs->process); 01912 perror(""); 01913 dbug_flush(0); 01914 } 01915 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void DbugExit | ( | const char * | why | ) | [static] |
Definition at line 1937 of file dbug.c.
References code_state(), ERR_ABORT, exit, and _db_code_state_::process.
Referenced by DbugMalloc().
01938 { 01939 CODE_STATE *cs=code_state(); 01940 (void) fprintf(stderr, ERR_ABORT, cs ? cs->process : "(null)", why); 01941 (void) fflush(stderr); 01942 exit(1); 01943 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static char * DbugMalloc | ( | size_t | size | ) | [static] |
Definition at line 1967 of file dbug.c.
References DbugExit(), and malloc.
Referenced by ListAdd(), ListCopy(), and PushState().
01968 { 01969 register char *new_malloc; 01970 01971 if (!(new_malloc= (char*) malloc((size_t) size))) 01972 DbugExit("out of memory"); 01973 return new_malloc; 01974 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void DBUGOpenFile | ( | CODE_STATE * | , | |
| const char * | , | |||
| const char * | , | |||
| int | ||||
| ) | [static] |
Definition at line 1773 of file dbug.c.
References TaoCrypt::BOOLEAN, ChangeOwner, ERR_OPEN, EXISTS, settings::flags, FLUSH_ON_WRITE, memcpy, settings::name, NULL, settings::out_file, perror(), _db_code_state_::process, REGISTER, _db_code_state_::stack, strcmp(), strmov(), and Writable.
Referenced by _db_set_().
01775 { 01776 REGISTER FILE *fp; 01777 REGISTER BOOLEAN newfile; 01778 01779 if (name != NULL) 01780 { 01781 if (end) 01782 { 01783 int len=end-name; 01784 memcpy(cs->stack->name, name, len); 01785 cs->stack->name[len]=0; 01786 } 01787 else 01788 strmov(cs->stack->name,name); 01789 name=cs->stack->name; 01790 if (strcmp(name, "-") == 0) 01791 { 01792 cs->stack->out_file= stdout; 01793 cs->stack->flags |= FLUSH_ON_WRITE; 01794 cs->stack->name[0]=0; 01795 } 01796 else 01797 { 01798 if (!Writable((char*)name)) 01799 { 01800 (void) fprintf(stderr, ERR_OPEN, cs->process, name); 01801 perror(""); 01802 fflush(stderr); 01803 } 01804 else 01805 { 01806 newfile= !EXISTS(name); 01807 if (!(fp= fopen(name, append ? "a+" : "w"))) 01808 { 01809 (void) fprintf(stderr, ERR_OPEN, cs->process, name); 01810 perror(""); 01811 fflush(stderr); 01812 } 01813 else 01814 { 01815 cs->stack->out_file= fp; 01816 if (newfile) 01817 { 01818 ChangeOwner(cs, name); 01819 } 01820 } 01821 } 01822 } 01823 } 01824 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static const char * DbugStrTok | ( | const char * | s | ) | [static] |
Definition at line 1981 of file dbug.c.
Referenced by _db_set_().
01982 { 01983 while (s[0] && (s[0] != ':' || (s[1] == '\\' || s[1] == '/'))) 01984 s++; 01985 return s; 01986 }
Here is the caller graph for this function:

| static void DoPrefix | ( | CODE_STATE * | cs, | |
| uint | line | |||
| ) | [static] |
Definition at line 1703 of file dbug.c.
References BaseName(), DEPTH_ON, _db_code_state_::file, FILE_ON, settings::flags, _db_code_state_::level, LINE_ON, _db_code_state_::lineno, my_thread_name(), NULL, NUMBER_ON, settings::out_file, PID_ON, _db_code_state_::process, PROCESS_ON, _db_code_state_::stack, and TIMESTAMP_ON.
Referenced by _db_doprnt_(), _db_dump_(), _db_enter_(), and _db_return_().
01704 { 01705 cs->lineno++; 01706 if (cs->stack->flags & PID_ON) 01707 { 01708 #ifdef THREAD 01709 (void) fprintf(cs->stack->out_file, "%-7s: ", my_thread_name()); 01710 #else 01711 (void) fprintf(cs->stack->out_file, "%5d: ", (int) getpid()); 01712 #endif 01713 } 01714 if (cs->stack->flags & NUMBER_ON) 01715 (void) fprintf(cs->stack->out_file, "%5d: ", cs->lineno); 01716 if (cs->stack->flags & TIMESTAMP_ON) 01717 { 01718 #ifdef __WIN__ 01719 /* FIXME This doesn't give microseconds as in Unix case, and the resolution is 01720 in system ticks, 10 ms intervals. See my_getsystime.c for high res */ 01721 SYSTEMTIME loc_t; 01722 GetLocalTime(&loc_t); 01723 (void) fprintf (cs->stack->out_file, 01724 /* "%04d-%02d-%02d " */ 01725 "%02d:%02d:%02d.%06d ", 01726 /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/ 01727 loc_t.wHour, loc_t.wMinute, loc_t.wSecond, loc_t.wMilliseconds); 01728 #else 01729 struct timeval tv; 01730 struct tm *tm_p; 01731 if (gettimeofday(&tv, NULL) != -1) 01732 { 01733 if ((tm_p= localtime((const time_t *)&tv.tv_sec))) 01734 { 01735 (void) fprintf (cs->stack->out_file, 01736 /* "%04d-%02d-%02d " */ 01737 "%02d:%02d:%02d.%06d ", 01738 /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/ 01739 tm_p->tm_hour, tm_p->tm_min, tm_p->tm_sec, 01740 (int) (tv.tv_usec)); 01741 } 01742 } 01743 #endif 01744 } 01745 if (cs->stack->flags & PROCESS_ON) 01746 (void) fprintf(cs->stack->out_file, "%s: ", cs->process); 01747 if (cs->stack->flags & FILE_ON) 01748 (void) fprintf(cs->stack->out_file, "%14s: ", BaseName(cs->file)); 01749 if (cs->stack->flags & LINE_ON) 01750 (void) fprintf(cs->stack->out_file, "%5d: ", _line_); 01751 if (cs->stack->flags & DEPTH_ON) 01752 (void) fprintf(cs->stack->out_file, "%4d: ", cs->level); 01753 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static BOOLEAN DoProfile | ( | CODE_STATE * | ) | [static] |
Definition at line 1536 of file dbug.c.
References _db_code_state_::func, InList(), _db_code_state_::level, settings::maxdepth, settings::p_functions, _db_code_state_::process, settings::processes, PROFILING, and _db_code_state_::stack.
Referenced by _db_enter_(), and _db_return_().
01537 { 01538 return PROFILING && 01539 cs->level <= cs->stack->maxdepth && 01540 InList(cs->stack->p_functions, cs->func) && 01541 InList(cs->stack->processes, cs->process); 01542 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static BOOLEAN DoTrace | ( | CODE_STATE * | cs | ) | [static] |
Definition at line 1508 of file dbug.c.
References _db_code_state_::func, settings::functions, InList(), _db_code_state_::level, settings::maxdepth, _db_code_state_::process, settings::processes, _db_code_state_::stack, and TRACING.
Referenced by _db_enter_(), and _db_return_().
01509 { 01510 return (TRACING && cs->level <= cs->stack->maxdepth && 01511 InList(cs->stack->functions, cs->func) && 01512 InList(cs->stack->processes, cs->process)); 01513 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void FreeList | ( | struct link * | linkp | ) | [static] |
Definition at line 1671 of file dbug.c.
References free, link::next_link, NULL, and REGISTER.
Referenced by _db_set_(), and FreeState().
01672 { 01673 REGISTER struct link *old; 01674 01675 while (linkp != NULL) 01676 { 01677 old= linkp; 01678 linkp= linkp->next_link; 01679 free((char *) old); 01680 } 01681 }
Here is the caller graph for this function:

| static void FreeState | ( | CODE_STATE * | cs, | |
| struct settings * | state | |||
| ) | [static] |
Definition at line 1436 of file dbug.c.
References DBUGCloseFile(), free, FreeList(), settings::functions, functions, is_shared, settings::keywords, settings::out_file, settings::p_functions, settings::processes, and settings::prof_file.
Referenced by _db_end_(), and _db_pop_().
01439 { 01440 if (!is_shared(state, keywords)) 01441 FreeList(state->keywords); 01442 if (!is_shared(state, functions)) 01443 FreeList(state->functions); 01444 if (!is_shared(state, processes)) 01445 FreeList(state->processes); 01446 if (!is_shared(state, p_functions)) 01447 FreeList(state->p_functions); 01448 if (!is_shared(state, out_file)) 01449 DBUGCloseFile(cs, state->out_file); 01450 if (state->prof_file) 01451 DBUGCloseFile(cs, state->prof_file); 01452 free((char *) state); 01453 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void Indent | ( | CODE_STATE * | cs, | |
| int | indent | |||
| ) | [static] |
Definition at line 1639 of file dbug.c.
References count, INDENT, max, settings::out_file, REGISTER, _db_code_state_::stack, and settings::sub_level.
Referenced by _db_doprnt_(), _db_dump_(), _db_enter_(), and _db_return_().
01640 { 01641 REGISTER int count; 01642 01643 indent= max(indent-1-cs->stack->sub_level,0)*INDENT; 01644 for (count= 0; count < indent ; count++) 01645 { 01646 if ((count % INDENT) == 0) 01647 fputc('|',cs->stack->out_file); 01648 else 01649 fputc(' ',cs->stack->out_file); 01650 } 01651 }
Here is the caller graph for this function:

Definition at line 1367 of file dbug.c.
References TaoCrypt::BOOLEAN, FALSE, link::next_link, NULL, REGISTER, link::str, strcmp(), and TRUE.
Referenced by _db_keyword_(), DoProfile(), and DoTrace().
01368 { 01369 REGISTER struct link *scan; 01370 REGISTER BOOLEAN result; 01371 01372 if (linkp == NULL) 01373 result= TRUE; 01374 else 01375 { 01376 result= FALSE; 01377 for (scan= linkp; scan != NULL; scan= scan->next_link) 01378 { 01379 if (!strcmp(scan->str, cp)) 01380 { 01381 result= TRUE; 01382 break; 01383 } 01384 } 01385 } 01386 return result; 01387 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1230 of file dbug.c.
References DbugMalloc(), memcpy, link::next_link, start(), and link::str.
Referenced by _db_set_().
01232 { 01233 const char *start; 01234 struct link *new_malloc; 01235 int len; 01236 01237 while (ctlp < end) 01238 { 01239 start= ctlp; 01240 while (ctlp < end && *ctlp != ',') 01241 ctlp++; 01242 len=ctlp-start; 01243 new_malloc= (struct link *) DbugMalloc(sizeof(struct link)+len); 01244 memcpy(new_malloc->str, start, len); 01245 new_malloc->str[len]=0; 01246 new_malloc->next_link= head; 01247 head= new_malloc; 01248 ctlp++; 01249 } 01250 return head; 01251 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1323 of file dbug.c.
References DbugMalloc(), memcpy, link::next_link, NULL, link::str, and strlen().
Referenced by _db_set_().
01324 { 01325 struct link *new_malloc; 01326 struct link *head; 01327 int len; 01328 01329 head= NULL; 01330 while (orig != NULL) 01331 { 01332 len= strlen(orig->str); 01333 new_malloc= (struct link *) DbugMalloc(sizeof(struct link)+len); 01334 memcpy(new_malloc->str, orig->str, len); 01335 new_malloc->str[len]= 0; 01336 new_malloc->next_link= head; 01337 head= new_malloc; 01338 orig= orig->next_link; 01339 } 01340 return head; 01341 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1273 of file dbug.c.
References free, link::next_link, and start().
Referenced by _db_set_().
01275 { 01276 const char *start; 01277 struct link **cur; 01278 int len; 01279 01280 while (ctlp < end) 01281 { 01282 start= ctlp; 01283 while (ctlp < end && *ctlp != ',') 01284 ctlp++; 01285 len=ctlp-start; 01286 cur=&head; 01287 do 01288 { 01289 while (*cur && !strncmp((*cur)->str, start, len)) 01290 { 01291 struct link *delme=*cur; 01292 *cur=(*cur)->next_link; 01293 free((char*)delme); 01294 } 01295 } while (*cur && *(cur=&((*cur)->next_link))); 01296 } 01297 return head; 01298 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static FILE * OpenProfile | ( | CODE_STATE * | cs, | |
| const char * | name | |||
| ) | [static] |
Definition at line 1854 of file dbug.c.
References TaoCrypt::BOOLEAN, ChangeOwner, dbug_flush(), settings::delay, Delay, ERR_OPEN, EXISTS, settings::out_file, perror(), _db_code_state_::process, settings::prof_file, REGISTER, _db_code_state_::stack, and Writable.
Referenced by _db_set_().
01855 { 01856 REGISTER FILE *fp; 01857 REGISTER BOOLEAN newfile; 01858 01859 fp=0; 01860 if (!Writable(name)) 01861 { 01862 (void) fprintf(cs->stack->out_file, ERR_OPEN, cs->process, name); 01863 perror(""); 01864 dbug_flush(0); 01865 (void) Delay(cs->stack->delay); 01866 } 01867 else 01868 { 01869 newfile= !EXISTS(name); 01870 if (!(fp= fopen(name, "w"))) 01871 { 01872 (void) fprintf(cs->stack->out_file, ERR_OPEN, cs->process, name); 01873 perror(""); 01874 dbug_flush(0); 01875 } 01876 else 01877 { 01878 cs->stack->prof_file= fp; 01879 if (newfile) 01880 { 01881 ChangeOwner(cs, name); 01882 } 01883 } 01884 } 01885 return fp; 01886 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void perror | ( | char * | s | ) | [static] |
| static void perror | ( | ) | [static] |
Referenced by DBUGCloseFile(), DBUGOpenFile(), SHM_Transporter::disconnectImpl(), FileUnitTest::error(), fatal_error(), main(), my_crawl(), NDB_COMMAND(), SHM_Transporter::ndb_shm_attach(), SHM_Transporter::ndb_shm_create(), SHM_Transporter::ndb_shm_get(), open_log_file(), OpenProfile(), pstack_install_segv_action(), and sql_perror().
Here is the caller graph for this function:

| static void PushState | ( | CODE_STATE * | cs | ) | [static] |
Definition at line 1410 of file dbug.c.
References DbugMalloc(), settings::next, NULL, settings::out_file, and _db_code_state_::stack.
Referenced by _db_push_().
01411 { 01412 struct settings *new_malloc; 01413 01414 new_malloc= (struct settings *) DbugMalloc(sizeof(struct settings)); 01415 new_malloc->next= cs->stack; 01416 new_malloc->out_file= NULL; 01417 cs->stack= new_malloc; 01418 }
Here is the call graph for this function:

Here is the caller graph for this function:

const char* db_process = 0 [static] |
struct settings init_settings [static] |
Definition at line 214 of file dbug.c.
Referenced by _db_end_(), _db_explain_init_(), _db_set_(), _db_set_init_(), and code_state().
CODE_STATE static_code_state [static] |
Initial value:
{
"dbug", "?func", "?file", NULL, &init_settings,
NullS, NullS, 0,0,0,0,0,NullS
}
Definition at line 359 of file dbug.c.
Referenced by code_state().
1.4.7

