From 7d350e72562682a00d90dc5ccf334fed22717839 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Thu, 16 Jan 1997 11:27:11 +0000 Subject: [PATCH] Fixed printing of small offsets. E.g., -4(%ebp) is now printed as -0x4(%ebp) instead of as _APTD+0xffc(%ebp), and if GUPROF is defined, 8(%ebp) is now printed as 0x8(%ebp) instead of as GMON_PROF_HIRES+0x4(%ebp). --- sys/amd64/include/db_machdep.h | 15 +++++++++++++++ sys/ddb/db_sym.c | 10 ++++++++-- sys/i386/include/db_machdep.h | 15 +++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/sys/amd64/include/db_machdep.h b/sys/amd64/include/db_machdep.h index dae26d79371..633f4f3e3bb 100644 --- a/sys/amd64/include/db_machdep.h +++ b/sys/amd64/include/db_machdep.h @@ -73,4 +73,19 @@ extern db_regs_t ddb_regs; /* register state */ #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_ */ diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c index 0afa48abe78..7974825758a 100644 --- a/sys/ddb/db_sym.c +++ b/sys/ddb/db_sym.c @@ -274,7 +274,7 @@ db_symbol_values(sym, namep, valuep) * then we just print the value in hex. Small values might get * bogus symbol associations, e.g. 3 might get some absolute * value like _INCLUDE_VERSION or something, therefore we do - * not accept symbols whose value is zero (and use plain hex). + * not accept symbols whose value is "small" (and use plain hex). */ unsigned int db_maxoff = 0x10000; @@ -293,7 +293,13 @@ db_printsym(off, strategy) cursym = db_search_symbol(off, strategy, &d); db_symbol_values(cursym, &name, &value); - if (name == 0 || d >= db_maxoff || value == 0) { + if (name == 0) + value = off; + if (value >= DB_SMALL_VALUE_MIN && value <= DB_SMALL_VALUE_MAX) { + db_printf("%+#n", off); + return; + } + if (name == 0 || d >= db_maxoff) { db_printf("%#n", off); return; } diff --git a/sys/i386/include/db_machdep.h b/sys/i386/include/db_machdep.h index dae26d79371..633f4f3e3bb 100644 --- a/sys/i386/include/db_machdep.h +++ b/sys/i386/include/db_machdep.h @@ -73,4 +73,19 @@ extern db_regs_t ddb_regs; /* register state */ #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_ */