print_backtrace - Take parameter count
authorAlex Hornung <ahornung@gmail.com>
Wed, 31 Mar 2010 10:44:25 +0000 (10:44 +0000)
committerAlex Hornung <ahornung@gmail.com>
Thu, 15 Apr 2010 20:24:49 +0000 (20:24 +0000)
* Modify print_backtrace to take a parameter 'count' that specifies the
  maximum number of frames to print for the backtrace.

* Change all current consumers to use the new print_backtrace with count
  -1, resulting in the same behaviour as before this change.

* Remove cruft in dsched_fq that simulated this behaviour previously.

25 files changed:
sys/dev/acpica5/Osd/OsdSynch.c
sys/dsched/fq/dsched_fq_core.c
sys/kern/kern_debug.c
sys/kern/kern_shutdown.c
sys/kern/kern_spinlock.c
sys/kern/kern_timeout.c
sys/kern/lwkt_thread.c
sys/kern/uipc_mbuf.c
sys/kern/vfs_bio.c
sys/kern/vfs_lock.c
sys/net/route.c
sys/netinet/ip_output.c
sys/platform/pc32/i386/busdma_machdep.c
sys/platform/pc32/i386/db_trace.c
sys/platform/pc32/i386/pmap.c
sys/platform/pc64/x86_64/busdma_machdep.c
sys/platform/pc64/x86_64/db_trace.c
sys/platform/vkernel/i386/db_trace.c
sys/platform/vkernel/platform/busdma_machdep.c
sys/platform/vkernel64/platform/busdma_machdep.c
sys/platform/vkernel64/x86_64/db_trace.c
sys/sys/systm.h
sys/vfs/nfs/nfs_socket.c
sys/vfs/tmpfs/tmpfs_vfsops.c
sys/vm/vm_vmspace.c

index d6f0e47..03edf31 100644 (file)
@@ -382,7 +382,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);
-       print_backtrace();
+       print_backtrace(-1);
     } else {
        Spin->owner = curthread;
        Spin->func = func;
@@ -400,7 +400,7 @@ AcpiOsReleaseLock (ACPI_SPINLOCK Spin, ACPI_CPU_FLAGS 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);
-           print_backtrace();
+           print_backtrace(-1);
        } else
            return;
     }
index 1425202..b08dc09 100644 (file)
@@ -85,18 +85,6 @@ struct callout       fq_callout;
 
 extern struct dsched_ops dsched_fq_ops;
 
-void db_stack_trace_cmd(int addr, boolean_t have_addr, int count,char *modif);
-void fq_print_backtrace(void);
-
-void
-fq_print_backtrace(void)
-{
-       register_t  ebp;
-
-       __asm __volatile("movl %%ebp, %0" : "=r" (ebp));
-       db_stack_trace_cmd(ebp, 1, 4, NULL);
-}
-
 void
 fq_reference_dpriv(struct dsched_fq_dpriv *dpriv)
 {
@@ -142,7 +130,7 @@ fq_dereference_dpriv(struct dsched_fq_dpriv *dpriv)
                atomic_subtract_int(&dpriv->refcount, 3); /* mark as: in destruction */
 #if 1
                kprintf("dpriv (%p) destruction started, trace:\n", dpriv);
-               fq_print_backtrace();
+               print_backtrace(4);
 #endif
                spin_lock_wr(&dpriv->lock);
                TAILQ_FOREACH_MUTABLE(fqp, &dpriv->fq_priv_list, dlink, fqp2) {
@@ -172,7 +160,7 @@ fq_dereference_priv(struct dsched_fq_priv *fqp)
                atomic_subtract_int(&fqp->refcount, 3); /* mark as: in destruction */
 #if 0
                kprintf("fqp (%p) destruction started, trace:\n", fqp);
-               fq_print_backtrace();
+               print_backtrace(8);
 #endif
                dpriv = fqp->dpriv;
                KKASSERT(dpriv != NULL);
@@ -226,7 +214,7 @@ fq_dereference_mpriv(struct dsched_fq_mpriv *fqmp)
                atomic_subtract_int(&fqmp->refcount, 3); /* mark as: in destruction */
 #if 0
                kprintf("fqmp (%p) destruction started, trace:\n", fqmp);
-               fq_print_backtrace();
+               print_backtrace(8);
 #endif
                FQ_GLOBAL_FQMP_LOCK();
                spin_lock_wr(&fqmp->lock);
index bb6115f..6108f3e 100644 (file)
@@ -82,7 +82,7 @@
  */
 #ifndef DDB
 void
-print_backtrace(void)
+print_backtrace(int count __unused)
 {
                kprintf("Cannot print stack trace.\n");
                kprintf("DDB kernel option is needed.\n");
index 199eed0..e19c240 100644 (file)
@@ -737,7 +737,7 @@ panic(const char *fmt, ...)
 
 #if defined(DDB)
        if (newpanic && trace_on_panic)
-               print_backtrace();
+               print_backtrace(-1);
        if (debugger_on_panic)
                Debugger("panic");
 #endif
index 11026bf..96c57cb 100644 (file)
@@ -306,14 +306,14 @@ exponential_backoff(struct exponential_backoff *bo)
                        return (TRUE);
 #if defined(INVARIANTS)
                if (spin_lock_test_mode) {
-                       print_backtrace();
+                       print_backtrace(-1);
                        return (TRUE);
                }
 #endif
                ++bo->nsec;
 #if defined(INVARIANTS)
                if (bo->nsec == 11)
-                       print_backtrace();
+                       print_backtrace(-1);
 #endif
                if (bo->nsec == 60)
                        panic("spin_lock: %p, indefinite wait!\n", bo->mtx);
index 189ffb0..279431a 100644 (file)
@@ -359,7 +359,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]);
-               print_backtrace();
+               print_backtrace(-1);
        }
 #endif
        gd = mycpu;
