diff options
author | avg <avg@FreeBSD.org> | 2010-09-22 06:45:07 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2010-09-22 06:45:07 +0000 |
commit | 98648775410aacffb472684a04b9eb6a99041957 (patch) | |
tree | a518f0cad0f2d2ea8503a6ea24075ef20a0e9117 /sys/kern | |
parent | 4cccdc71390803142b8cc0867784eb3d3c52017d (diff) | |
download | FreeBSD-src-98648775410aacffb472684a04b9eb6a99041957.zip FreeBSD-src-98648775410aacffb472684a04b9eb6a99041957.tar.gz |
kdb_backtrace: use stack_print_ddb instead of stack_print
This is a followup to r212964.
stack_print call chain obtains linker sx lock and thus potentially may
lead to a deadlock depending on a kind of a panic.
stack_print_ddb doesn't acquire any locks and it doesn't use any
facilities of ddb backend.
Using stack_print_ddb outside of DDB ifdef required taking a number of
helper functions from under it as well.
It is a good idea to rename linker_ddb_* and stack_*_ddb functions to
have 'unlocked' component in their name instead of 'ddb', because those
functions do not use any DDB services, but instead they provide unlocked
access to linker symbol information. The latter was previously needed
only for DDB, hence the 'ddb' name component.
Alternative is to ditch unlocked versions altogether after implementing
proper panic handling:
1. stop other cpus upon a panic
2. make all non-spinlock lock operations (mutex, sx, rwlock) be a no-op
when panicstr != NULL
Suggested by: mdf
Discussed with: attilio
MFC after: 2 weeks
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_linker.c | 4 | ||||
-rw-r--r-- | sys/kern/subr_kdb.c | 2 | ||||
-rw-r--r-- | sys/kern/subr_stack.c | 6 |
3 files changed, 4 insertions, 8 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index dd29302..43ccd74 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -924,7 +924,6 @@ linker_debug_search_symbol_name(caddr_t value, char *buf, u_int buflen, return (0); } -#ifdef DDB /* * DDB Helpers. DDB has to look across multiple files with their own symbol * tables and string tables. @@ -933,12 +932,14 @@ linker_debug_search_symbol_name(caddr_t value, char *buf, u_int buflen, * DDB to hang because somebody's got the lock held. We'll take the chance * that the files list is inconsistant instead. */ +#ifdef DDB int linker_ddb_lookup(const char *symstr, c_linker_sym_t *sym) { return (linker_debug_lookup(symstr, sym)); } +#endif int linker_ddb_search_symbol(caddr_t value, c_linker_sym_t *sym, long *diffp) @@ -961,7 +962,6 @@ linker_ddb_search_symbol_name(caddr_t value, char *buf, u_int buflen, return (linker_debug_search_symbol_name(value, buf, buflen, offset)); } -#endif /* * stack(9) helper for non-debugging environemnts. Unlike DDB helpers, we do diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 963d0ed..5a93f87 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -308,7 +308,7 @@ kdb_backtrace(void) printf("KDB: stack backtrace:\n"); stack_save(&st); - stack_print(&st); + stack_print_ddb(&st); } #endif } diff --git a/sys/kern/subr_stack.c b/sys/kern/subr_stack.c index 6b80554..b719b71 100644 --- a/sys/kern/subr_stack.c +++ b/sys/kern/subr_stack.c @@ -44,9 +44,7 @@ static MALLOC_DEFINE(M_STACK, "stack", "Stack Traces"); static int stack_symbol(vm_offset_t pc, char *namebuf, u_int buflen, long *offset); -#ifdef DDB static int stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset); -#endif struct stack * stack_create(void) @@ -125,7 +123,6 @@ stack_print_short(struct stack *st) printf("\n"); } -#ifdef DDB void stack_print_ddb(struct stack *st) { @@ -141,6 +138,7 @@ stack_print_ddb(struct stack *st) } } +#ifdef DDB void stack_print_short_ddb(struct stack *st) { @@ -255,7 +253,6 @@ stack_symbol(vm_offset_t pc, char *namebuf, u_int buflen, long *offset) return (0); } -#ifdef DDB static int stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset) { @@ -275,4 +272,3 @@ stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset) *name = "??"; return (ENOENT); } -#endif |