This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] 'union' handling for Fortran
- From: Markus Deuling <deuling at de dot ibm dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Ulrich Weigand <uweigand at de dot ibm dot com>
- Date: Sat, 09 Jun 2007 14:46:25 +0200
- Subject: [rfc] 'union' handling for Fortran
Hello,
in SPU target registers are of type spu_builtin_type_vec128 which is a union. A SPU application
written in Fortran cannot access SPU registers because Fortran doesn't know how to handle unions.
(gdb) set language fortran
Warning: the current language does not match this frame.
(gdb) p $r1
$2 = <error reading variable>
(gdb) ptype $r1
type = spu_builtin_type_vec128
A C application accesses it correct:
(gdb) p $r1
$1 = {uint128 = 0x0003ffd00003f6f00003ffd00003ffd0, v2_int64 =
{1125693748672240,
1125693748674512}, v4_int32 = {262096, 259824, 262096, 262096}, v8_int16 =
{3,
-48, 3, -2320, 3, -48, 3, -48},
v16_int8 = "\000\003ÿÐ\000\003öð\000\003ÿÐ\000\003ÿÐ", v2_double = {
5.5616660895720413e-309, 5.5616660895832664e-309}, v4_float = {3.67274722e-
40,
3.64090972e-40, 3.67274722e-40, 3.67274722e-40}}
(gdb) ptype $r1
type = union __spu_builtin_type_vec128 {
int128_t uint128;
int64_t v2_int64[2];
int32_t v4_int32[4];
int16_t v8_int16[8];
int8_t v16_int8[16];
double v2_double[2];
float v4_float[4];
}
This patch adds support for TYPE_CODE_UNION to Fortran backend by calling the appropriate C routines c_type_print_base and
c_val_print.
ChangeLog:
* f-typeprint.c (print_equivalent_f77_float_type): Add support for
TYPE_CODE_UNION.
* f-valprint.c (f_val_print): Likewise.
Testsuite showed no regressions. Would this be ok to commit ?
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
diff -urN gdb-orig/gdb/f-typeprint.c gdb-6.6/gdb/f-typeprint.c
--- gdb-orig/gdb/f-typeprint.c 2006-03-01 02:37:26.000000000 +0100
+++ gdb-6.6/gdb/f-typeprint.c 2007-06-05 06:29:52.000000000 +0200
@@ -409,6 +409,11 @@
fputs_filtered (TYPE_TAG_NAME (type), stream);
break;
+ case TYPE_CODE_UNION:
+ /* Union is a unknown data type in Fortran. Call the C-specific valprint
+ routine to print unions. */
+ c_type_print_base (type, stream, show, level);
+
default_case:
default:
/* Handle types not explicitly handled by the other cases,
diff -urN gdb-orig/gdb/f-valprint.c gdb-6.6/gdb/f-valprint.c
--- gdb-orig/gdb/f-valprint.c 2006-02-24 08:26:10.000000000 +0100
+++ gdb-6.6/gdb/f-valprint.c 2007-06-05 06:29:52.000000000 +0200
@@ -371,6 +371,13 @@
CHECK_TYPEDEF (type);
switch (TYPE_CODE (type))
{
+ /* Union is a unknown data type in Fortran. Call the C-specific valprint
+ routine to print unions. */
+ case TYPE_CODE_UNION:
+ c_val_print (type, valaddr, embedded_offset, address, stream, format,
+ deref_ref, recurse, pretty);
+ break;
+
case TYPE_CODE_STRING:
f77_get_dynamic_length_of_aggregate (type);
LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0);