This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
mips-tdep.c: Fix new-ABI handling of composite types
- From: "Maciej W. Rozycki" <macro at mips dot com>
- To: gdb-patches at sourceware dot org
- Cc: David Ung <davidu at mips dot com>, "Maciej W. Rozycki" <macro at linux-mips dot org>
- Date: Fri, 21 Sep 2007 16:27:45 +0100 (BST)
- Subject: mips-tdep.c: Fix new-ABI handling of composite types
Hello,
This patch fixes 2 new-ABI regressions in the test suite. Here's David's
original comment attached to the change:
"Currently if structs size is not a multiple of mips_abi_regsize(),
they are put in both places (stack and argument registers). But
the N32/N64 abi says that the caller does not reserve space for
the register arguments, it's upto the callee to do that. Doing so
inside gdb would cause the simulated program to incorrectly access
fields of the struct if the size of the struct extends pass the
argument registers onto the stack."
The comment within the change provides a similar explanation.
Tested for n32 using the mipsisa32-sde-elf target, with the
mips-sim-sde64/-mips64/-EB and mips-sim-sde64/-mips64/-EL boards removing
the following failures:
(gdb) FAIL: gdb.base/call-ar-st.exp: print sum_array_print(10, *list1, *list2, *list3, *list4)
(gdb) FAIL: gdb.base/call-rt-st.exp: print print_one_large_struct(*list1)
2007-09-21 David Ung <davidu@mips.com>
Maciej W. Rozycki <macro@mips.com>
* mips-tdep.c (mips_n32n64_push_dummy_call): Per N32/N64 ABI
rules do not treat composite types specially.
OK to apply?
Maciej
12430.diff
Index: binutils-quilt/src/gdb/mips-tdep.c
===================================================================
--- binutils-quilt.orig/src/gdb/mips-tdep.c 2007-08-28 16:16:55.000000000 +0100
+++ binutils-quilt/src/gdb/mips-tdep.c 2007-08-28 16:53:33.000000000 +0100
@@ -2928,12 +2928,14 @@
/* Copy the argument to general registers or the stack in
register-sized pieces. Large arguments are split between
registers and stack. */
- /* Note: structs whose size is not a multiple of MIPS64_REGSIZE
- are treated specially: Irix cc passes them in registers
- where gcc sometimes puts them on the stack. For maximum
- compatibility, we will put them in both places. */
- int odd_sized_struct = (len > MIPS64_REGSIZE
- && len % MIPS64_REGSIZE != 0);
+ /* For N32/N64, structs, unions, or other composite types are
+ treated as a sequence of doublewords, and are passed in integer
+ or floating point registers as though they were simple scalar
+ parameters to the extent that they fit, with any excess on the
+ stack packed according to the normal memory layout of the
+ object.
+ The caller does not reserve space for the register arguments;
+ the callee is responsible for reserving it if required. */
/* Note: Floating-point values that didn't fit into an FP
register are only written to memory. */
while (len > 0)
@@ -2950,8 +2952,7 @@
gdb_assert (argreg > MIPS_LAST_ARG_REGNUM);
/* Write this portion of the argument to the stack. */
- if (argreg > MIPS_LAST_ARG_REGNUM
- || odd_sized_struct)
+ if (argreg > MIPS_LAST_ARG_REGNUM)
{
/* Should shorter than int integer values be
promoted to int before being stored? */