From 10bf059b62480d502652408e9c138445859789fc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2003 21:49:49 +0000 Subject: Backport my backtrace patch from HEAD (This used to be commit 66fcf6b4938a87e5ded7c7e5830a6a54e4439544) --- source3/lib/util.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index 1bfbd6f5a0..a392530786 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1400,6 +1400,10 @@ void smb_panic(const char *why) { char *cmd; int result; + size_t i; + void *backtrace_stack[BACKTRACE_STACK_SIZE]; + size_t backtrace_size; + char **backtrace_strings; #ifdef DEVELOPER { @@ -1427,6 +1431,23 @@ void smb_panic(const char *why) WEXITSTATUS(result))); } DEBUG(0,("PANIC: %s\n", why)); + +#ifdef HAVE_BACKTRACE_SYMBOLS + /* get the backtrace (stack frames) */ + backtrace_size = backtrace(backtrace_stack,BACKTRACE_STACK_SIZE); + backtrace_strings = backtrace_symbols(backtrace_stack, backtrace_size); + + DEBUG(0, ("BACKTRACE: %d stack frames:\n", backtrace_size)); + + if (backtrace_strings) { + for (i = 0; i < backtrace_size; i++) + DEBUGADD(0, (" #%u %s\n", i, backtrace_strings[i])); + + SAFE_FREE(backtrace_strings); + } + +#endif + dbgflush(); abort(); } -- cgit