[patch] Fix fortran access to special register on SPU arch

Markus Deuling
2008-03-03T19:07:15Z

[-- Attachment #1: Type: text/plain, Size: 1502 bytes --]

Hi,

SPU architecture has 128 special register:

(gdb) ptype $r0
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];
}
(gdb)

when debugging a fortran binary GDB cannot access single elements of the above
elements regarded as arrays of int64, int32 ...

(gdb) p $r0%v2_int64
$1 = (635655159808, 0)
(gdb) p $r0%v2_int64(0)
Attempt to take address of value not located in memory.
(gdb) set $r0%v2_int64(0)=2
Attempt to take address of value not located in memory.
(gdb)

Access to fortran subranges is possible:

(gdb) p $r0%v2_int64(0:0)
$2 = (635655159808)
(gdb) p $r0%v2_int64(0:1)
$3 = (635655159808, 0)
(gdb) p $r0%v2_int64
$4 = (635655159808, 0)
(gdb)

This patch invokes value_subscript for the special case that a multi_f77_subscript
is in a register instead of memory.

(gdb) p $r0%uint128
$2 = 0x00000094000000000000000000000000
(gdb) p $r0%v2_int64
$3 = (635655159808, 0)
(gdb) p $r0%v2_int64(0)
$4 = 635655159808

(gdb) set $r0%v2_int64(1)=5
(gdb) p $r0%v2_int64(1)
$6 = 5
(gdb)

the gdb.fortran testsuite showed no regression on SPU.
If this patch is ok it would be great to have it in gdb 6.8. Ok ?

ChangeLog:

* eval.c (evaluate_subexp_standard): Call value_subscript for
accessing fortran array elements in registers.

Regards,
Markus

--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com

[-- Attachment #2: diff-fortran --]
[-- Type: text/plain, Size: 461 bytes --]

diff -urpN src/gdb/eval.c dev/gdb/eval.c
--- src/gdb/eval.c 2008-02-11 05:48:36.000000000 +0100
+++ dev/gdb/eval.c 2008-03-03 19:23:37.000000000 +0100
@@ -1720,6 +1720,8 @@ evaluate_subexp_standard (struct type *e
returns the correct type value */

deprecated_set_value_type (arg1, tmp_type);
+ if (VALUE_LVAL (arg1) == lval_register)
+ return value_subscript (arg1, arg2);
return value_ind (value_add (value_coerce_array (arg1), arg2));
}