This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit, spu] Update all $sp slots for inferior calls
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 3 Sep 2008 23:28:43 +0200 (CEST)
- Subject: [commit, spu] Update all $sp slots for inferior calls
Hello,
the SPU ABI requires that all slots of the stack pointer registers are
updated when allocating a stack frame; this makes sure the second slot
(which holds the amount of free stack space, used for stack overflow
checks) is always up-to-date.
GDB neglected to do so when allocating space for a dummy frame. This
could potentially cause stack overflow checks to malfunction during an
inferior call.
Fixed by the patch below; tested on spu-elf; committed to mainline.
Bye,
Ulrich
ChangeLog:
* spu-tdep.c (spu_push_dummy_call): Update all stack pointer slots
when allocating stack frame for inferior call.
diff -x patches -x .pc -urNp src-orig/gdb/spu-tdep.c src/gdb/spu-tdep.c
--- src-orig/gdb/spu-tdep.c 2008-09-01 13:38:29.529390000 +0200
+++ src/gdb/spu-tdep.c 2008-09-01 19:29:26.028430141 +0200
@@ -1285,6 +1248,7 @@ spu_push_dummy_call (struct gdbarch *gdb
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ CORE_ADDR sp_delta;
int i;
int regnum = SPU_ARG1_REGNUM;
int stack_arg = -1;
@@ -1364,8 +1328,14 @@ spu_push_dummy_call (struct gdbarch *gdb
regcache_cooked_read (regcache, SPU_RAW_SP_REGNUM, buf);
target_write_memory (sp, buf, 16);
- /* Finally, update the SP register. */
- regcache_cooked_write_unsigned (regcache, SPU_SP_REGNUM, sp);
+ /* Finally, update all slots of the SP register. */
+ sp_delta = sp - extract_unsigned_integer (buf, 4);
+ for (i = 0; i < 4; i++)
+ {
+ CORE_ADDR sp_slot = extract_unsigned_integer (buf + 4*i, 4);
+ store_unsigned_integer (buf + 4*i, 4, sp_slot + sp_delta);
+ }
+ regcache_cooked_write (regcache, SPU_RAW_SP_REGNUM, buf);
return sp;
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com