30 #ifdef HAVE_EXECINFO_H
32 #define BACKTRACE_LEVELMAX 0100
35 #include <lal/LALMalloc.h>
36 #include <lal/LALError.h>
51 n = vfprintf(stderr, fmt, ap);
62 (void) vfprintf(stderr, fmt, ap);
64 #if defined(HAVE_BACKTRACE) && defined(BACKTRACE_LEVELMAX)
65 void *callstack[BACKTRACE_LEVELMAX];
66 size_t frames = backtrace(callstack, BACKTRACE_LEVELMAX);
67 fprintf(stderr,
"backtrace:\n");
68 backtrace_symbols_fd(callstack, frames, fileno(stderr));
80 (void) vfprintf(stderr, fmt, ap);
82 #if defined(HAVE_BACKTRACE) && defined(BACKTRACE_LEVELMAX)
83 void *callstack[BACKTRACE_LEVELMAX];
84 size_t frames = backtrace(callstack, BACKTRACE_LEVELMAX);
85 fprintf(stderr,
"backtrace:\n");
86 backtrace_symbols_fd(callstack, frames, fileno(stderr));
98 (
"Error[%d] %d: function %s, file %s, line %d, %s\n"
101 statement ? statement :
"",
status->statusDescription);
113 (
"Warning[%d]: function %s, file %s, line %d, %s\n"
126 n =
LALPrintError(
"Info[%d]: function %s, file %s, line %d, %s\n"
139 n =
LALPrintError(
"%s[%d]: function %s, file %s, line %d, %s\n",
140 exitflg ?
"Leave" :
"Enter",
status->level,
150 const char *
file,
const int line)
155 exitcode =
status->statusPtr ? 1 : 0;
157 status->level = level > 0 ? level : 1;
159 status->function =
function;
165 "INITSTATUS: non-null status pointer",
file,
173 lalAbortHook(
"Abort: function %s, file %s, line %d, %s\n"
174 " Null status pointer passed to function\n",
175 function,
file, line,
id);
205 "ATTATCHSTATUSPTR: non-null status pointer",
file,
212 "ATTATCHSTATUSPTR: memory allocation error",
231 status->statusDescription = NULL;
234 "DETATCHSTATUSPTR: null status pointer",
file,
245 const char *
file,
const int line)
253 status->statusDescription = mesg;
265 const char *statement,
const char *
file,
274 status->statusDescription = mesg;
286 const char *
file,
const int line)
288 if (
status->statusPtr->statusCode) {
292 status->statusDescription =
"Recursive error";
316 while (
status->statusPtr);
346 #define FAILMSG( stat, func, file, line, id ) \
348 if ( lalDebugLevel & LALERROR ) \
350 LALPrintError( "Error[0]: file %s, line %d, %s\n" \
351 "\tLAL_CALL: Function call `%s' failed.\n", file, line, id, func ); \
355 fprintf(stderr,"Level 0: %s\n\tFunction call `%s' failed.\n" \
356 "\tfile %s, line %d\n", id, func, file, line ); \
357 REPORTSTATUS( stat ); \
370 volatile const char *
id
386 volatile const char *
id
402 volatile const char *
id
int LAL_ERR_ABRT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
int(* lalRaiseHook)(int, const char *,...)
int LALPrepareAbort(LALStatus *status, const INT4 code, const char *mesg, const char *file, const int line)
void(* lalAbortHook)(const char *,...)
void FREESTATUSPTR(LALStatus *status)
void REPORTSTATUS(LALStatus *status)
int LALDetatchStatusPtr(LALStatus *status, const char *file, const int line)
lal_errhandler_t lal_errhandler
int LALPrepareAssertFail(LALStatus *status, const INT4 code, const char *mesg, const char *statement, const char *file, const int line)
int LAL_ERR_RTRN(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
int LALCheckStatusPtr(LALStatus *status, const char *statement, const char *file, const int line)
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
#define FAILMSG(stat, func, file, line, id)
int LALPrepareReturn(LALStatus *status, const char *file, const int line)
int LALInitStatus(LALStatus *status, const char *function, const char *id, const char *file, const int line)
int LALAttatchStatusPtr(LALStatus *status, const char *file, const int line)
int(* lal_errhandler_t)(LALStatus *, const char *func, const char *file, const int line, volatile const char *id)
int32_t INT4
Four-byte signed integer.
@ LALTRACE
enable tracing messages
@ LALINFO
enable info messages
@ LALERROR
enable error messages
@ LALWARNING
enable warning messages
int LALRaise(int sig, const char *fmt,...)
void LALAbort(const char *fmt,...)
int LALTrace(LALStatus *status, int exitflg)
int LALWarning(LALStatus *status, const char *warning)
int LALError(LALStatus *status, const char *statement)
int LALInfo(LALStatus *status, const char *info)
int LALPrintError(const char *fmt,...)
#define xlalErrno
Modifiable lvalue containing the XLAL error number.
LAL status structure, see The LALStatus structure for more details.
const CHAR * file
The name of the source file containing the function code.
INT4 statusCode
A numerical code identifying the type of error, or 0 for nominal status; Negative values are reserved...
INT4 level
The nested-function level where any error was reported.
const CHAR * function
The name of the function.
volatile const CHAR * Id
A character string identifying the source file and version number of the function being reported on.
const CHAR * statusDescription
An explanatory string corresponding to the numerical status code.
struct tagLALStatus * statusPtr
Pointer to the next node in the list; NULL if this function is not reporting a subroutine error.
INT4 line
The line number in the source file where the current statusCode was set.