Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfa] mips heuristic_proc_start fix
@ 2001-07-06 11:20 Daniel Jacobowitz
  2001-07-06 11:27 ` Andrew Cagney
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2001-07-06 11:20 UTC (permalink / raw)
  To: gdb-patches

This one was fun to track down... I've been getting corrupt PC values off
the stack in backtraces, something which needs to be fixed elsewhere.  The
interesting thing is that the PC I was reading was 0x2.  Remember that
CORE_ADDR on MIPS is an unsigned 64-bit quantity.

There's some wrapping bugs here.  If start_pc - heuristic_fence_post wraps,
it may be greater than VM_MIN_ADDRESS, but it will also be greater than
start_pc, so we will fail - not ideal, maybe, but safe.  On the other hand,
if start_pc == 0x2, and heuristic_fence_post == 0, then fence gets set to
VM_MIN_ADDRESS (0x400000 here).  start_pc -= instlen is 0xfffffffffffffffe. 
That's above the fencepost!  Oops.

OK to commit?

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2001-07-06  Daniel Jacobowitz  <drow@mvista.com>

	* mips-tdep.c (heuristic_proc_start):  Avoid long loop if start_pc
	is corrupt.

Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.56
diff -u -r1.56 mips-tdep.c
--- mips-tdep.c	2001/07/06 05:35:17	1.56
+++ mips-tdep.c	2001/07/06 18:03:57
@@ -1506,6 +1506,13 @@
       || fence < VM_MIN_ADDRESS)
     fence = VM_MIN_ADDRESS;
 
+  if (start_pc < fence)
+    {
+      warning ("Warning: GDB can't find the start of the function at 0x%s (wraparound).",
+	       paddr_nz (pc));
+      return 0;
+    }
+
   instlen = pc_is_mips16 (pc) ? MIPS16_INSTLEN : MIPS_INSTLEN;
 
   /* search back for previous return */


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-07-12 14:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-06 11:20 [rfa] mips heuristic_proc_start fix Daniel Jacobowitz
2001-07-06 11:27 ` Andrew Cagney
2001-07-06 11:32   ` Daniel Jacobowitz
2001-07-06 11:40     ` Daniel Jacobowitz
2001-07-12  0:47       ` Andrew Cagney
2001-07-12 12:14         ` Daniel Jacobowitz
2001-07-12 14:11           ` Andrew Cagney
2001-07-12 14:19             ` Daniel Jacobowitz
2001-07-12 14:35               ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox