summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2003-03-26 12:53:28 +0000
committerJelmer Vernooij <jelmer@samba.org>2003-03-26 12:53:28 +0000
commit0eff00c69225d106b827efed73e21d3538e72e0e (patch)
treebe990a89d2a4969d84df769873a9aea7d1981da8 /source3
parent4474f67fa3f915f7e09fddc3df42cd97403752f9 (diff)
downloadsamba-0eff00c69225d106b827efed73e21d3538e72e0e.tar.gz
samba-0eff00c69225d106b827efed73e21d3538e72e0e.tar.bz2
samba-0eff00c69225d106b827efed73e21d3538e72e0e.zip
Output backtrace to logfile in smb_panic(), as suggested by mbp
(only on systems that support it, of course) (This used to be commit bf439d733df6a11a25ff561a853c3382a3b34b96)
Diffstat (limited to 'source3')
-rw-r--r--source3/configure.in2
-rw-r--r--source3/include/local.h4
-rw-r--r--source3/lib/util.c35
3 files changed, 32 insertions, 9 deletions
diff --git a/source3/configure.in b/source3/configure.in
index 733037b977..cc67efbb90 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -796,7 +796,7 @@ AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
AC_CHECK_FUNCS(syslog vsyslog getgrouplist timegm)
# setbuffer, shmget, shm_open are needed for smbtorture
-AC_CHECK_FUNCS(setbuffer shmget shm_open)
+AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols)
# syscall() is needed for smbwrapper.
AC_CHECK_FUNCS(syscall)
diff --git a/source3/include/local.h b/source3/include/local.h
index 29b0641119..4c3c58e14f 100644
--- a/source3/include/local.h
+++ b/source3/include/local.h
@@ -223,4 +223,8 @@
/* Max number of simultaneous winbindd socket connections. */
#define WINBINDD_MAX_SIMULTANEOUS_CLIENTS 200
+
+/* Buffer size to use when printing backtraces */
+#define BACKTRACE_STACK_SIZE 64
+
#endif
diff --git a/source3/lib/util.c b/source3/lib/util.c
index b67896c648..8bc36a4fb4 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1400,20 +1400,24 @@ 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
{
extern char *global_clobber_region_function;
extern unsigned int global_clobber_region_line;
-
+
if (global_clobber_region_function) {
DEBUG(0,("smb_panic: clobber_region() last called from [%s(%u)]\n",
- global_clobber_region_function,
- global_clobber_region_line));
+ global_clobber_region_function,
+ global_clobber_region_line));
}
}
#endif
-
+
cmd = lp_panic_action();
if (cmd && *cmd) {
DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmd));
@@ -1421,19 +1425,34 @@ void smb_panic(const char *why)
if (result == -1)
DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n",
- strerror(errno)));
+ strerror(errno)));
else
DEBUG(0, ("smb_panic(): action returned status %d\n",
- WEXITSTATUS(result)));
+ WEXITSTATUS(result)));
}
DEBUG(0,("PANIC: %s\n", why));
+ DEBUG(0, ("%d stack frames:\n", backtrace_size));
+
+#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);
+
+ if (backtrace_strings) {
+ for (i = 0; i < backtrace_size; i++)
+ DEBUG(0, (" #%u %s\n", i, backtrace_strings[i]));
+ }
+
+ free(backtrace_strings);
+#endif
+
dbgflush();
abort();
}
/*******************************************************************
- A readdir wrapper which just returns the file name.
-********************************************************************/
+ A readdir wrapper which just returns the file name.
+ ********************************************************************/
const char *readdirname(DIR *p)
{