* [patch]: Fix access to SPU registers for fortran
@ 2008-04-18 19:54 Markus Deuling
2008-04-21 19:43 ` Ulrich Weigand
0 siblings, 1 reply; 8+ messages in thread
From: Markus Deuling @ 2008-04-18 19:54 UTC (permalink / raw)
To: GDB Patches; +Cc: Ulrich Weigand
[-- Attachment #1: Type: text/plain, Size: 2012 bytes --]
Hi,
this is a follow-up to a patch I posted a while ago:
http://sourceware.org/ml/gdb-patches/2008-03/msg00012.html
When debugging a fortran binary on SPU access to one of the 128-bit registers
fails. For example
(gdb) p $r0%v2_int64(0)
Attempt to take address of value not located in memory.
The reason for that is that the value is located in a register instead of inferior memory.
This is fixed with the attached patch:
(gdb) p $r7%v2_double
$3 = (0, 0)
(gdb) p $r7%v2_double(0)
$4 = 0
(gdb) p $r7%v2_double(1)
$5 = 0
(gdb) p $r7%v2_double(2)
no such vector element
(gdb) p $r7%v2_double(-1)
no such vector element
(gdb)
Internally 128-bit SPU registers are handled as a TYPE_CODE_UNION (__spu_builtin_type_vec128).
This patch adds support for TYPE_CODE_UNION in fortran language and also fixes the syntax of
"ptype" and "print $reg".
(gdb) ptype $r0
type = Type, C_Union :: __spu_builtin_type_vec128
int128_t :: uint128
int64_t :: v2_int64(0:1)
int32_t :: v4_int32(0:3)
int16_t :: v8_int16(0:7)
int8_t :: v16_int8(0:15)
double :: v2_double(0:1)
float :: v4_float(0:3)
End Type __spu_builtin_type_vec128
(gdb) p $r0
$2 = ( 0x00000094000000000000000000000000, (635655159808, 0), (148, 0, 0, 0), (0, 148, 0, 0, 0, 0, 0, 0), (0 '\000', 0 '\000', 0 '\000', -108 '\224', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000'), (3.140553770628603e-312, 0), (2.07392173e-43, 0, 0, 0) )
(gdb)
Testsuite showed no regression on SPU. Ok ?
ChangeLog:
* eval.c (evaluate_subexp_standard): Use value_subscripted_rvalue for
multi_f77_subscript to support values from registers.
* valarith.c (value_subscripted_rvalue): Remove prototype and static.
* value.h (value_subscripted_rvalue): Add prototype.
* f-typeprint.c (f_type_print_base): Add support for TYPE_CODE_UNION.
Fix output.
* f-valprint.c (f_val_print): Likewise.
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
[-- Attachment #2: diff-spu-fortran-ptype --]
[-- Type: text/plain, Size: 3940 bytes --]
diff -urpN src-orig/gdb/eval.c src/gdb/eval.c
--- src-orig/gdb/eval.c 2008-03-21 16:02:37.000000000 +0100
+++ src/gdb/eval.c 2008-04-18 16:11:06.000000000 +0200
@@ -1720,7 +1720,7 @@ evaluate_subexp_standard (struct type *e
returns the correct type value */
deprecated_set_value_type (arg1, tmp_type);
- return value_ind (value_add (value_coerce_array (arg1), arg2));
+ return value_subscripted_rvalue (arg1, arg2, 0);
}
case BINOP_LOGICAL_AND:
diff -urpN src-orig/gdb/f-typeprint.c src/gdb/f-typeprint.c
--- src-orig/gdb/f-typeprint.c 2008-02-28 20:10:42.000000000 +0100
+++ src/gdb/f-typeprint.c 2008-04-17 17:41:30.000000000 +0200
@@ -368,14 +369,22 @@ f_type_print_base (struct type *type, st
break;
case TYPE_CODE_STRUCT:
- fprintfi_filtered (level, stream, "Type ");
+ case TYPE_CODE_UNION:
+ if (TYPE_CODE (type) == TYPE_CODE_UNION)
+ fprintfi_filtered (level, stream, "Type, C_Union :: ");
+ else
+ fprintfi_filtered (level, stream, "Type ");
fputs_filtered (TYPE_TAG_NAME (type), stream);
fputs_filtered ("\n", stream);
for (index = 0; index < TYPE_NFIELDS (type); index++)
{
- f_print_type (TYPE_FIELD_TYPE (type, index), "", stream, show, level + 4);
+ f_type_print_base (TYPE_FIELD_TYPE (type, index), stream, show,
+ level + 4);
fputs_filtered (" :: ", stream);
- fputs_filtered (TYPE_FIELD_NAME (type, index), stream);
+ fprintfi_filtered (level, stream, "%s",
+ TYPE_FIELD_NAME (type, index));
+ f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index),
+ stream, 0, 0, 0);
fputs_filtered ("\n", stream);
}
fprintfi_filtered (level, stream, "End Type ");
diff -urpN src-orig/gdb/f-valprint.c src/gdb/f-valprint.c
--- src-orig/gdb/f-valprint.c 2008-01-11 14:34:14.000000000 +0100
+++ src/gdb/f-valprint.c 2008-04-15 20:13:55.000000000 +0200
@@ -589,9 +589,10 @@ f_val_print (struct type *type, const gd
break;
case TYPE_CODE_STRUCT:
+ case TYPE_CODE_UNION:
/* Starting from the Fortran 90 standard, Fortran supports derived
types. */
- fprintf_filtered (stream, "{ ");
+ fprintf_filtered (stream, "( ");
for (index = 0; index < TYPE_NFIELDS (type); index++)
{
int offset = TYPE_FIELD_BITPOS (type, index) / 8;
@@ -601,7 +602,7 @@ f_val_print (struct type *type, const gd
if (index != TYPE_NFIELDS (type) - 1)
fputs_filtered (", ", stream);
}
- fprintf_filtered (stream, "}");
+ fprintf_filtered (stream, " )");
break;
default:
diff -urpN src-orig/gdb/valarith.c src/gdb/valarith.c
--- src-orig/gdb/valarith.c 2008-02-04 01:23:04.000000000 +0100
+++ src/gdb/valarith.c 2008-04-18 15:08:21.000000000 +0200
@@ -39,7 +39,6 @@
#define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2)
#endif
-static struct value *value_subscripted_rvalue (struct value *, struct value *, int);
static struct type *unop_result_type (enum exp_opcode op, struct type *type1);
static struct type *binop_result_type (enum exp_opcode op, struct type *type1,
struct type *type2);
@@ -257,7 +256,7 @@ value_subscript (struct value *array, st
(eg, a vector register). This routine used to promote floats
to doubles, but no longer does. */
-static struct value *
+struct value *
value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound)
{
struct type *array_type = check_typedef (value_type (array));
diff -urpN src-orig/gdb/value.h src/gdb/value.h
--- src-orig/gdb/value.h 2008-04-06 10:56:36.000000000 +0200
+++ src/gdb/value.h 2008-04-18 13:43:16.000000000 +0200
@@ -558,4 +558,5 @@ extern struct value *value_allocate_spac
extern struct value *value_of_local (const char *name, int complain);
+extern struct value * value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound);
#endif /* !defined (VALUE_H) */
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [patch]: Fix access to SPU registers for fortran
2008-04-18 19:54 [patch]: Fix access to SPU registers for fortran Markus Deuling
@ 2008-04-21 19:43 ` Ulrich Weigand
2008-04-21 19:59 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Ulrich Weigand @ 2008-04-21 19:43 UTC (permalink / raw)
To: Markus Deuling; +Cc: GDB Patches
Markus Deuling wrote:
> * eval.c (evaluate_subexp_standard): Use value_subscripted_rvalue for
> multi_f77_subscript to support values from registers.
> * valarith.c (value_subscripted_rvalue): Remove prototype and static.
> * value.h (value_subscripted_rvalue): Add prototype.
>
> * f-typeprint.c (f_type_print_base): Add support for TYPE_CODE_UNION.
> Fix output.
> * f-valprint.c (f_val_print): Likewise.
This is OK, thanks.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch]: Fix access to SPU registers for fortran
2008-04-21 19:43 ` Ulrich Weigand
@ 2008-04-21 19:59 ` Daniel Jacobowitz
2008-04-21 20:04 ` Ulrich Weigand
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2008-04-21 19:59 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Markus Deuling, GDB Patches
On Mon, Apr 21, 2008 at 09:29:15PM +0200, Ulrich Weigand wrote:
> Markus Deuling wrote:
>
> > * eval.c (evaluate_subexp_standard): Use value_subscripted_rvalue for
> > multi_f77_subscript to support values from registers.
> > * valarith.c (value_subscripted_rvalue): Remove prototype and static.
> > * value.h (value_subscripted_rvalue): Add prototype.
> >
> > * f-typeprint.c (f_type_print_base): Add support for TYPE_CODE_UNION.
> > Fix output.
> > * f-valprint.c (f_val_print): Likewise.
>
> This is OK, thanks.
Not without documentation, please. Syntax that doesn't come from
Fortran (as far as I know) and isn't in the manual might as well not
be there :-)
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch]: Fix access to SPU registers for fortran
2008-04-21 19:59 ` Daniel Jacobowitz
@ 2008-04-21 20:04 ` Ulrich Weigand
2008-04-21 21:53 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Ulrich Weigand @ 2008-04-21 20:04 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Markus Deuling, GDB Patches
Daniel Jacobowitz wrote:
> Not without documentation, please. Syntax that doesn't come from
> Fortran (as far as I know) and isn't in the manual might as well not
> be there :-)
Hmmm, most of the output changes in Markus' patch actually bring the
output in line with correct Fortran syntax in the first place ;-)
The one addition is the representation of "union" types in the output;
this can never happen in regular Fortran, but can happen if you access
registers that use a gdbarch-defined union type. This extension is
simply the "C_Union" marker; note that as far as the *parser* is
concerned, there is no syntax extension.
But I guess you're right that this extension should be documented.
I assume the right place would be somewhere in section 12.4.3 Fortran?
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch]: Fix access to SPU registers for fortran
2008-04-21 20:04 ` Ulrich Weigand
@ 2008-04-21 21:53 ` Daniel Jacobowitz
2008-04-22 9:40 ` Markus Deuling
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2008-04-21 21:53 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Markus Deuling, GDB Patches
On Mon, Apr 21, 2008 at 10:00:42PM +0200, Ulrich Weigand wrote:
> Daniel Jacobowitz wrote:
>
> > Not without documentation, please. Syntax that doesn't come from
> > Fortran (as far as I know) and isn't in the manual might as well not
> > be there :-)
>
> Hmmm, most of the output changes in Markus' patch actually bring the
> output in line with correct Fortran syntax in the first place ;-)
>
> The one addition is the representation of "union" types in the output;
> this can never happen in regular Fortran, but can happen if you access
> registers that use a gdbarch-defined union type. This extension is
> simply the "C_Union" marker; note that as far as the *parser* is
> concerned, there is no syntax extension.
>
> But I guess you're right that this extension should be documented.
> I assume the right place would be somewhere in section 12.4.3 Fortran?
I see. I didn't realize we already had the % operator that did the
necessary operation - I must have not found it when this was last
discussed.
Maybe we could mention it in the Operators bit of the Fortran
documentation, and there add that GDB allows it on unions?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch]: Fix access to SPU registers for fortran
2008-04-21 21:53 ` Daniel Jacobowitz
@ 2008-04-22 9:40 ` Markus Deuling
2008-04-22 11:04 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Markus Deuling @ 2008-04-22 9:40 UTC (permalink / raw)
To: Ulrich Weigand, Daniel Jacobowitz; +Cc: GDB Patches, Eli Zaretskii
[-- Attachment #1: Type: text/plain, Size: 1432 bytes --]
Hi,
Daniel Jacobowitz schrieb:
> On Mon, Apr 21, 2008 at 10:00:42PM +0200, Ulrich Weigand wrote:
>> Daniel Jacobowitz wrote:
>>
>>> Not without documentation, please. Syntax that doesn't come from
>>> Fortran (as far as I know) and isn't in the manual might as well not
>>> be there :-)
>> Hmmm, most of the output changes in Markus' patch actually bring the
>> output in line with correct Fortran syntax in the first place ;-)
>>
>> The one addition is the representation of "union" types in the output;
>> this can never happen in regular Fortran, but can happen if you access
>> registers that use a gdbarch-defined union type. This extension is
>> simply the "C_Union" marker; note that as far as the *parser* is
>> concerned, there is no syntax extension.
>>
>> But I guess you're right that this extension should be documented.
>> I assume the right place would be somewhere in section 12.4.3 Fortran?
>
> I see. I didn't realize we already had the % operator that did the
> necessary operation - I must have not found it when this was last
> discussed.
>
> Maybe we could mention it in the Operators bit of the Fortran
> documentation, and there add that GDB allows it on unions?
>
thanks for your comments. I added some lines to the documentation.
Is this ok ?
ChangeLog:
* gdb.texinfo (Fortran Operators): Describe '%' operator.
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
[-- Attachment #2: diff-spu-fortran-ptype-doc --]
[-- Type: text/plain, Size: 631 bytes --]
diff -urpN src/gdb/doc/gdb.texinfo dev/gdb/doc/gdb.texinfo
--- src/gdb/doc/gdb.texinfo 2008-04-21 06:23:26.000000000 +0200
+++ dev/gdb/doc/gdb.texinfo 2008-04-22 07:10:59.000000000 +0200
@@ -9903,6 +9903,12 @@ of the second one.
@item :
The range operator. Normally used in the form of array(low:high) to
represent a section of array.
+
+@item %
+The access component operator. Normally used to access elements in derived
+types. Also suitable for unions. As unions aren't part of regular fortran
+this can only happen when accessing a register that uses a gdbarch-defined
+union type.
@end table
@node Fortran Defaults
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch]: Fix access to SPU registers for fortran
2008-04-22 9:40 ` Markus Deuling
@ 2008-04-22 11:04 ` Eli Zaretskii
2008-04-22 12:14 ` Markus Deuling
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2008-04-22 11:04 UTC (permalink / raw)
To: Markus Deuling; +Cc: uweigand, drow, gdb-patches
> Date: Tue, 22 Apr 2008 07:15:40 +0200
> From: Markus Deuling <deuling@de.ibm.com>
> CC: GDB Patches <gdb-patches@sourceware.org>, Eli Zaretskii <eliz@gnu.org>
>
> I added some lines to the documentation.
> Is this ok ?
Yes, thanks.
> +types. Also suitable for unions. As unions aren't part of regular fortran
> +this can only happen when accessing a register that uses a gdbarch-defined
> +union type.
"Fortran" capitalized, please, and please give me a comma between
"Fortran" and "this" in the above sentence.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch]: Fix access to SPU registers for fortran
2008-04-22 11:04 ` Eli Zaretskii
@ 2008-04-22 12:14 ` Markus Deuling
0 siblings, 0 replies; 8+ messages in thread
From: Markus Deuling @ 2008-04-22 12:14 UTC (permalink / raw)
To: GDB Patches; +Cc: Eli Zaretskii, uweigand, drow
Eli Zaretskii schrieb:
>> Date: Tue, 22 Apr 2008 07:15:40 +0200
>> From: Markus Deuling <deuling@de.ibm.com>
>> CC: GDB Patches <gdb-patches@sourceware.org>, Eli Zaretskii <eliz@gnu.org>
>>
>> I added some lines to the documentation.
>> Is this ok ?
>
> Yes, thanks.
>
>> +types. Also suitable for unions. As unions aren't part of regular fortran
>> +this can only happen when accessing a register that uses a gdbarch-defined
>> +union type.
>
> "Fortran" capitalized, please, and please give me a comma between
> "Fortran" and "this" in the above sentence.
>
Thank you, I've committed a corrected version now.
Regards,
Markus
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-04-22 6:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-18 19:54 [patch]: Fix access to SPU registers for fortran Markus Deuling
2008-04-21 19:43 ` Ulrich Weigand
2008-04-21 19:59 ` Daniel Jacobowitz
2008-04-21 20:04 ` Ulrich Weigand
2008-04-21 21:53 ` Daniel Jacobowitz
2008-04-22 9:40 ` Markus Deuling
2008-04-22 11:04 ` Eli Zaretskii
2008-04-22 12:14 ` Markus Deuling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox