__db_print_symbol: don't try to be too smart with db_print_loc_and_inst.

We can have in a register an address that points to/into some variable
in the data segment, but db_print_loc_and_inst only looks for
functions, so it will misprint it as something unrelated from libkern
+ huge offset.  E.g. instead of netbsd:cpu_info_store it would print
netbsd:prop_string_create_cstring+0xdeadbeef

Worse, if the address happens to be odd (char field in a struct, an
element of char array), attempt at printing the "instruction" at that
address will cause a fault and will abort "mach frame".

Disassemly is not really that useful in "mach frame" listing anyway
and more often just clutters things by overflowing 80 columns.
This commit is contained in:
uwe 2006-09-06 00:11:49 +00:00
parent f6bf0450b3
commit 6cfe10b75a

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.36 2006/09/05 22:48:40 uwe Exp $ */
/* $NetBSD: db_interface.c,v 1.37 2006/09/06 00:11:49 uwe Exp $ */
/*-
* Copyright (C) 2002 UCHIYAMA Yasushi. All rights reserved.
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.36 2006/09/05 22:48:40 uwe Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.37 2006/09/06 00:11:49 uwe Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -588,13 +588,11 @@ __db_print_symbol(db_expr_t value)
const char *name;
db_expr_t offset;
db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset);
db_find_sym_and_offset((db_addr_t)value, &name, &offset);
if (name != NULL && offset <= db_maxoff && offset != value)
db_print_loc_and_inst(value);
else
db_printf("\n");
db_printsym(value, DB_STGY_ANY, db_printf);
db_printf("\n");
}
#ifdef KSTACK_DEBUG