This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Wrong return convention for arrays (mips-irix)
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Sat, 9 Jan 2010 08:59:53 +0400
- Subject: [commit] Wrong return convention for arrays (mips-irix)
Consider the following function returning an array whose size is
128 bits or smaller:
type Data_Small is array (1 .. 2) of Integer;
function Create_Small return Data_Small;
GDB claims that the return value cannot be printed at the end of
a "finish":
(gdb) break create_small
Breakpoint 1 at 0x10002954: file pck.adb, line 5.
(gdb) run
Starting program: /[...]/p
Breakpoint 1, pck.create_small () at pck.adb:5
5 return (others => 1);
(gdb) finish
Run till exit from #0 pck.create_small () at pck.adb:5
0x10002bdc in p () at p.adb:8
8 Small := Create_Small;
Value returned has type: pck__data_small. Cannot determine contents
The problem comes from mips-tdep.c:mips_n32n64_return_value which
considers that arrays are always returned using the
RETURN_VALUE_STRUCT_CONVENTION. But in fact, this is not entirely
correct. Looking at the ABI, all composite types that are 128bits
or smaller are returned via $2 and $3 (except for the special case
of a struct containing one or two floats).
This patch modifies the logic accordingly.
gdb/ChangeLog:
Wrong return convention for arrays (mips-irix).
* mips-tdep.c (mips_n32n64_return_value): Arrays whose size is
128 bits or smaller are returned the same way as structs
and unions of the the same size.
--
Joel
gdb/ChangeLog:
Wrong return convention for arrays (mips-irix).
* mips-tdep.c (mips_n32n64_return_value): Arrays whose size is
128 bits or smaller are returned the same way as structs
and unions of the the same size.
---
gdb/mips-tdep.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 92fcd4a..6749c27 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -3379,7 +3379,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct type *func_type,
(and $f2 if necessary). This is a generalization of the Fortran COMPLEX
case.
- * Any other struct or union results of at most 128 bits are returned in
+ * Any other composite results of at most 128 bits are returned in
$2 (first 64 bits) and $3 (remainder, if necessary).
* Larger composite results are handled by converting the function to a
@@ -3390,8 +3390,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct type *func_type,
specific exception to return COMPLEX results in the floating point
registers.] */
- if (TYPE_CODE (type) == TYPE_CODE_ARRAY
- || TYPE_LENGTH (type) > 2 * MIPS64_REGSIZE)
+ if (TYPE_LENGTH (type) > 2 * MIPS64_REGSIZE)
return RETURN_VALUE_STRUCT_CONVENTION;
else if (TYPE_CODE (type) == TYPE_CODE_FLT
&& TYPE_LENGTH (type) == 16
@@ -3481,9 +3480,10 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct type *func_type,
return RETURN_VALUE_REGISTER_CONVENTION;
}
else if (TYPE_CODE (type) == TYPE_CODE_STRUCT
- || TYPE_CODE (type) == TYPE_CODE_UNION)
+ || TYPE_CODE (type) == TYPE_CODE_UNION
+ || TYPE_CODE (type) == TYPE_CODE_ARRAY)
{
- /* A structure or union. Extract the left justified value,
+ /* A composite type. Extract the left justified value,
regardless of the byte order. I.e. DO NOT USE
mips_xfer_lower. */
int offset;
--
1.5.4.3