version 1.1.1.2, 2016/11/01 09:56:12
|
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) |
{ |
{ |
#ifdef USE_BACKTRACE |
#ifdef USE_BACKTRACE |
void *buffer[100]; | void *buffer[100]; |
char **strings; | char **strings; |
int n, k; | int n, k; |
|
|
n = backtrace(buffer, 100); | n = backtrace(buffer, 100); |
strings = backtrace_symbols(buffer, n); | strings = backtrace_symbols(buffer, n); |
if (strings == NULL) { | if (strings == NULL) { |
Log(LG_ERR, ("No backtrace symbols found")); | Log(LG_ERR, ("No backtrace symbols found")); |
} else { | } else { |
for (k = 0; k < n; k++) { | for (k = 0; k < n; k++) { |
Log(LG_ERR, ("%s", strings[k])); | Log(LG_ERR, ("%s", strings[k])); |
} | } |
free(strings); | free(strings); |
} | } |
#endif |
#endif |
Log(LG_ERR, ("ASSERT \"%s\" failed: file \"%s\", line %d", | Log(LG_ERR, ("ASSERT \"%s\" failed: file \"%s\", line %d", |
failedexpr, file, line)); | failedexpr, file, line)); |
|
|
DoExit(EX_ERRDEAD); | DoExit(EX_ERRDEAD); |
} |
} |
|
|