[issue867] kill db_print_backtrace()

Aggelos Economopoulos aoiko at cc.ece.ntua.gr
Thu Feb 5 10:40:00 PST 2009


Sepherosa Ziehau (via DragonFly issue tracker) wrote:
> Sepherosa Ziehau <sepherosa at gmail.com> added the comment:
> 
> On Tue, Jan 20, 2009 at 7:18 PM, Hasso Tepper (via DragonFly issue
> tracker) <sinknull at crater.dragonflybsd.org> wrote:
>> Hasso Tepper <hasso at estpak.ee> added the comment:
>>
>> What's the opinion regarding this? It should be either committed or closed.
> 
> Looks good to me.  However, should ddb/ddb.h uninclude in these files
> after this patch?

This report today:

<jwh> hm, guys
<jwh> linking kernel.nodebug
<jwh> route.o: In function `rtfree_remote':
<jwh> route.c:(.text+0xfb): undefined reference to `db_print_backtrace'
<jwh> ip_output.o: In function `ip_output':
<jwh> ip_output.c:(.text+0x5c2): undefined reference to `db_print_backtrace'
<jwh> building vkernel

prompted me to produce a new patch, which indeed removes some #ifdef DDB
and #include <ddb/ddb.h> lines. Compile tested w/ LINT and my regular
kernel config without DDB.

Opinions? Otherwise in it goes, should be trivial enough for the soft
freeze :)

Sorry this is not inline, icedove sucks quite a bit for serious email
usage...

Aggelos
diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h
index 7b7063e..fbd9630 100644
--- a/sys/ddb/ddb.h
+++ b/sys/ddb/ddb.h
@@ -145,11 +145,6 @@ db_cmdfcn_t	vm_page_print;
 #endif
 
 /*
- * Print backtrace. (Machine-Dependant)
- */
-void		db_print_backtrace(void);
-
-/*
  * Command table.
  */
 struct command {
diff --git a/sys/dev/acpica5/Osd/OsdSynch.c b/sys/dev/acpica5/Osd/OsdSynch.c
index c307be9..34bce27 100644
--- a/sys/dev/acpica5/Osd/OsdSynch.c
+++ b/sys/dev/acpica5/Osd/OsdSynch.c
@@ -355,9 +355,6 @@ AcpiOsDeleteLock (ACPI_SPINLOCK Spin)
     kfree(Spin, M_ACPISEM);
 }
 
-#ifdef ACPI_DEBUG_LOCKS
-void db_print_backtrace(void);
-#endif
 /*
  * OS-dependent locking primitives.  These routines should be able to be
  * called from an interrupt-handler or cpu_idle thread.
@@ -379,7 +376,7 @@ AcpiOsAcquireLock (ACPI_SPINLOCK Spin)
 	kprintf("%p(%s:%d): acpi_spinlock %p already held by %p(%s:%d)\n",
 		curthread, func, line, Spin, Spin->owner, Spin->func,
 		Spin->line);
-	db_print_backtrace();
+	backtrace();
     } else {
 	Spin->owner = curthread;
 	Spin->func = func;
@@ -397,7 +394,7 @@ AcpiOsReleaseLock (ACPI_SPINLOCK Spin, UINT32 Flags)
 	if (Spin->owner != NULL) {
 	    kprintf("%p: acpi_spinlock %p is unexectedly held by %p(%s:%d)\n",
 		    curthread, Spin, Spin->owner, Spin->func, Spin->line);
-	    db_print_backtrace();
+	    backtrace();
 	} else
 	    return;
     }
diff --git a/sys/kern/kern_debug.c b/sys/kern/kern_debug.c
index 18be479..be37bb6 100644
--- a/sys/kern/kern_debug.c
+++ b/sys/kern/kern_debug.c
@@ -80,15 +80,11 @@
 /*
  * Simple DDB stack trace funtionality.
  */
