Back to index

citadel  8.12
ecrash.h
Go to the documentation of this file.
00001 /*
00002  * eCrash.h
00003  * David Frascone
00004  * 
00005  * eCrash types and prototypes.
00006  *
00007  * vim: ts=4
00008  */
00009 
00010 #ifndef _ECRASH_H_
00011 #define _ECRASH_H_
00012 
00013 #include <stdio.h>
00014 #include <signal.h>
00015 
00016 typedef void (*sighandler_t)(int);
00017 
00018 typedef long BOOL;
00019 
00020 #define MAX_LINE_LEN 256
00021 
00022 #ifndef TRUE
00023 #define TRUE 1
00024 #define FALSE 0
00025 #define BOOL int
00026 #endif
00027 
00028 #define ECRASH_DEFAULT_STACK_DEPTH 10
00029 #define ECRASH_DEFAULT_BACKTRACE_SIGNAL SIGUSR2
00030 #define ECRASH_DEFAULT_THREAD_WAIT_TIME 10
00031 #define ECRASH_MAX_NUM_SIGNALS 30
00032 
00039 typedef struct {
00040        char          *function;
00041        void          *address;
00042 } eCrashSymbol;
00052 typedef struct {
00053        int           numSymbols;
00054        eCrashSymbol *symbols;
00055 } eCrashSymbolTable;
00056 
00057 
00058 
00059 #define ECRASH_DEBUG_ENABLE  /* undef to turn off debug */
00060 
00061 #ifdef ECRASH_DEBUG_ENABLE
00062 # define ECRASH_DEBUG_VERY_VERBOSE 1
00063 # define ECRASH_DEBUG_VERBOSE      2
00064 # define ECRASH_DEBUG_INFO         3
00065 # define ECRASH_DEBUG_WARN         4
00066 # define ECRASH_DEBUG_ERROR        5
00067 # define ECRASH_DEBUG_OFF          6
00068 # define ECRASH_DEBUG_DEFAULT        (ECRASH_DEBUG_ERROR)
00069 # define DPRINTF(level, fmt...) \
00070               if (level >= gbl_params.debugLevel) { printf(fmt); fflush(stdout); }
00071 #else /* ECRASH_DEBUG_ENABLE */
00072 # define DPRINTF(level, fmt...) 
00073 #endif /* ECRASH_DEBUG_ENABLE */
00074 
00075 
00084 typedef struct {
00085 
00086 
00087        /*  OUTPUT OPTIONS */
00089        char *filename;                    
00091        FILE *filep;
00093        int    fd;
00094 
00095        int debugLevel;
00096 
00100        BOOL dumpAllThreads;
00101 
00103        unsigned int maxStackDepth;
00104 
00108        int defaultBacktraceSignal;
00109 
00113        unsigned int threadWaitTime;
00114 
00119        BOOL useBacktraceSymbols; 
00120 
00130        eCrashSymbolTable *symbolTable;
00131 
00136        int signals[ECRASH_MAX_NUM_SIGNALS];
00137 
00138 } eCrashParameters;
00139 
00150 int eCrash_Init(eCrashParameters *params);
00159 int eCrash_Uninit( void );
00160 
00173 int eCrash_RegisterThread(char *name, int signo);
00174 
00183 int eCrash_UnregisterThread( void );
00184 
00185 #endif /* _E_CRASH_H_ */