mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-01 08:27:59 +00:00
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
This commit is contained in:
parent
9c2d052943
commit
61548876b1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=212994
@ -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
|
||||
|
@ -308,7 +308,7 @@ kdb_backtrace(void)
|
||||
|
||||
printf("KDB: stack backtrace:\n");
|
||||
stack_save(&st);
|
||||
stack_print(&st);
|
||||
stack_print_ddb(&st);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user