version 1.1, 2012/02/21 23:32:47
|
version 1.1.1.3, 2021/03/17 00:39:23
|
Line 9
|
Line 9
|
|
|
#include "ppp.h" |
#include "ppp.h" |
#include "log.h" |
#include "log.h" |
|
#ifdef USE_BACKTRACE |
|
#include <execinfo.h> |
|
#endif |
|
|
void |
void |
DoAssert(const char *file, int line, const char *failedexpr) |
DoAssert(const char *file, int line, const char *failedexpr) |
{ |
{ |
Log(LG_ERR, ("ASSERT \"%s\" failed: file \"%s\", line %d", | #ifdef USE_BACKTRACE |
failedexpr, file, line)); | void *buffer[100]; |
DoExit(EX_ERRDEAD); | char **strings; |
} | int n, k; |
|
|
|
n = backtrace(buffer, 100); |
|
strings = backtrace_symbols(buffer, n); |
|
if (strings == NULL) { |
|
Log(LG_ERR, ("No backtrace symbols found")); |
|
} else { |
|
for (k = 0; k < n; k++) { |
|
Log(LG_ERR, ("%s", strings[k])); |
|
} |
|
free(strings); |
|
} |
|
#endif |
|
Log(LG_ERR, ("ASSERT \"%s\" failed: file \"%s\", line %d", |
|
failedexpr, file, line)); |
|
|
|
DoExit(EX_ERRDEAD); |
|
} |