Fix printing of negative offsets (typically from frame pointers) again.

I fixed this in 1997, but the fix was over-engineered and fragile and
was broken in 2003 if not before.  i386 parameters were copied to 8
other arches verbatim, mostly after they stopped working on i386, and
mostly without the large comment saying how the values were chosen on
i386.  powerpc has a non-verbatim copy which just changes the uncritical
parameter and seems to add a sign extension bug to it.

Just treat negative offsets as offsets if they are no more negative than
-db_offset_max (default -64K), and remove all the broken parameters.

-64K is not very negative, but it is enough for frame and stack pointer
offsets since kernel stacks are small.

The over-engineering was mainly to go more negative than -64K for the
negative offset format, without affecting printing for more than a
single address.

Addresses in the top 64K of a (full 32-bit or 64-bit) address space
are now printed less well, but there aren't many interesting ones.
For arches that have many interesting ones very near the top (e.g.,
68k has interrupt vectors there), there would be no good limit for
the negative offset format and -64K is a good as anything.
This commit is contained in:
bde 2017-03-26 18:46:35 +00:00
parent b1c33e0ea0
commit 254458ab34
9 changed files with 4 additions and 55 deletions

View File

@ -81,19 +81,4 @@ do { \
#define inst_load(ins) 0
#define inst_store(ins) 0
/*
* There no interesting addresses below _kstack = 0xefbfe000. There
* are small absolute values for GUPROF, but we don't want to see them.
* Treat "negative" addresses below _kstack as non-small to allow for
* future reductions of _kstack and to avoid sign extension problems.
*
* There is one interesting symbol above -db_maxoff = 0xffff0000,
* namely _APTD = 0xfffff000. Accepting this would mess up the
* printing of small negative offsets. The next largest symbol is
* _APTmap = 0xffc00000. Accepting this is OK (unless db_maxoff is
* set to >= 0x400000 - (max stack offset)).
*/
#define DB_SMALL_VALUE_MAX 0x7fffffff
#define DB_SMALL_VALUE_MIN (-0x400001)
#endif /* !_MACHINE_DB_MACHDEP_H_ */

View File

@ -89,9 +89,6 @@ typedef int db_expr_t;
#define next_instr_address(pc, bd) ((bd) ? (pc) : ((pc) + INSN_SIZE))
#define DB_SMALL_VALUE_MAX (0x7fffffff)
#define DB_SMALL_VALUE_MIN (-0x40001)
#define DB_ELFSIZE 32
int db_validate_address(vm_offset_t);

View File

@ -118,9 +118,6 @@ typedef long db_expr_t;
#define next_instr_address(pc, bd) ((bd) ? (pc) : ((pc) + 4))
#define DB_SMALL_VALUE_MAX (0x7fffffff)
#define DB_SMALL_VALUE_MIN (-0x40001)
#define DB_ELFSIZE 64
#endif /* !_MACHINE_DB_MACHDEP_H_ */

View File

@ -432,19 +432,16 @@ db_printsym(db_expr_t off, db_strategy_t strategy)
db_expr_t d;
char *filename;
const char *name;
db_expr_t value;
int linenum;
c_db_sym_t cursym;
cursym = db_search_symbol(off, strategy, &d);
db_symbol_values(cursym, &name, &value);
if (name == NULL)
value = off;
if (value >= DB_SMALL_VALUE_MIN && value <= DB_SMALL_VALUE_MAX) {
if (off < 0 && off >= -db_maxoff) {
db_printf("%+#lr", (long)off);
return;
}
if (name == NULL || d >= (unsigned long)db_maxoff) {
cursym = db_search_symbol(off, strategy, &d);
db_symbol_values(cursym, &name, NULL);
if (name == NULL || d >= (db_addr_t)db_maxoff) {
db_printf("%#lr", (unsigned long)off);
return;
}

View File

@ -83,21 +83,6 @@ do { \
#define inst_load(ins) 0
#define inst_store(ins) 0
/*
* There no interesting addresses below _kstack = 0xefbfe000. There
* are small absolute values for GUPROF, but we don't want to see them.
* Treat "negative" addresses below _kstack as non-small to allow for
* future reductions of _kstack and to avoid sign extension problems.
*
* There is one interesting symbol above -db_maxoff = 0xffff0000,
* namely _APTD = 0xfffff000. Accepting this would mess up the
* printing of small negative offsets. The next largest symbol is
* _APTmap = 0xffc00000. Accepting this is OK (unless db_maxoff is
* set to >= 0x400000 - (max stack offset)).
*/
#define DB_SMALL_VALUE_MAX 0x7fffffff
#define DB_SMALL_VALUE_MIN (-0x400001)
int db_segsize(struct trapframe *tfp);
#endif /* !_MACHINE_DB_MACHDEP_H_ */

View File

@ -87,9 +87,6 @@ db_addr_t next_instr_address(db_addr_t, boolean_t);
#define inst_load(i) (db_inst_type(i) == IT_LOAD)
#define inst_store(i) (db_inst_type(i) == IT_STORE)
#define DB_SMALL_VALUE_MAX 0x7fffffff
#define DB_SMALL_VALUE_MIN (-0x400001)
int db_inst_type(int);
db_addr_t branch_taken(int inst, db_addr_t pc);
int32_t kdbpeek(int *);

View File

@ -87,7 +87,4 @@ typedef intptr_t db_expr_t; /* expression - signed */
#define inst_load(ins) 0
#define inst_store(ins) 0
#define DB_SMALL_VALUE_MAX (KERNBASE-1)
#define DB_SMALL_VALUE_MIN (-0x40001)
#endif /* _POWERPC_DB_MACHDEP_H_ */

View File

@ -83,9 +83,6 @@ typedef long db_expr_t;
#define next_instr_address(pc, bd) ((bd) ? (pc) : ((pc) + 4))
#define DB_SMALL_VALUE_MAX (0x7fffffff)
#define DB_SMALL_VALUE_MIN (-0x40001)
#define DB_ELFSIZE 64
#endif /* !_MACHINE_DB_MACHDEP_H_ */

View File

@ -61,9 +61,6 @@ typedef long db_expr_t;
#define inst_load(ins) (0)
#define inst_store(ins) (0)
#define DB_SMALL_VALUE_MAX (0x7fffffff)
#define DB_SMALL_VALUE_MIN (-0x40001)
#define DB_ELFSIZE 64
#endif /* !_MACHINE_DB_MACHDEP_H_ */