Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern make the ddb code crash(8) friendly.



details:   https://anonhg.NetBSD.org/src/rev/19bcbe7aec63
branches:  trunk
changeset: 336051:19bcbe7aec63
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Feb 08 19:41:00 2015 +0000

description:
make the ddb code crash(8) friendly.

diffstat:

 sys/kern/kern_timeout.c |  36 ++++++++++++++++++++++++++----------
 1 files changed, 26 insertions(+), 10 deletions(-)

diffs (114 lines):

diff -r 76401f88a7fa -r 19bcbe7aec63 sys/kern/kern_timeout.c
--- a/sys/kern/kern_timeout.c   Sun Feb 08 19:39:09 2015 +0000
+++ b/sys/kern/kern_timeout.c   Sun Feb 08 19:41:00 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_timeout.c,v 1.48 2014/12/10 17:09:49 martin Exp $ */
+/*     $NetBSD: kern_timeout.c,v 1.49 2015/02/08 19:41:00 christos Exp $       */
 
 /*-
  * Copyright (c) 2003, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.48 2014/12/10 17:09:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.49 2015/02/08 19:41:00 christos Exp $");
 
 /*
  * Timeouts are kept in a hierarchical timing wheel.  The c_time is the
@@ -101,6 +101,7 @@
 #include <machine/db_machdep.h>
 #include <ddb/db_interface.h>
 #include <ddb/db_access.h>
+#include <ddb/db_cpu.h>
 #include <ddb/db_sym.h>
 #include <ddb/db_output.h>
 #endif
@@ -165,8 +166,6 @@
 #define CIRCQ_LAST(elem,list)  ((elem)->cq_next_l == (list))
 #define CIRCQ_EMPTY(list)      ((list)->cq_next_l == (list))
 
-static void    callout_softclock(void *);
-
 struct callout_cpu {
        kmutex_t        *cc_lock;
        sleepq_t        cc_sleepq;
@@ -183,6 +182,9 @@
        char            cc_name2[12];
 };
 
+#ifndef CRASH
+
+static void    callout_softclock(void *);
 static struct callout_cpu callout_cpu0;
 static void *callout_sih;
 
@@ -757,21 +759,32 @@
        cc->cc_lwp = NULL;
        mutex_spin_exit(cc->cc_lock);
 }
+#endif
 
 #ifdef DDB
 static void
 db_show_callout_bucket(struct callout_cpu *cc, struct callout_circq *bucket)
 {
-       callout_impl_t *c;
+       callout_impl_t *c, ci;
        db_expr_t offset;
        const char *name;
        static char question[] = "?";
+       struct callout_circq bi;
+       struct callout_cpu cci;
        int b;
 
+       db_read_bytes((db_addr_t)cc, sizeof(cci), (char *)&cci);
+       cc = &cci;
+
+       db_read_bytes((db_addr_t)bucket, sizeof(bi), (char *)&bi);
+       bucket = &bi;
+
        if (CIRCQ_EMPTY(bucket))
                return;
 
        for (c = CIRCQ_FIRST(bucket); /*nothing*/; c = CIRCQ_NEXT(&c->c_list)) {
+               db_read_bytes((db_addr_t)c, sizeof(ci), (char *)&ci);
+               c = &ci;
                db_find_sym_and_offset((db_addr_t)(intptr_t)c->c_func, &name,
                    &offset);
                name = name ? name : question;
@@ -789,12 +802,13 @@
 void
 db_show_callout(db_expr_t addr, bool haddr, db_expr_t count, const char *modif)
 {
-       CPU_INFO_ITERATOR cii;
        struct callout_cpu *cc;
        struct cpu_info *ci;
        int b;
 
+#ifndef CRASH
        db_printf("hardclock_ticks now: %d\n", hardclock_ticks);
+#endif
        db_printf("    ticks  wheel               arg  func\n");
 
        /*
@@ -802,13 +816,15 @@
         * anyhow, and we might be called in a circumstance where
         * some other CPU was paused while holding the lock.
         */
-       for (CPU_INFO_FOREACH(cii, ci)) {
-               cc = ci->ci_data.cpu_callout;
+       for (ci = db_cpu_first(); ci != NULL; ci = db_cpu_next(ci)) {
+               db_read_bytes((db_addr_t)&ci->ci_data.cpu_callout,
+                   sizeof(cc), (char *)&cc);
                db_show_callout_bucket(cc, &cc->cc_todo);
        }
        for (b = 0; b < BUCKETS; b++) {
-               for (CPU_INFO_FOREACH(cii, ci)) {
-                       cc = ci->ci_data.cpu_callout;
+               for (ci = db_cpu_first(); ci != NULL; ci = db_cpu_next(ci)) {
+                       db_read_bytes((db_addr_t)&ci->ci_data.cpu_callout,
+                           sizeof(cc), (char *)&cc);
                        db_show_callout_bucket(cc, &cc->cc_wheel[b]);
                }
        }



Home | Main Index | Thread Index | Old Index