Powerpc skip prologue
Joel Brobecker
brobecker@adacore.com
Sat Aug 9 14:17:00 GMT 2008
> 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
-------------- next part --------------
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;
}
}
More information about the Gdb-patches
mailing list