svn commit: samba r8678 - in branches/SAMBA_4_0/source: client lib lib/cmdline script script/tests scripting/ejs smbd

tridge at samba.org tridge at samba.org
Thu Jul 21 12:11:53 GMT 2005


Author: tridge
Date: 2005-07-21 12:11:52 +0000 (Thu, 21 Jul 2005)
New Revision: 8678

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8678

Log:
setup for gdb backtrace in 'make test'


Added:
   branches/SAMBA_4_0/source/script/gdb_backtrace
Modified:
   branches/SAMBA_4_0/source/client/smbspool.c
   branches/SAMBA_4_0/source/lib/cmdline/popt_common.c
   branches/SAMBA_4_0/source/lib/fault.c
   branches/SAMBA_4_0/source/script/tests/selftest.sh
   branches/SAMBA_4_0/source/scripting/ejs/smbscript.c
   branches/SAMBA_4_0/source/smbd/server.c


Changeset:
Modified: branches/SAMBA_4_0/source/client/smbspool.c
===================================================================
--- branches/SAMBA_4_0/source/client/smbspool.c	2005-07-21 11:28:24 UTC (rev 8677)
+++ branches/SAMBA_4_0/source/client/smbspool.c	2005-07-21 12:11:52 UTC (rev 8678)
@@ -175,7 +175,7 @@
   * Setup the SAMBA server state...
   */
 
-  setup_logging("smbspool", DEBUG_STDOUT);
+  setup_logging(argv[0], DEBUG_STDOUT);
 
   if (!lp_load()) {
 	  fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", lp_config_file());

Modified: branches/SAMBA_4_0/source/lib/cmdline/popt_common.c
===================================================================
--- branches/SAMBA_4_0/source/lib/cmdline/popt_common.c	2005-07-21 11:28:24 UTC (rev 8677)
+++ branches/SAMBA_4_0/source/lib/cmdline/popt_common.c	2005-07-21 12:11:52 UTC (rev 8678)
@@ -48,6 +48,9 @@
 			   const char *arg, const void *data)
 {
 	const char *pname;
+
+	/* setup for panics */
+	fault_setup(poptGetInvocationName(con));
 	
 	if (reason == POPT_CALLBACK_REASON_POST) {
 		/* Hook any 'every Samba program must do this, after

Modified: branches/SAMBA_4_0/source/lib/fault.c
===================================================================
--- branches/SAMBA_4_0/source/lib/fault.c	2005-07-21 11:28:24 UTC (rev 8677)
+++ branches/SAMBA_4_0/source/lib/fault.c	2005-07-21 12:11:52 UTC (rev 8678)
@@ -23,14 +23,13 @@
 #include "system/wait.h"
 #include "system/filesys.h"
 
-static void (*cont_fn)(void *);
-
 /* the registered fault handler */
 static struct {
 	const char *name;
 	void (*fault_handler)(int sig);
 } fault_handlers;
 
+static const char *progname;
 
 #ifdef HAVE_BACKTRACE
 #include <execinfo.h>
@@ -111,8 +110,16 @@
 	int result;
 
 	if (cmd && *cmd) {
-		DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmd));
-		result = system(cmd);
+		char pidstr[20];
+		char cmdstring[200];
+		safe_strcpy(cmdstring, cmd, sizeof(cmdstring));
+		snprintf(pidstr, sizeof(pidstr), "%u", getpid());
+		all_string_sub(cmdstring, "%PID%", pidstr, sizeof(cmdstring));
+		if (progname) {
+			all_string_sub(cmdstring, "%PROG%", progname, sizeof(cmdstring));
+		}
+		DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmdstring));
+		result = system(cmdstring);
 
 		if (result == -1)
 			DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n",
@@ -147,19 +154,6 @@
 
 	smb_panic("internal error");
 
