Don't return undefined symbols to a DDB symbol lookup.

Undefined symbols have a value of zero, so it makes no sense to return
such a symbol when performing a lookup by value. This occurs for example
when unwinding the stack after calling a NULL function pointer, and we
confusingly report the faulting function as uart_sab82532_class() on
amd64.

Convert db_print_loc_and_inst() to only attempt disassembly if we managed
to find a symbol corresponding to the IP. Otherwise we may fault and
re-enter the debugger.

Reviewed by:	jhb
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D2858
This commit is contained in:
Mark Johnston 2015-07-21 23:07:55 +00:00
parent 1a5bee0849
commit e31a60b486
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285774
2 changed files with 7 additions and 3 deletions

View File

@ -232,9 +232,13 @@ db_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
void
db_print_loc_and_inst(db_addr_t loc)
{
db_expr_t off;
db_printsym(loc, DB_STGY_PROC);
db_printf(":\t");
(void) db_disasm(loc, true);
if (db_search_symbol(loc, DB_STGY_PROC, &off) != C_DB_SYM_NULL) {
db_printf(":\t");
(void)db_disasm(loc, true);
}
}
/*

View File

@ -110,7 +110,7 @@ X_db_search_symbol(db_symtab_t *symtab, db_addr_t off, db_strategy_t strat,
diff = ~0UL;
match = NULL;
for (sym = (Elf_Sym*)symtab->start; (char*)sym < symtab->end; sym++) {
if (sym->st_name == 0)
if (sym->st_name == 0 || sym->st_shndx == SHN_UNDEF)
continue;
if (off < sym->st_value)
continue;