mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
Ad-hoc backtrace logging with isc_backtrace_log()
It's sometimes helpful to get a quick idea of the call stack when debugging. This change factors out the backtrace logging from named's fatal error handler so that it's easy to use in other places too.
This commit is contained in:
@@ -101,13 +101,6 @@
|
||||
*/
|
||||
/* #include "xxdb.h" */
|
||||
|
||||
/*
|
||||
* The maximum number of stack frames to dump on assertion failure.
|
||||
*/
|
||||
#ifndef BACKTRACE_MAXFRAME
|
||||
#define BACKTRACE_MAXFRAME 128
|
||||
#endif /* ifndef BACKTRACE_MAXFRAME */
|
||||
|
||||
extern unsigned int dns_zone_mkey_hour;
|
||||
extern unsigned int dns_zone_mkey_day;
|
||||
extern unsigned int dns_zone_mkey_month;
|
||||
@@ -189,9 +182,6 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type,
|
||||
static void
|
||||
assertion_failed(const char *file, int line, isc_assertiontype_t type,
|
||||
const char *cond) {
|
||||
void *tracebuf[BACKTRACE_MAXFRAME];
|
||||
int nframes;
|
||||
|
||||
/*
|
||||
* Handle assertion failures.
|
||||
*/
|
||||
@@ -203,24 +193,12 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type,
|
||||
*/
|
||||
isc_assertion_setcallback(NULL);
|
||||
|
||||
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,
|
||||
(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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
"%s:%d: %s(%s) failed", file, line,
|
||||
isc_assertion_typetotext(type), cond);
|
||||
isc_backtrace_log(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL);
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
"exiting (due to assertion failure)");
|
||||
|
Reference in New Issue
Block a user