diff options
author | markj <markj@FreeBSD.org> | 2015-07-21 23:07:55 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2015-07-21 23:07:55 +0000 |
commit | 8cefad6db06b1f448eee68e9585ce57ed9c1eb97 (patch) | |
tree | ccd1159c6d608481558c0bfbd1a9f8ce91ffdf8a /sys/ddb | |
parent | 2d0eee839505b6e20d1eb1cf4e57b5299cc172c3 (diff) | |
download | FreeBSD-src-8cefad6db06b1f448eee68e9585ce57ed9c1eb97.zip FreeBSD-src-8cefad6db06b1f448eee68e9585ce57ed9c1eb97.tar.gz |
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
Diffstat (limited to 'sys/ddb')
-rw-r--r-- | sys/ddb/db_examine.c | 8 | ||||
-rw-r--r-- | sys/ddb/db_main.c | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/sys/ddb/db_examine.c b/sys/ddb/db_examine.c index d4c5ed4..a41fcb5 100644 --- a/sys/ddb/db_examine.c +++ b/sys/ddb/db_examine.c @@ -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); + } } /* diff --git a/sys/ddb/db_main.c b/sys/ddb/db_main.c index 5ef6962..3345bb6 100644 --- a/sys/ddb/db_main.c +++ b/sys/ddb/db_main.c @@ -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; |