Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: gdb-patches@sourceware.org
Cc: Kevin Buettner <kevinb@redhat.com>,
	Andrew Cagney <cagney@gnu.org>,
		strauman@slac.stanford.edu, Will Stockdell <stockdel@us.ibm.com>
Subject: RFA: Adjust PowerPC prologue analyzer for PIC
Date: Tue, 13 Dec 2005 10:17:00 -0000	[thread overview]
Message-ID: <20051211171541.GA32322@nevyn.them.org> (raw)

This patch is based on Till's patch from GNATS.  One of the three changes
(b1 in the diff attached to 2029) was fixed independently by Michael Snyder
last year, but I think it needs a small improvement: there's a comment that
says "skip over additional [mflr instructions]", and checks lr_reg < 0.  Now
that should be lr_reg == -1, since -2 means we've seen one and stored it.

(a) seems right - we should recognize "bcl 20,31,.+4" as a skippable
prologue instruction.  GCC generates this for PIC code, and in fact
backtracing out of shared libraries on GNU/Linux works badly without
recognizing this instruction.  I left out recognition for the equivalent bc
instruction.  Is there any reason I'm missing why this should be generated?

I left out (b) because I'm not sure that it's correct, and I don't have a
testcase for it.  That changed

!             && (lr_reg == -1 || fdata->nosavedpc == 0))
to
!             && (fdata->nosavedpc == 0))

but if lr_reg is -1, meaning we haven't seen an mflr, maybe we won't. I
guess that's necessary only in the case where instructions get scheduled
before the mflr?  If you still believe that's correct, let's try it
separately.

I've tested this patch on powerpc-linux, where it showed no change in the
testsuite results.  It also fixes Debian bug #312059.

Is this patch OK?

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-12-10  Daniel Jacobowitz  <dan@codesourcery.com>

	PR tdep/2029
	Suggested by Till Straumann <strauman@slac.stanford.edu>:
	* rs6000-tdep.c (skip_prologue): Update check for later mtlr
	instructions.  Handle PIC bcl.

Index: gdb-6.4/gdb/rs6000-tdep.c
===================================================================
--- gdb-6.4.orig/gdb/rs6000-tdep.c	2005-11-01 14:32:36.000000000 -0500
+++ gdb-6.4/gdb/rs6000-tdep.c	2005-12-10 00:22:15.000000000 -0500
@@ -911,7 +911,7 @@ skip_prologue (CORE_ADDR pc, CORE_ADDR l
 
 	     remember just the first one, but skip over additional
 	     ones.  */
-	  if (lr_reg < 0)
+	  if (lr_reg == -1)
 	    lr_reg = (op & 0x03e00000);
           if (lr_reg == 0)
             r0_contains_arg = 0;
@@ -1024,6 +1024,13 @@ skip_prologue (CORE_ADDR pc, CORE_ADDR l
 	  continue;
 
 	}
+      else if ((op & 0xfe80ffff) == 0x42800005 && lr_reg != -1)
+	{
+	  /* bcl 20,xx,.+4 is used to get the current PC, with or without
+	     prediction bits.  If the LR has already been saved, we can
+	     skip it.  */
+	  continue;
+	}
       else if (op == 0x48000005)
 	{			/* bl .+4 used in 
 				   -mrelocatable */


             reply	other threads:[~2005-12-11 17:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-13 10:17 Daniel Jacobowitz [this message]
2005-12-13 12:40 ` Jim Blandy
2005-12-13 17:38   ` Daniel Jacobowitz
2005-12-13 22:43 ` Mark Kettenis
2005-12-19 19:21 ` Kevin Buettner
2006-01-23  1:49   ` Daniel Jacobowitz

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=20051211171541.GA32322@nevyn.them.org \
    --to=drow@false.org \
    --cc=cagney@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=kevinb@redhat.com \
    --cc=stockdel@us.ibm.com \
    --cc=strauman@slac.stanford.edu \
    /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