@@ -412,7 +412,7 @@ callout_stop(struct callout *c)
                kprintf(
                    "callout_stop(%p) from %p: callout was not initialized\n",
                    c, ((int **)&c)[-1]);
-               print_backtrace();
+               print_backtrace(-1);
        }
 #endif
        crit_enter_gd(gd);
index 8eabc98..a8282e2 100644 (file)
@@ -496,7 +496,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);
-               print_backtrace();
+               print_backtrace(-1);
            }
            lwkt_switch();
            gd->gd_intr_nesting_level = savegdnest;
index 9934d1e..1b2a53f 100644 (file)
@@ -926,7 +926,7 @@ m_free(struct mbuf *m)
 
                if (afewtimes-- > 0) {
                        kprintf("mfree: m->m_nextpkt != NULL\n");
-                       print_backtrace();
+                       print_backtrace(-1);
                }
                m->m_nextpkt = NULL;
        }
index 20969f9..ea10c0e 100644 (file)
@@ -4105,7 +4105,7 @@ vfs_clean_one_page(struct buf *bp, int pageno, vm_page_t m)
                                bp->b_dirtyoff, bp->b_dirtyend);
                        bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK);
                        if (debug_commit)
-                               print_backtrace();
+                               print_backtrace(-1);
                }
                /*
                 * Only clear the pmap modified bits if ALL the dirty bits
index 242d7e3..1c66ef3 100644 (file)
@@ -192,7 +192,7 @@ __vfree(struct vnode *vp)
 #ifdef TRACKVNODE
        if ((ulong)vp == trackvnode) {
                kprintf("__vfree %p %08x\n", vp, vp->v_flag);
-               print_backtrace();
+               print_backtrace(-1);
        }
 #endif
        spin_lock_wr(&vfs_spin);
index 74958b5..712973e 100644 (file)
@@ -384,7 +384,7 @@ rtfree_remote(struct rtentry *rt, int allow_panic)
        } else {
                kprintf("rt remote free rt_cpuid %d, mycpuid %d\n",
                        rt->rt_cpuid, mycpuid);
-               print_backtrace();
+               print_backtrace(-1);
        }
 
        netmsg_init(&nmsg, NULL, &curthread->td_msgport,
@@ -1423,7 +1423,7 @@ rt_addrinfo_print(int cmd, struct rt_addrinfo *rti)
 
 #ifdef ROUTE_DEBUG
        if (cmd == RTM_DELETE && route_debug > 1)
-               print_backtrace();
+               print_backtrace(-1);
 #endif
 
        switch(cmd) {
index c6d7995..29cbae6 100644 (file)
@@ -229,7 +229,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro,
                                kprintf("ip_output: "
                                        "rt rt_cpuid %d accessed on cpu %d\n",
                                        ro->ro_rt->rt_cpuid, mycpuid);
-                               print_backtrace();
+                               print_backtrace(-1);
                        }
                }
 
index b880bf7..686311d 100644 (file)
@@ -255,7 +255,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
                        panic("boundary must be power of 2\n");
                if (boundary < maxsegsz) {
                        kprintf("boundary < maxsegsz:\n");
-                       print_backtrace();
+                       print_backtrace(-1);
                        maxsegsz = boundary;
                }
        }
@@ -493,14 +493,14 @@ check_kmalloc(bus_dma_tag_t dmat, const void *vaddr0, int verify)
                if (verify || bootverbose)
                        kprintf("boundary check failed\n");
                if (verify)
-                       print_backtrace(); /* XXX panic */
+                       print_backtrace(-1); /* XXX panic */
                maxsize = dmat->maxsize;
        }
        if (vaddr & (dmat->alignment - 1)) {
                if (verify || bootverbose)
                        kprintf("alignment check failed\n");
                if (verify)
-                       print_backtrace(); /* XXX panic */
+                       print_backtrace(-1); /* XXX panic */
                if (dmat->maxsize < dmat->alignment)
                        maxsize = dmat->alignment;
                else
index 355be8a..d5eeed6 100644 (file)
@@ -435,12 +435,12 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
 }
 
 void
