#include <libexc.h>
#endif
-void log_stack_trace(void)
+void log_stack_trace_with_level(int level)
{
#ifdef HAVE_LIBUNWIND
/* Try to use libunwind before any other technique since on ia64
goto libunwind_failed;
}
- DEBUG(0, ("BACKTRACE:\n"));
+ DEBUG(level, ("BACKTRACE:\n"));
do {
ip = sp = 0;
/* Name found. */
case -UNW_ENOMEM:
/* Name truncated. */
- DEBUGADD(0, (" #%u %s + %#llx [ip=%#llx] [sp=%#llx]\n",
+ DEBUGADD(level, (" #%u %s + %#llx [ip=%#llx] [sp=%#llx]\n",
i, procname, (long long)off,
(long long)ip, (long long) sp));
break;
/* case -UNW_ENOINFO: */
/* case -UNW_EUNSPEC: */
/* No symbol name found. */
- DEBUGADD(0, (" #%u %s [ip=%#llx] [sp=%#llx]\n",
+ DEBUGADD(level, (" #%u %s [ip=%#llx] [sp=%#llx]\n",
i, "<unknown symbol>",
(long long)ip, (long long) sp));
}
return;
libunwind_failed:
- DEBUG(0, ("unable to produce a stack trace with libunwind\n"));
+ DEBUG(level, ("unable to produce a stack trace with libunwind\n"));
#elif HAVE_BACKTRACE_SYMBOLS
void *backtrace_stack[BACKTRACE_STACK_SIZE];
backtrace_size = backtrace(backtrace_stack,BACKTRACE_STACK_SIZE);
backtrace_strings = backtrace_symbols(backtrace_stack, backtrace_size);
- DEBUG(0, ("BACKTRACE: %lu stack frames:\n",
+ DEBUG(level, ("BACKTRACE: %lu stack frames:\n",
(unsigned long)backtrace_size));
if (backtrace_strings) {
int i;
for (i = 0; i < backtrace_size; i++)
- DEBUGADD(0, (" #%u %s\n", i, backtrace_strings[i]));
+ DEBUGADD(level, (" #%u %s\n", i, backtrace_strings[i]));
/* Leak the backtrace_strings, rather than risk what free() might do */
}
levels = trace_back_stack(0, addrs, names,
BACKTRACE_STACK_SIZE, NAMESIZE - 1);
- DEBUG(0, ("BACKTRACE: %d stack frames:\n", levels));
+ DEBUG(level, ("BACKTRACE: %d stack frames:\n", levels));
for (i = 0; i < levels; i++) {
- DEBUGADD(0, (" #%d 0x%llx %s\n", i, addrs[i], names[i]));
+ DEBUGADD(level, (" #%d 0x%llx %s\n", i, addrs[i], names[i]));
}
#undef NAMESIZE
#else
- DEBUG(0, ("unable to produce a stack trace on this platform\n"));
+ DEBUG(level, ("unable to produce a stack trace on this platform\n"));
#endif
}
+void log_stack_trace(void)
+{
+ log_stack_trace_with_level(0);
+}
+
/*******************************************************************
A readdir wrapper which just returns the file name.
********************************************************************/