This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] m32r-tdep.c: Fix sign extension problem during prologue analysis


I recently learned that there were far too many testsuite failures for
the m32r-elf target.  I found that backtraces (among other things)
were badly broken and traced the problem to a lack of sign extension
for a particular instruction pattern during prologue analysis.

Comments?  (Is there a better way to do the sign extension?)

Kevin

	* m32r-tdep.c (decode_prologue): Sign extend offset for
	"addi sp, xx" case.
	(m32r_frame_unwind_cache): Likewise.

Index: m32r-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m32r-tdep.c,v
retrieving revision 1.48
diff -u -p -r1.48 m32r-tdep.c
--- m32r-tdep.c	23 Aug 2007 18:08:35 -0000	1.48
+++ m32r-tdep.c	10 Oct 2007 23:35:12 -0000
@@ -349,7 +349,7 @@ decode_prologue (CORE_ADDR start_pc, COR
       if ((insn >> 8) == 0x4f)	/* addi sp, xx */
 	/* add 8 bit sign-extended offset */
 	{
-	  int stack_adjust = (gdb_byte) (insn & 0xff);
+	  int stack_adjust = (signed char) (insn & 0xff);
 
 	  /* there are probably two of these stack adjustments:
 	     1) A negative one in the prologue, and
@@ -578,7 +578,7 @@ m32r_frame_unwind_cache (struct frame_in
       else if ((op & 0xff00) == 0x4f00)
 	{
 	  /* addi sp, xx */
-	  int n = (gdb_byte) (op & 0xff);
+	  int n = (signed char) (op & 0xff);
 	  info->sp_offset += n;
 	}
       else if (op == 0x1d8f)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]