Back to index

citadel  8.12
Classes | Defines | Typedefs | Functions
ecrash.h File Reference
#include <stdio.h>
#include <signal.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


struct  eCrashSymbol
 Function Name / Address pair. More...
struct  eCrashSymbolTable
 Symbol table used to avoid backtrace_symbols() More...
struct  eCrashParameters
 eCrash Initialization Parameters More...


#define MAX_LINE_LEN   256
#define TRUE   1
#define FALSE   0
#define BOOL   int
#define ECRASH_DEBUG_ENABLE   /* undef to turn off debug */
#define ECRASH_DEBUG_OFF   6
#define DPRINTF(level, fmt...)   if (level >= gbl_params.debugLevel) { printf(fmt); fflush(stdout); }


typedef void(* sighandler_t )(int)
typedef long BOOL


int eCrash_Init (eCrashParameters *params)
 Initialize eCrash.
int eCrash_Uninit (void)
 UnInitialize eCrash.
int eCrash_RegisterThread (char *name, int signo)
 Register a thread for backtracing on crash.
int eCrash_UnregisterThread (void)
 Un-register a thread for stack dumps.

Class Documentation

struct eCrashSymbol

Function Name / Address pair.

This is used in conjunction with eCrashSymbolTable to provide an alternative to backtrace_symbols.

Definition at line 39 of file ecrash.h.

Class Members
void * address
char * function
struct eCrashSymbolTable

Symbol table used to avoid backtrace_symbols()

This structure is used to provide a alternative to backtrace_symbols which is not async signal safe.

The symbol table should be sorted by address (it will be either binary or linearly searched)

Definition at line 52 of file ecrash.h.

Collaboration diagram for eCrashSymbolTable:
Class Members
int numSymbols
eCrashSymbol * symbols
struct eCrashParameters

eCrash Initialization Parameters

This structure contains all the global initialization functions for eCrash.

See also:

Definition at line 84 of file ecrash.h.

Collaboration diagram for eCrashParameters:
Class Members
int debugLevel
int defaultBacktraceSignal Default signal to use to tell a thread to drop it's stack.
BOOL dumpAllThreads If true, all registered threads will be dumped.
int fd fd to output to or -1
char * filename Filename to output to, or NULL.
FILE * filep FILE * to output to or NULL.
unsigned int maxStackDepth How far to backtrace each stack.
int signals Array of crash signals to catch, ending in 0 I would have left it a [] array, but I do a static copy, so I needed a set size.
eCrashSymbolTable * symbolTable To avoid the issues with backtrace_symbols (see comments above) the caller can supply it's own symbol table, containing function names and start addresses. This table can be created using a script, or a static table.If this variable is not null, it will be used, instead of backtrace_symbols, reguardless of the setting of useBacktraceSymbols.
unsigned int threadWaitTime How long to wait for a threads dump.
BOOL useBacktraceSymbols If this is non-zero, the dangerous function, backtrace_symbols will be used. That function does a malloc(), so is not async signal safe, and could cause deadlocks.

Define Documentation

#define BOOL   int

Definition at line 25 of file ecrash.h.

#define DPRINTF (   level,
)    if (level >= gbl_params.debugLevel) { printf(fmt); fflush(stdout); }

Definition at line 69 of file ecrash.h.

Definition at line 68 of file ecrash.h.

#define ECRASH_DEBUG_ENABLE   /* undef to turn off debug */

Definition at line 59 of file ecrash.h.


Definition at line 66 of file ecrash.h.


Definition at line 64 of file ecrash.h.

#define ECRASH_DEBUG_OFF   6

Definition at line 67 of file ecrash.h.


Definition at line 63 of file ecrash.h.


Definition at line 62 of file ecrash.h.


Definition at line 65 of file ecrash.h.


Definition at line 29 of file ecrash.h.


Definition at line 28 of file ecrash.h.

Definition at line 30 of file ecrash.h.


Definition at line 31 of file ecrash.h.

#define FALSE   0

Definition at line 24 of file ecrash.h.

#define MAX_LINE_LEN   256

Definition at line 20 of file ecrash.h.

#define TRUE   1

Definition at line 23 of file ecrash.h.

Typedef Documentation

typedef long BOOL

Definition at line 18 of file ecrash.h.

typedef void(* sighandler_t)(int)

Definition at line 16 of file ecrash.h.

Function Documentation

int eCrash_Init ( eCrashParameters params)

Initialize eCrash.

This function must be called before calling any other eCrash functions. It sets up the global behavior of the system.

paramsOur input parameters. The passed in structure will be copied.
Zero on success.

Here is the caller graph for this function:

int eCrash_RegisterThread ( char *  name,
int  signo 

Register a thread for backtracing on crash.

This function must be called by any thread wanting it's stack dumped in the event of a crash. The thread my specify what signal should be used, or the default, SIGUSR1 will be used.

nameString used to refer to us in crash dumps
signoSignal to use to generate dump (default: SIGUSR1)
Zero on success.

Here is the caller graph for this function:

int eCrash_Uninit ( void  )

UnInitialize eCrash.

This function may be called to de-activate eCrash, release the signal handlers, and free any memory allocated by eCrash.

Zero on success.
int eCrash_UnregisterThread ( void  )

Un-register a thread for stack dumps.

This function may be called to un-register any previously registered thread.

Zero on success.