*/
/* #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;
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.
*/
*/
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)");
static void
default_callback(const char *file, int line, isc_assertiontype_t type,
const char *cond) {
- void *tracebuf[BACKTRACE_MAXFRAME];
- int nframes = isc_backtrace(tracebuf, BACKTRACE_MAXFRAME);
+ void *tracebuf[ISC_BACKTRACE_MAXFRAME];
+ int nframes = isc_backtrace(tracebuf, ISC_BACKTRACE_MAXFRAME);
fprintf(stderr, "%s:%d: %s(%s) failed%s\n", file, line,
isc_assertion_typetotext(type), cond,
#endif /* HAVE_BACKTRACE_SYMBOLS */
#include <isc/backtrace.h>
+#include <isc/log.h>
#include <isc/result.h>
#include <isc/util.h>
backtrace_symbols_fd(buffer, size, fd);
}
+void
+isc_backtrace_log(isc_log_t *lctx, isc_logcategory_t *category,
+ isc_logmodule_t *module, int level) {
+ void *tracebuf[ISC_BACKTRACE_MAXFRAME];
+ int nframes;
+ char **strs;
+
+ nframes = isc_backtrace(tracebuf, ISC_BACKTRACE_MAXFRAME);
+ if (nframes <= 0) {
+ return;
+ }
+ strs = isc_backtrace_symbols(tracebuf, nframes);
+ if (strs == NULL) {
+ return;
+ }
+ for (int i = 0; i < nframes; i++) {
+ isc_log_write(lctx, category, module, level, "%s", strs[i]);
+ }
+}
+
#else /* HAVE_BACKTRACE_SYMBOLS */
int
UNUSED(fd);
}
+void
+isc_backtrace_log(isc_log_t *lctx, isc_logcategory_t *category,
+ isc_logmodule_t *module, int level) {
+ UNUSED(lctx);
+ UNUSED(category);
+ UNUSED(module);
+ UNUSED(level);
+}
+
#endif /* HAVE_BACKTRACE_SYMBOLS */
***/
#include <isc/types.h>
+/*
+ * The maximum number of stack frames to dump on assertion failure.
+ */
+#ifndef ISC_BACKTRACE_MAXFRAME
+#define ISC_BACKTRACE_MAXFRAME 128
+#endif /* ifndef ISC_BACKTRACE_MAXFRAME */
+
/***
*** Functions
***/
*\li See platform NOTES for backtrace_symbols_fd for caveats
*/
+void
+isc_backtrace_log(isc_log_t *lctx, isc_logcategory_t *category,
+ isc_logmodule_t *module, int level);
+/*
+ * Write a backtrace to the log.
+ */
+
ISC_LANG_ENDDECLS