Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Aleksandar Ristovski <aristovski@qnx.com>
Cc: gdb-patches@sources.redhat.com, Jerome Guitton <guitton@adacore.com>
Subject: Re: Powerpc skip prologue
Date: Sat, 09 Aug 2008 14:17:00 -0000	[thread overview]
Message-ID: <20080809141651.GB4936@adacore.com> (raw)
In-Reply-To: <g6lbth$cmp$1@ger.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1072 bytes --]

> GDB assumes the gpr registers will be saved starting from a rN register up 
> to r31. This assumption doesn't seem to be right. See this: 
> http://sourceware.org/ml/gdb-patches/2007-12/msg00111.html and this: 
> http://sourceware.org/ml/gdb/2008-07/msg00279.html
> 
> So I devised a micro-patch for handling the saved gprs.

I just realized that we faced the same problem and forgot to submit
the patch to the FSF. The ABI doesn't say anything about requiring
that a sequence of registers be saved, which is why we introduced
the use of a map rather than just save the lowest/highest register
number.

I propose to commit the following in a week unless there are comments/
objections:

2008-08-09  Jerome Guitton  <guitton@adacore.com>

        * rs6000-tdep.c (rs6000_framedata): Add new field.
        (SET_REG_IN_MAP, GET_REG_IN_MAP): New macros.
        (skip_prologue): Update register map when a register is saved.
        (rs6000_frame_cache): Only set register address if the corresponding
        register has been saved.

Tested on ppc-aix.

Cheers,
-- 
Joel

[-- Attachment #2: rs6000-tdep.diff --]
[-- Type: text/plain, Size: 2563 bytes --]

Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.318
diff -u -p -r1.318 rs6000-tdep.c
--- rs6000-tdep.c	15 Jul 2008 18:32:06 -0000	1.318
+++ rs6000-tdep.c	9 Aug 2008 14:12:58 -0000
@@ -117,6 +117,9 @@ struct rs6000_framedata
 				   by which we decrement sp to allocate
 				   the frame */
     int saved_gpr;		/* smallest # of saved gpr */
+    unsigned int saved_gpr_map; /* saved gpr map; for any reg in gprs,
+                                   iff bit "# of reg" of saved_gprs_map is 1
+                                   then reg is saved */
     int saved_fpr;		/* smallest # of saved fpr */
     int saved_vr;               /* smallest # of saved vr */
     int saved_ev;               /* smallest # of saved ev */
@@ -1042,6 +1045,9 @@ ppc_deal_with_atomic_sequence (struct fr
 
 #define GET_SRC_REG(x) (((x) >> 21) & 0x1f)
 
+#define SET_REG_IN_MAP(map,x) ((map |= 1 << x))
+#define GET_REG_IN_MAP(map,x) ((map & (1 << x)))
+
 /* Limit the number of skipped non-prologue instructions, as the examining
    of the prologue is expensive.  */
 static int max_skip_non_prologue_insns = 10;
@@ -1155,6 +1161,7 @@ bl_to_blrl_insn_p (CORE_ADDR pc, int ins
    - offset is the initial size of this stack frame --- the amount by
    which we decrement the sp to allocate the frame.
    - saved_gpr is the number of the first saved gpr.
+   - saved_gpr_map is the map of saved gprs.
    - saved_fpr is the number of the first saved fpr.
    - saved_vr is the number of the first saved vr.
    - saved_ev is the number of the first saved ev.
@@ -1197,6 +1204,7 @@ skip_prologue (struct gdbarch *gdbarch, 
 
   memset (fdata, 0, sizeof (struct rs6000_framedata));
   fdata->saved_gpr = -1;
+  fdata->saved_gpr_map = 0;
   fdata->saved_fpr = -1;
   fdata->saved_vr = -1;
   fdata->saved_ev = -1;
@@ -1275,6 +1283,7 @@ skip_prologue (struct gdbarch *gdbarch, 
 	{
 
 	  reg = GET_SRC_REG (op);
+          SET_REG_IN_MAP (fdata->saved_gpr_map, reg);
 	  if (fdata->saved_gpr == -1 || fdata->saved_gpr > reg)
 	    {
 	      fdata->saved_gpr = reg;
@@ -2573,7 +2582,8 @@ rs6000_frame_cache (struct frame_info *t
       CORE_ADDR gpr_addr = cache->base + fdata.gpr_offset;
       for (i = fdata.saved_gpr; i < ppc_num_gprs; i++)
 	{
-	  cache->saved_regs[tdep->ppc_gp0_regnum + i].addr = gpr_addr;
+          if (GET_REG_IN_MAP (fdata.saved_gpr_map,i))
+            cache->saved_regs[tdep->ppc_gp0_regnum + i].addr = gpr_addr;
 	  gpr_addr += wordsize;
 	}
     }

  reply	other threads:[~2008-08-09 14:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-28 20:59 Aleksandar Ristovski
2008-08-09 14:17 ` Joel Brobecker [this message]
2008-08-09 16:12   ` Daniel Jacobowitz
2008-08-10  2:45     ` Joel Brobecker
2008-08-18 10:10       ` Joel Brobecker
2008-08-18 12:35         ` 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=20080809141651.GB4936@adacore.com \
    --to=brobecker@adacore.com \
    --cc=aristovski@qnx.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=guitton@adacore.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