diff options
| author | christos <christos@NetBSD.org> | 2015-02-08 19:41:00 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2015-02-08 19:41:00 +0000 |
| commit | 165a895eb016a1bdf4f213bfe4c7ea09f92c51c3 (patch) | |
| tree | 432a964d618fd8678568833ac636ae0bfa3aae7f /sys | |
| parent | 17562e206ba52b134ca0c48b7f8583e85b1300ca (diff) | |
make the ddb code crash(8) friendly.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/kern/kern_timeout.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index f01d364bca3..531f08d7a40 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.48 2014/12/10 17:09:49 martin Exp #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 @@ do { \ #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 @@ struct callout_cpu { 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 @@ callout_softclock(void *v) 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 @@ db_show_callout_bucket(struct callout_cpu *cc, struct callout_circq *bucket) 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 @@ db_show_callout(db_expr_t addr, bool haddr, db_expr_t count, const char *modif) * 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]); } } |