+#ifndef DDB
 void
 backtrace(void)
 {
-
-#ifdef DDB
-		kprintf("Stack backtrace:\n");
-		db_print_backtrace();
-#else
 		kprintf("Cannot print stack trace.\n");
 		kprintf("DDB kernel option is needed.\n");
-#endif
 }
+#endif
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index 015c8e1..a549542 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -96,6 +96,7 @@
 #include <machine/stdarg.h>
 
 #ifdef DDB
+#include <ddb/ddb.h>
 #ifdef DDB_UNATTENDED
 int debugger_on_panic = 0;
 #else
@@ -104,8 +105,6 @@ int debugger_on_panic = 1;
 SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW,
 	&debugger_on_panic, 0, "Run debugger on kernel panic");
 
-extern void db_print_backtrace(void);
-
 #ifdef DDB_TRACE
 int trace_on_panic = 1;
 #else
@@ -794,7 +793,7 @@ panic(const char *fmt, ...)
 
 #if defined(DDB)
 	if (newpanic && trace_on_panic)
-		db_print_backtrace();
+		backtrace();
 	if (debugger_on_panic)
 		Debugger("panic");
 #endif
diff --git a/sys/kern/kern_spinlock.c b/sys/kern/kern_spinlock.c
index d1f31b8..c3139b7 100644
--- a/sys/kern/kern_spinlock.c
+++ b/sys/kern/kern_spinlock.c
@@ -32,8 +32,6 @@
  * $DragonFly: src/sys/kern/kern_spinlock.c,v 1.16 2008/09/11 01:11:42 y0netan1 Exp $
  */
 
-#include "opt_ddb.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/types.h>
@@ -43,7 +41,6 @@
 #include <sys/proc.h>
 #endif
 #include <sys/priv.h>
-#include <ddb/ddb.h>
 #include <machine/atomic.h>
 #include <machine/cpufunc.h>
 #include <machine/specialreg.h>
@@ -307,16 +304,16 @@ exponential_backoff(struct exponential_backoff *bo)
 		kprintf("spin_lock: %p, indefinite wait!\n", bo->mtx);
 		if (panicstr)
 			return (TRUE);
-#if defined(INVARIANTS) && defined(DDB)
+#if defined(INVARIANTS)
 		if (spin_lock_test_mode) {
-			db_print_backtrace();
+			backtrace();
 			return (TRUE);
 		}
 #endif
 		++bo->nsec;
-#if defined(INVARIANTS) && defined(DDB)
+#if defined(INVARIANTS)
 		if (bo->nsec == 11)
-			db_print_backtrace();
+			backtrace();
 #endif
 		if (bo->nsec == 60)
 			panic("spin_lock: %p, indefinite wait!\n", bo->mtx);
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index 5f833d2..685c0ac 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -99,8 +99,6 @@
  * The per-cpu augmentation was done by Matthew Dillon.
  */
 
-#include "opt_ddb.h"
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/callout.h>
@@ -108,7 +106,6 @@
 #include <sys/interrupt.h>
 #include <sys/thread.h>
 #include <sys/thread2.h>
-#include <ddb/ddb.h>
 
 #ifndef MAX_SOFTCLOCK_STEPS
 #define MAX_SOFTCLOCK_STEPS 100 /* Maximum allowed value of steps. */
@@ -360,9 +357,7 @@ callout_reset(struct callout *c, int to_ticks, void (*ftn)(void *),
 		kprintf(
 		    "callout_reset(%p) from %p: callout was not initialized\n",
 		    c, ((int **)&c)[-1]);
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	}
 #endif
 	gd = mycpu;
@@ -415,9 +410,7 @@ callout_stop(struct callout *c)
 		kprintf(
 		    "callout_stop(%p) from %p: callout was not initialized\n",
 		    c, ((int **)&c)[-1]);
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	}
 #endif
 	crit_enter_gd(gd);