-print_backtrace(void)
+print_backtrace(int count)
 {
        register_t  ebp;
 
        __asm __volatile("movl %%ebp, %0" : "=r" (ebp));
-       db_stack_trace_cmd(ebp, 1, -1, NULL);
+       db_stack_trace_cmd(ebp, 1, count, NULL);
 }
 
 #define DB_DRX_FUNC(reg)                                               \
index d7ea947..bbac355 100644 (file)
@@ -2110,11 +2110,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");
-               print_backtrace();
+               print_backtrace(-1);
        }
        if (va >= UPT_MAX_ADDRESS && pmap != &kernel_pmap) {
                kprintf("Warning: pmap_enter called on KVA without kernel_pmap\n");
-               print_backtrace();
+               print_backtrace(-1);
        }
 
        /*
@@ -2294,11 +2294,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");
-               print_backtrace();
+               print_backtrace(-1);
        }
        if (va >= UPT_MAX_ADDRESS && pmap != &kernel_pmap) {
                kprintf("Warning: pmap_enter_quick called on KVA without kernel_pmap\n");
-               print_backtrace();
+               print_backtrace(-1);
        }
 
        KKASSERT(va < UPT_MIN_ADDRESS); /* assert used on user pmaps only */
index b880bf7..686311d 100644 (file)
@@ -255,7 +255,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
                        panic("boundary must be power of 2\n");
                if (boundary < maxsegsz) {
                        kprintf("boundary < maxsegsz:\n");
-                       print_backtrace();
+                       print_backtrace(-1);
                        maxsegsz = boundary;
                }
        }
@@ -493,14 +493,14 @@ check_kmalloc(bus_dma_tag_t dmat, const void *vaddr0, int verify)
                if (verify || bootverbose)
                        kprintf("boundary check failed\n");
                if (verify)
-                       print_backtrace(); /* XXX panic */
+                       print_backtrace(-1); /* XXX panic */
                maxsize = dmat->maxsize;
        }
        if (vaddr & (dmat->alignment - 1)) {
                if (verify || bootverbose)
                        kprintf("alignment check failed\n");
                if (verify)
-                       print_backtrace(); /* XXX panic */
+                       print_backtrace(-1); /* XXX panic */
                if (dmat->maxsize < dmat->alignment)
                        maxsize = dmat->alignment;
                else
index 3ccef35..fef29c5 100644 (file)
@@ -443,12 +443,12 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
 }
 
 void
-print_backtrace(void)
+print_backtrace(int count)
 {
        register_t  rbp;
 
        __asm __volatile("movq %%rbp, %0" : "=r" (rbp));
-       db_stack_trace_cmd(rbp, 1, -1, NULL);
+       db_stack_trace_cmd(rbp, 1, count, NULL);
 }
 
 #define DB_DRX_FUNC(reg)                                               \
index 5dab6bd..87b301e 100644 (file)
@@ -386,12 +386,12 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
 }
 
 void
-print_backtrace(void)
+print_backtrace(int count)
 {
        register_t  ebp;
 
        __asm __volatile("movl %%ebp, %0" : "=r" (ebp));
-       db_stack_trace_cmd(ebp, 1, -1, NULL);
+       db_stack_trace_cmd(ebp, 1, count, NULL);
 }
 
 static int