-	if (cont_fn) {
-		cont_fn(NULL);
-#ifdef SIGSEGV
-		CatchSignal(SIGSEGV,SIGNAL_CAST SIG_DFL);
-#endif
-#ifdef SIGBUS
-		CatchSignal(SIGBUS,SIGNAL_CAST SIG_DFL);
-#endif
-#ifdef SIGABRT
-		CatchSignal(SIGABRT,SIGNAL_CAST SIG_DFL);
-#endif
-		return; /* this should cause a core dump */
-	}
 	exit(1);
 }
 
@@ -179,10 +173,11 @@
 /*******************************************************************
 setup our fault handlers
 ********************************************************************/
-void fault_setup(void (*fn)(void *))
+void fault_setup(const char *pname)
 {
-	cont_fn = fn;
-
+	if (progname == NULL) {
+		progname = pname;
+	}
 #ifdef SIGSEGV
 	CatchSignal(SIGSEGV,SIGNAL_CAST sig_fault);
 #endif

Added: branches/SAMBA_4_0/source/script/gdb_backtrace
===================================================================
--- branches/SAMBA_4_0/source/script/gdb_backtrace	2005-07-21 11:28:24 UTC (rev 8677)
+++ branches/SAMBA_4_0/source/script/gdb_backtrace	2005-07-21 12:11:52 UTC (rev 8678)
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# we want everything on stderr, so the program is not disturbed
+exec 1>&2
+
+PID=$1
+PROG=$2
+
+TMPFILE=/tmp/gdb.$$
+cat << EOF  > $TMPFILE
+set height 1000
+bt full
+quit
+EOF
+
+gdb -batch -x $TMPFILE $PROG $PID < /dev/null 
+/bin/rm -f $TMPFILE


Property changes on: branches/SAMBA_4_0/source/script/gdb_backtrace
___________________________________________________________________
Name: svn:executable
   + *

Modified: branches/SAMBA_4_0/source/script/tests/selftest.sh
===================================================================
--- branches/SAMBA_4_0/source/script/tests/selftest.sh	2005-07-21 11:28:24 UTC (rev 8677)
+++ branches/SAMBA_4_0/source/script/tests/selftest.sh	2005-07-21 12:11:52 UTC (rev 8678)
@@ -92,6 +92,7 @@
 	name resolve order = bcast
 	interfaces = lo*
 	tls enabled = $TLS_ENABLED
+	panic action = $SRCDIR/script/gdb_backtrace %PID% %PROG%
 
 [tmp]
 	path = $TMPDIR

Modified: branches/SAMBA_4_0/source/scripting/ejs/smbscript.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/smbscript.c	2005-07-21 11:28:24 UTC (rev 8677)
+++ branches/SAMBA_4_0/source/scripting/ejs/smbscript.c	2005-07-21 12:11:52 UTC (rev 8678)
@@ -45,6 +45,7 @@
 	struct MprVar *return_var;
 	int exit_status, i;
 
+	fault_setup(argv[0]);
 	smbscript_init_subsystems;
 	mprSetCtx(mem_ctx);
 

Modified: branches/SAMBA_4_0/source/smbd/server.c
===================================================================
--- branches/SAMBA_4_0/source/smbd/server.c	2005-07-21 11:28:24 UTC (rev 8677)
+++ branches/SAMBA_4_0/source/smbd/server.c	2005-07-21 12:11:52 UTC (rev 8678)
@@ -96,8 +96,6 @@
 */
 static void setup_signals(void)
 {
-	fault_setup(NULL);
-	
 	/* we are never interested in SIGPIPE */
 	BlockSignals(True,SIGPIPE);
 
@@ -175,7 +173,7 @@
 
 	poptFreeContext(pc);
 
-	setup_logging(NULL, interactive?DEBUG_STDOUT:DEBUG_FILE);
+	setup_logging(argv[0], interactive?DEBUG_STDOUT:DEBUG_FILE);
 	setup_signals();
 
 	/* we want total control over the permissions on created files,



More information about the samba-cvs mailing list