diff --git a/sys/kern/lwkt_thread.c b/sys/kern/lwkt_thread.c
index a1ce259..bf6e4e5 100644
--- a/sys/kern/lwkt_thread.c
+++ b/sys/kern/lwkt_thread.c
@@ -40,7 +40,6 @@
  * to use a critical section to avoid problems.  Foreign thread 
  * scheduling is queued via (async) IPIs.
  */
-#include "opt_ddb.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -71,9 +70,6 @@
 #include <machine/stdarg.h>
 #include <machine/smp.h>
 
-#ifdef DDB
-#include <ddb/ddb.h>
-#endif
 
 static MALLOC_DEFINE(M_THREAD, "thread", "lwkt threads");
 
@@ -501,9 +497,7 @@ lwkt_switch(void)
 		td->td_flags |= TDF_PANICWARN;
 		kprintf("Warning: thread switch from interrupt or IPI, "
 			"thread %p (%s)\n", td, td->td_comm);
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	    }
 	    lwkt_switch();
 	    gd->gd_intr_nesting_level = savegdnest;
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 560f01c..f8d9c1a 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -69,7 +69,6 @@
  */
 
 #include "opt_param.h"
-#include "opt_ddb.h"
 #include "opt_mbuf_stress_test.h"
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -890,8 +889,6 @@ m_mclfree(void *arg)
 		objcache_put(mclmeta_cache, mcl);
 }
 
-extern void db_print_backtrace(void);
-
 /*
  * Free a single mbuf and any associated external storage.  The successor,
  * if any, is returned.
@@ -921,14 +918,12 @@ m_free(struct mbuf *m)
 	KKASSERT(m->m_nextpkt == NULL);
 #else
 	if (m->m_nextpkt != NULL) {
-#ifdef DDB
 		static int afewtimes = 10;
 
 		if (afewtimes-- > 0) {
 			kprintf("mfree: m->m_nextpkt != NULL\n");
-			db_print_backtrace();
+			backtrace();
 		}
-#endif
 		m->m_nextpkt = NULL;
 	}
 #endif
diff --git a/sys/platform/pc32/i386/db_trace.c b/sys/platform/pc32/i386/db_trace.c
index f1ed532..e70636a 100644
--- a/sys/platform/pc32/i386/db_trace.c
+++ b/sys/platform/pc32/i386/db_trace.c
@@ -435,7 +435,7 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
 }
 
 void
-db_print_backtrace(void)
+backtrace(void)
 {
 	register_t  ebp;
 
diff --git a/sys/platform/pc32/i386/pmap.c b/sys/platform/pc32/i386/pmap.c
index 2102002..279e96d 100644
--- a/sys/platform/pc32/i386/pmap.c
+++ b/sys/platform/pc32/i386/pmap.c
@@ -107,8 +107,6 @@
 #include <machine/pmap.h>
 #include <machine/pmap_inval.h>
 
-#include <ddb/ddb.h>
-
 #define PMAP_KEEP_PDIRS
 #ifndef PMAP_SHPGPERPROC
 #define PMAP_SHPGPERPROC 200
@@ -1964,15 +1962,11 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
 #endif
 	if (va < UPT_MAX_ADDRESS && pmap == &kernel_pmap) {
 		kprintf("Warning: pmap_enter called on UVA with kernel_pmap\n");
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	}
 	if (va >= UPT_MAX_ADDRESS && pmap != &kernel_pmap) {
 		kprintf("Warning: pmap_enter called on KVA without kernel_pmap\n");
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	}
 
 	/*
@@ -2127,15 +2121,11 @@ pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m)
 
 	if (va < UPT_MAX_ADDRESS && pmap == &kernel_pmap) {
 		kprintf("Warning: pmap_enter_quick called on UVA with kernel_pmap\n");
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	}
 	if (va >= UPT_MAX_ADDRESS && pmap != &kernel_pmap) {
 		kprintf("Warning: pmap_enter_quick called on KVA without kernel_pmap\n");
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	}
 
 	KKASSERT(va < UPT_MIN_ADDRESS);	/* assert used on user pmaps only */
