Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Mar 2017 18:46:35 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316001 - in head/sys: amd64/include arm/include arm64/include ddb i386/include mips/include powerpc/include riscv/include sparc64/include
Message-ID:  <201703261846.v2QIkZEq021897@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Sun Mar 26 18:46:35 2017
New Revision: 316001
URL: https://svnweb.freebsd.org/changeset/base/316001

Log:
  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.

Modified:
  head/sys/amd64/include/db_machdep.h
  head/sys/arm/include/db_machdep.h
  head/sys/arm64/include/db_machdep.h
  head/sys/ddb/db_sym.c
  head/sys/i386/include/db_machdep.h
  head/sys/mips/include/db_machdep.h
  head/sys/powerpc/include/db_machdep.h
  head/sys/riscv/include/db_machdep.h
  head/sys/sparc64/include/db_machdep.h

Modified: head/sys/amd64/include/db_machdep.h
==============================================================================
--- head/sys/amd64/include/db_machdep.h	Sun Mar 26 18:12:50 2017	(r316000)
+++ head/sys/amd64/include/db_machdep.h	Sun Mar 26 18:46:35 2017	(r316001)
@@ -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_ */

Modified: head/sys/arm/include/db_machdep.h
==============================================================================
--- head/sys/arm/include/db_machdep.h	Sun Mar 26 18:12:50 2017	(r316000)
+++ head/sys/arm/include/db_machdep.h	Sun Mar 26 18:46:35 2017	(r316001)
@@ -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);

Modified: head/sys/arm64/include/db_machdep.h
==============================================================================
--- head/sys/arm64/include/db_machdep.h	Sun Mar 26 18:12:50 2017	(r316000)
+++ head/sys/arm64/include/db_machdep.h	Sun Mar 26 18:46:35 2017	(r316001)
@@ -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_ */

Modified: head/sys/ddb/db_sym.c
==============================================================================
--- head/sys/ddb/db_sym.c	Sun Mar 26 18:12:50 2017	(r316000)
+++ head/sys/ddb/db_sym.c	Sun Mar 26 18:46:35 2017	(r316001)
@@ -432,19 +432,16 @@ db_printsym(db_expr_t off, db_strategy_t
 	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;
 	}

Modified: head/sys/i386/include/db_machdep.h
==============================================================================
--- head/sys/i386/include/db_machdep.h	Sun Mar 26 18:12:50 2017	(r316000)
+++ head/sys/i386/include/db_machdep.h	Sun Mar 26 18:46:35 2017	(r316001)
@@ -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_ */

Modified: head/sys/mips/include/db_machdep.h
==============================================================================
--- head/sys/mips/include/db_machdep.h	Sun Mar 26 18:12:50 2017	(r316000)
+++ head/sys/mips/include/db_machdep.h	Sun Mar 26 18:46:35 2017	(r316001)
@@ -87,9 +87,6 @@ db_addr_t	next_instr_address(db_addr_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 *);

Modified: head/sys/powerpc/include/db_machdep.h
==============================================================================
--- head/sys/powerpc/include/db_machdep.h	Sun Mar 26 18:12:50 2017	(r316000)
+++ head/sys/powerpc/include/db_machdep.h	Sun Mar 26 18:46:35 2017	(r316001)
@@ -87,7 +87,4 @@ typedef	intptr_t	db_expr_t;	/* expressio
 #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_ */

Modified: head/sys/riscv/include/db_machdep.h
==============================================================================
--- head/sys/riscv/include/db_machdep.h	Sun Mar 26 18:12:50 2017	(r316000)
+++ head/sys/riscv/include/db_machdep.h	Sun Mar 26 18:46:35 2017	(r316001)
@@ -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_ */

Modified: head/sys/sparc64/include/db_machdep.h
==============================================================================
--- head/sys/sparc64/include/db_machdep.h	Sun Mar 26 18:12:50 2017	(r316000)
+++ head/sys/sparc64/include/db_machdep.h	Sun Mar 26 18:46:35 2017	(r316001)
@@ -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_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703261846.v2QIkZEq021897>