mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
Add support for generating backtraces on Windows
This commit adds support for generating backtraces on Windows and refactors the isc_backtrace API to match the Linux/BSD API (without the isc_ prefix) * isc_backtrace_gettrace() was renamed to isc_backtrace(), the third argument was removed and the return type was changed to int * isc_backtrace_symbols() was added * isc_backtrace_symbols_fd() was added and used as appropriate
This commit is contained in:
@@ -205,8 +205,6 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type,
|
||||
const char *cond) {
|
||||
void *tracebuf[BACKTRACE_MAXFRAME];
|
||||
int nframes;
|
||||
isc_result_t result;
|
||||
const char *logsuffix = "";
|
||||
|
||||
/*
|
||||
* Handle assertion failures.
|
||||
@@ -219,32 +217,23 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type,
|
||||
*/
|
||||
isc_assertion_setcallback(NULL);
|
||||
|
||||
result = isc_backtrace_gettrace(tracebuf, BACKTRACE_MAXFRAME,
|
||||
&nframes);
|
||||
if (result == ISC_R_SUCCESS && nframes > 0) {
|
||||
logsuffix = ", back trace";
|
||||
}
|
||||
nframes = isc_backtrace(tracebuf, BACKTRACE_MAXFRAME);
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
"%s:%d: %s(%s) failed%s", file, line,
|
||||
isc_assertion_typetotext(type), cond, logsuffix);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
#if HAVE_BACKTRACE_SYMBOLS
|
||||
char **strs = backtrace_symbols(tracebuf, nframes);
|
||||
for (int i = 0; i < nframes; i++) {
|
||||
isc_log_write(named_g_lctx,
|
||||
NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN,
|
||||
ISC_LOG_CRITICAL, "%s", strs[i]);
|
||||
isc_assertion_typetotext(type), cond,
|
||||
(nframes > 0) ? ", back trace" : "");
|
||||
if (nframes > 0) {
|
||||
char **strs = isc_backtrace_symbols(tracebuf, nframes);
|
||||
if (strs != NULL) {
|
||||
for (int i = 0; i < nframes; i++) {
|
||||
isc_log_write(named_g_lctx,
|
||||
NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN,
|
||||
ISC_LOG_CRITICAL, "%s",
|
||||
strs[i]);
|
||||
}
|
||||
}
|
||||
#else /* HAVE_BACKTRACE_SYMBOLS */
|
||||
for (int i = 0; i < nframes; i++) {
|
||||
isc_log_write(
|
||||
named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
"#%d %p in ??", i, tracebuf[i]);
|
||||
}
|
||||
#endif /* HAVE_BACKTRACE_SYMBOLS */
|
||||
}
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
|
Reference in New Issue
Block a user