index 2523dd1..14263d5 100644 (file)
@@ -223,7 +223,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
                        panic("boundary must be power of 2\n");
                if (boundary < maxsegsz) {
                        kprintf("boundary < maxsegsz:\n");
-                       print_backtrace();
+                       print_backtrace(-1);
                        maxsegsz = boundary;
                }
        }
@@ -452,14 +452,14 @@ check_kmalloc(bus_dma_tag_t dmat, const void *vaddr0, int verify)
                if (verify || bootverbose)
                        kprintf("boundary check failed\n");
                if (verify)
-                       print_backtrace(); /* XXX panic */
+                       print_backtrace(-1); /* XXX panic */
                maxsize = dmat->maxsize;
        }
        if (vaddr & (dmat->alignment - 1)) {
                if (verify || bootverbose)
                        kprintf("alignment check failed\n");
                if (verify)
-                       print_backtrace(); /* XXX panic */
+                       print_backtrace(-1); /* XXX panic */
                if (dmat->maxsize < dmat->alignment)
                        maxsize = dmat->alignment;
                else
index 986ba9a..6d1842a 100644 (file)
@@ -221,7 +221,7 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
                        panic("boundary must be power of 2\n");
                if (boundary < maxsegsz) {
                        kprintf("boundary < maxsegsz:\n");
-                       print_backtrace();
+                       print_backtrace(-1);
                        maxsegsz = boundary;
                }
        }
@@ -449,13 +449,13 @@ check_kmalloc(bus_dma_tag_t dmat, const void *vaddr0, int verify)
        if ((vaddr ^ (vaddr + dmat->maxsize - 1)) & ~PAGE_MASK) {
                kprintf("boundary check failed\n");
                if (verify)
-                       print_backtrace(); /* XXX panic */
+                       print_backtrace(-1); /* XXX panic */
                maxsize = dmat->maxsize;
        }
        if (vaddr & (dmat->alignment - 1)) {
                kprintf("alignment check failed\n");
                if (verify)
-                       print_backtrace(); /* XXX panic */
+                       print_backtrace(-1); /* XXX panic */
                if (dmat->maxsize < dmat->alignment)
                        maxsize = dmat->alignment;
                else
index b86c9c5..90c11e7 100644 (file)
@@ -444,12 +444,12 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
 }
 
 void
-print_backtrace(void)
+print_backtrace(int count)
 {
        register_t  rbp;
 
        __asm __volatile("movq %%rbp, %0" : "=r" (rbp));
-       db_stack_trace_cmd(rbp, 1, -1, NULL);
+       db_stack_trace_cmd(rbp, 1, count, NULL);
 }
 
 #define DB_DRX_FUNC(reg)                                               \
index 60b22b0..bf4b166 100644 (file)
@@ -143,7 +143,7 @@ struct savetls;
 struct krate;
 
 void   Debugger (const char *msg);
-void   print_backtrace(void);
+void   print_backtrace(int count);
 void   mi_gdinit (struct globaldata *gd, int cpu);
 void   mi_proc0init(struct globaldata *gd, struct user *proc0paddr);
 int    nullop (void);
index 23e0d01..7399d00 100644 (file)
@@ -1240,7 +1240,7 @@ nfs_request_try(struct nfsreq *rep)
         * action possible is for r_mrep to be set (once we enqueue it).
         */
        if (rep->r_flags == 0xdeadc0de) {
-               print_backtrace();
+               print_backtrace(-1);
                panic("flags nbad\n");
        }
        KKASSERT((rep->r_flags & (R_LOCKED | R_ONREQQ)) == 0);
index 470b61f..2dc8e55 100644 (file)
@@ -410,7 +410,7 @@ tmpfs_root(struct mount *mp, struct vnode **vpp)
        tmp = VFS_TO_TMPFS(mp);
        if (tmp->tm_root == NULL) {
                kprintf("tmpfs_root: called without root node %p\n", mp);
-               print_backtrace();
+               print_backtrace(-1);
                *vpp = NULL;
                error = EINVAL;
        } else {
index b76d00d..686cb06 100644 (file)
@@ -595,7 +595,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);
-                       print_backtrace();
+                       print_backtrace(-1);
                        pmap_setlwpvm(lp, lp->lwp_proc->p_vmspace);
                        vklp->ve = NULL;
                        KKASSERT(ve->refs > 0);