From: Aleksandar Ristovski <aristovski@qnx.com>
To: gdb-patches@sources.redhat.com
Subject: Powerpc skip prologue
Date: Mon, 28 Jul 2008 20:59:00 -0000 [thread overview]
Message-ID: <g6lbth$cmp$1@ger.gmane.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1015 bytes --]
Hello,
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 based it on the Daniel's observations and my own, by disassembling several functions - they appear to have prologue that will save several general purpose registers in the ascending register index order, but not up to r31. For example, r30 only, or r28,r29 etc.
Unfortunately, I can only test this on our (Neutrino) powerpc targets.
(No ChangeLog since I can not claim this is a final and correct solution in compliance with the ABI. If it turns out that ABI allows for saving registers non-sequentially or out-of order, e.g. r28, r30, r29, then this is not good and we need a more thorough patch that would allow for such situations).
Thanks,
Aleksandar Ristovski
QNX Software Systems
[-- Attachment #2: rs6000-tdep.c.prologueissue.diff --]
[-- Type: text/plain, Size: 1533 bytes --]
Index: gdb/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
--- gdb/rs6000-tdep.c 15 Jul 2008 18:32:06 -0000 1.318
+++ gdb/rs6000-tdep.c 28 Jul 2008 20:49:24 -0000
@@ -117,6 +117,7 @@ struct rs6000_framedata
by which we decrement sp to allocate
the frame */
int saved_gpr; /* smallest # of saved gpr */
+ int saved_gpr_max; /* Largest # of saved gpr */
int saved_fpr; /* smallest # of saved fpr */
int saved_vr; /* smallest # of saved vr */
int saved_ev; /* smallest # of saved ev */
@@ -1197,6 +1198,7 @@ skip_prologue (struct gdbarch *gdbarch,
memset (fdata, 0, sizeof (struct rs6000_framedata));
fdata->saved_gpr = -1;
+ fdata->saved_gpr_max = -1;
fdata->saved_fpr = -1;
fdata->saved_vr = -1;
fdata->saved_ev = -1;
@@ -1282,6 +1284,8 @@ skip_prologue (struct gdbarch *gdbarch,
op &= ~3UL;
fdata->gpr_offset = SIGNED_SHORT (op) + offset;
}
+ if (fdata->saved_gpr_max < reg)
+ fdata->saved_gpr_max = reg;
continue;
}
@@ -2571,7 +2575,7 @@ rs6000_frame_cache (struct frame_info *t
{
int i;
CORE_ADDR gpr_addr = cache->base + fdata.gpr_offset;
- for (i = fdata.saved_gpr; i < ppc_num_gprs; i++)
+ for (i = fdata.saved_gpr; i <= fdata.saved_gpr_max; i++)
{
cache->saved_regs[tdep->ppc_gp0_regnum + i].addr = gpr_addr;
gpr_addr += wordsize;
next reply other threads:[~2008-07-28 20:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-28 20:59 Aleksandar Ristovski [this message]
2008-08-09 14:17 ` Joel Brobecker
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='g6lbth$cmp$1@ger.gmane.org' \
--to=aristovski@qnx.com \
--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