diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2003-04-14 21:49:49 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2003-04-14 21:49:49 +0000 |
commit | 10bf059b62480d502652408e9c138445859789fc (patch) | |
tree | b6138b66dd7375a30c076c95829582f8addde39c /source3/lib | |
parent | 11fb38cfb8fd25783f54cba882e3e9968bd62a0b (diff) | |
download | samba-10bf059b62480d502652408e9c138445859789fc.tar.gz samba-10bf059b62480d502652408e9c138445859789fc.tar.bz2 samba-10bf059b62480d502652408e9c138445859789fc.zip |
Backport my backtrace patch from HEAD
(This used to be commit 66fcf6b4938a87e5ded7c7e5830a6a54e4439544)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util.c | 21 |
1 files changed, 21 insertions, 0 deletions
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(); } |