[commit, spu] Enhance prologue analyzer

Ulrich Weigand uweigand@de.ibm.com
Tue Mar 2 21:27:00 GMT 2010


Hello,

we noticed that in functions with large stack frames, where the
backchain is usually stored *after* the stack pointer was decremented,
the backchain store is not always counted as part of the function
prologue by spu_analyze_prologue.

This had the unfortunate effect in the combined debugger case we
sometimes stop on a function before it has stored its backchain,
resulting in an apparent backchain value of zero -- which is taken
as a top-of-stack indication causing the combined debugger to
continue the backtrace on the PowerPC side ...

To fix this, the following patch adds tracking the backchain store
instruction as part of the prologue as well.

Tested on spu-elf.
Committed to mainline.

Bye,
Ulrich

ChangeLog:

	* spu-tdep.c (spu_analyze_prologue): Track instruction to
	store backchain as part of prologue.

Index: gdb/spu-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/spu-tdep.c,v
retrieving revision 1.54
diff -u -p -r1.54 spu-tdep.c
--- gdb/spu-tdep.c	19 Oct 2009 09:51:42 -0000	1.54
+++ gdb/spu-tdep.c	2 Mar 2010 18:37:47 -0000
@@ -633,6 +633,7 @@ spu_analyze_prologue (struct gdbarch *gd
   int found_sp = 0;
   int found_fp = 0;
   int found_lr = 0;
+  int found_bc = 0;
   int reg_immed[SPU_NUM_GPRS];
   gdb_byte buf[16];
   CORE_ADDR prolog_pc = start_pc;
@@ -661,8 +662,9 @@ spu_analyze_prologue (struct gdbarch *gd
 	- The first instruction to set up the stack pointer.
 	- The first instruction to set up the frame pointer.
 	- The first instruction to save the link register.
+	- The first instruction to save the backchain.
 
-     We return the instruction after the latest of these three,
+     We return the instruction after the latest of these four,
      or the incoming PC if none is found.  The first instruction
      to set up the stack pointer also defines the frame size.
 
@@ -771,6 +773,14 @@ spu_analyze_prologue (struct gdbarch *gd
 	      found_lr = 1;
 	      prolog_pc = pc + 4;
 	    }
+
+	  if (ra == SPU_RAW_SP_REGNUM
+	      && (found_sp? immed == 0 : rt == SPU_RAW_SP_REGNUM)
+	      && !found_bc)
+	    {
+	      found_bc = 1;
+	      prolog_pc = pc + 4;
+	    }
 	}
 
       /* _start uses SELB to set up the stack pointer.  */
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com



More information about the Gdb-patches mailing list