Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Powerpc skip prologue
@ 2008-07-28 20:59 Aleksandar Ristovski
  2008-08-09 14:17 ` Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: Aleksandar Ristovski @ 2008-07-28 20:59 UTC (permalink / raw)
  To: gdb-patches

[-- 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;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-08-18 12:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-28 20:59 Powerpc skip prologue Aleksandar Ristovski
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox