This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Fix printing functions with complex return on PPC64
- From: Tiago Stürmer Daitx <tdaitx at linux dot vnet dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Cc: emachado at linux dot vnet dot ibm dot com, Ulrich dot Weigand at de dot ibm dot com
- Date: Wed, 23 Jan 2013 12:37:40 -0600
- Subject: [PATCH] Fix printing functions with complex return on PPC64
This patch fix the current PPC64 return value code to properly handle complex
types by passing the target type of the COMPLEX value. It also makes use of a
variable to hold TYPE_TARGET_TYPE (valtype) for better readability and reuse.
Previously two testcases from gdb.base/callfuncs.exp and another two from
gdb.base/varargs.exp would fail with GDB Interal Error due to improperly
calling convert_typed_floating with a COMPLEX type instead of using the
target type.
Excerpt from a diff between PPC64 run log before and after the fix:
-FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns float _Complex (GDB internal error)
-FAIL: gdb.base/callfuncs.exp: call inferior func with struct - returns double _Complex (GDB internal error)
-FAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3, fc4) (GDB internal error)
-FAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2, dc3, dc4) (GDB internal error)
+FAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3, fc4)
The existing FAIL is due to the complex arguments and will be fixed by another
patch series.
No regression was detected on PPC (32 bits) testcases.
Regards,
Tiago Daitx
gdb/Changelog
2012-11-01 Tiago Stürmer Daitx <tdaitx@linux.vnet.ibm.com>
* ppc-sysv-tdep.c (ppc64_sysv_abi_return_value): Set correct
type on float conversion for complex type.
---
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index 48b4765..0ffeab9 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -1920,11 +1920,13 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
gdb_byte regval[MAX_REGISTER_SIZE];
struct type *regtype =
register_type (gdbarch, tdep->ppc_fp0_regnum);
+ struct type *target_type;
+ target_type = check_typedef (TYPE_TARGET_TYPE (valtype));
if (writebuf != NULL)
{
convert_typed_floating ((const bfd_byte *) writebuf +
- i * (TYPE_LENGTH (valtype) / 2),
- valtype, regval, regtype);
+ i * TYPE_LENGTH (target_type),
+ target_type, regval, regtype);
regcache_cooked_write (regcache,
tdep->ppc_fp0_regnum + 1 + i,
regval);
@@ -1936,8 +1938,8 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
regval);
convert_typed_floating (regval, regtype,
(bfd_byte *) readbuf +
- i * (TYPE_LENGTH (valtype) / 2),
- valtype);
+ i * TYPE_LENGTH (target_type),
+ target_type);
}
}
}