show backtrace in assert failure and not abort

pull/4044/head
Sait Talha Nisanci 2020-07-13 22:35:23 +03:00
parent 1b3f4d79fe
commit ea83823437
3 changed files with 16 additions and 1 deletions

View File

@ -8,7 +8,6 @@
#include "postgres.h"
#include "backtrace.h"
// #include "backtrace-supported.h"
#include "lib/stringinfo.h"
#include "distributed/backtrace.h"
@ -54,6 +53,11 @@ Backtrace(int elevel)
errdetail("%s", GenerateBackTrace());
}
void AssertBacktrace(void) {
const char * backtrace = GenerateBackTrace();
ereport(ERROR, (errmsg("%s", backtrace)));
}
static char *
GenerateBackTrace(void)

View File

@ -12,5 +12,6 @@
#define CITUS_BACKTRACE_H
void Backtrace(int elevel);
void AssertBacktrace(void);
#endif

View File

@ -66,4 +66,14 @@ extern char * HashLogMessage(const char *text);
ereport_domain(elevel, TEXTDOMAIN, rest); \
} while (0)
#undef Trap
#define Trap(condition, errorType) \
do { \
if (condition) { \
AssertBacktrace(); \
ExceptionalCondition(CppAsString(condition), (errorType), \
__FILE__, __LINE__); \
} \
} while (0)
#endif /* LOG_UTILS_H */