This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [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: Daniel Jacobowitz <drow at false dot org>, Ulrich Weigand <uweigand at de dot ibm dot com>
- Date: Wed, 13 Jun 2007 18:29:11 +0200
- Subject: Re: [rfc] 'union' handling for Fortran
- References: <466AA121.1020202@de.ibm.com> <20070612153754.GG16068@caradoc.them.org>
Daniel Jacobowitz wrote:
On Sat, Jun 09, 2007 at 02:46:25PM +0200, Markus Deuling wrote:
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 ?
A test would be nice. You should be able to do one from C, using "set
language".
Is this good enough to be useful? The syntax will be unexpected, and
I don't know if you'll be able to get at the members without changing
the parser too.
This is a test with spu-gdb debugging a C application:
(gdb) br main
Breakpoint 1 at 0x4dc: file break_spu_bin.c, line 10.
(gdb) r
Starting program: /home/deuling/simple/break_spu_bin
Breakpoint 1, main (speid=4294967296, argp=1125693748412416, envp=0)
at break_spu_bin.c:10
10 printf("Hello World! from spu\n");
(gdb) set language fortran
Warning: the current language does not match this frame.
(gdb) p $r1
$1 = {uint128 = 0x0003ff700003f2500003ff700003ff70,
v2_int64 = (1125281431810640, 1125281431814000),
v4_int32 = (262000, 258640, 262000, 262000),
v8_int16 = (3, -144, 3, -3504, 3, -144, 3, -144),
v16_int8 = (0 '\000', 3 '\003', -1 'ï', 112 'p', 0 '\000', 3 '\003', -14 'ï', 80 'P', 0 '\000', 3 '\003', -1 'ï', 112 'p', 0 '\000', 3 '\003', -1 'ï', 112 'p'), v2_double = (5.5596289736068649e-309, 5.5596289736234655e-309),
v4_float = (3.67140198e-40, 3.62431835e-40, 3.67140198e-40, 3.67140198e-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];
}spu_builtin_type_vec128
(gdb)
Yes, you're right. The fortran programmer will wonder what that means :-) But I guess it's better
than an error message like
(gdb) p $r1
$2 = <error reading variable>
And yes, when language is set to fortran you can't access union members with out changes in the parser.
(gdb) p $r1.v4_float[0]
A syntax error in expression, near `.v4_float[0]'.
(gdb) set language c
(gdb) p $r1.v4_float[0]
$2 = 3.67140198e-40
(gdb)
Any Ideas on that ? Shall I do that changes to the parser ?!?
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com