diff --git a/sys/platform/pc64/amd64/db_trace.c b/sys/platform/pc64/amd64/db_trace.c
index d1077f2..fa96c99 100644
--- a/sys/platform/pc64/amd64/db_trace.c
+++ b/sys/platform/pc64/amd64/db_trace.c
@@ -440,7 +440,7 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
 }
 
 void
-db_print_backtrace(void)
+backtrace(void)
 {
 	register_t  rbp;
 
diff --git a/sys/platform/pc64/amd64/pmap.c b/sys/platform/pc64/amd64/pmap.c
index 3e5637f..97278dc 100644
--- a/sys/platform/pc64/amd64/pmap.c
+++ b/sys/platform/pc64/amd64/pmap.c
@@ -109,8 +109,6 @@
 #include <machine/pmap.h>
 #include <machine/pmap_inval.h>
 
-#include <ddb/ddb.h>
-
 #define PMAP_KEEP_PDIRS
 #ifndef PMAP_SHPGPERPROC
 #define PMAP_SHPGPERPROC 200
@@ -2081,15 +2079,11 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
 #endif
 	if (va < UPT_MAX_ADDRESS && pmap == &kernel_pmap) {
 		kprintf("Warning: pmap_enter called on UVA with kernel_pmap\n");
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	}
 	if (va >= UPT_MAX_ADDRESS && pmap != &kernel_pmap) {
 		kprintf("Warning: pmap_enter called on KVA without kernel_pmap\n");
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	}
 
 	/*
@@ -2244,15 +2238,11 @@ pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m)
 
 	if (va < UPT_MAX_ADDRESS && pmap == &kernel_pmap) {
 		kprintf("Warning: pmap_enter_quick called on UVA with kernel_pmap\n");
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	}
 	if (va >= UPT_MAX_ADDRESS && pmap != &kernel_pmap) {
 		kprintf("Warning: pmap_enter_quick called on KVA without kernel_pmap\n");
-#ifdef DDB
-		db_print_backtrace();
-#endif
+		backtrace();
 	}
 
 	KKASSERT(va < UPT_MIN_ADDRESS);	/* assert used on user pmaps only */
diff --git a/sys/platform/vkernel/i386/db_trace.c b/sys/platform/vkernel/i386/db_trace.c
index 6954fb0..0a4e523 100644
--- a/sys/platform/vkernel/i386/db_trace.c
+++ b/sys/platform/vkernel/i386/db_trace.c
@@ -386,7 +386,7 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
 }
 
 void
-db_print_backtrace(void)
+backtrace(void)
 {
 	register_t  ebp;
 
diff --git a/sys/vm/vm_vmspace.c b/sys/vm/vm_vmspace.c
index 2414ff9..4465a63 100644
--- a/sys/vm/vm_vmspace.c
+++ b/sys/vm/vm_vmspace.c
@@ -33,7 +33,6 @@
  * 
  * $DragonFly: src/sys/vm/vm_vmspace.c,v 1.14 2007/08/15 03:15:07 dillon Exp $
  */
-#include "opt_ddb.h"
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -49,7 +48,6 @@
 
 #include <vm/vm_extern.h>
 #include <vm/pmap.h>
-#include <ddb/ddb.h>
 
 #include <machine/vmparam.h>
 
@@ -481,9 +479,7 @@ vkernel_lwp_exit(struct lwp *lp)
 		if ((ve = vklp->ve) != NULL) {
 			kprintf("Warning, pid %d killed with "
 				"active VC!\n", lp->lwp_proc->p_pid);
-#ifdef DDB
-			db_print_backtrace();
-#endif
+			backtrace();
 			pmap_setlwpvm(lp, lp->lwp_proc->p_vmspace);
 			vklp->ve = NULL;
 			KKASSERT(ve->refs > 0);




More information about the Bugs mailing list