Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <dmj+@andrew.cmu.edu>
To: gdb-patches@sources.redhat.com
Subject: [rfa] mips heuristic_proc_start fix
Date: Fri, 06 Jul 2001 11:20:00 -0000	[thread overview]
Message-ID: <20010706112010.A5578@nevyn.them.org> (raw)

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 */


             reply	other threads:[~2001-07-06 11:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-06 11:20 Daniel Jacobowitz [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010706112010.A5578@nevyn.them.org \
    --to=dmj+@andrew.cmu.edu \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox