[rfc][00/37] Eliminate builtin_type_ macros
Joel Brobecker
brobecker@adacore.com
Tue Sep 9 21:18:00 GMT 2008
Hi Ulrich,
> I still got a few regressions with our testsuite, which I will
> investigate now. Can you hold the patch off a little while longer?
OK, our testsuite found 2 issues:
1. Pointer arithmetics, in particular "PTR + PTR" or "PTR - PTR"
expressions. For instance:
(gdb) print b'address - a'address
Argument to arithmetic operation not a number or boolean.
It's worth mentioning that the problem was already present
with pointer addition (adding two pointers doesn't necessarily
make a lot of sense, but anyway...).
The regression on the substraction is because we replaced the
call to (rip'ed) value_sub by a call to value_binop, which
doesn't support pointer differences.
I think the semantics of pointer differences in Ada are different
from C. It's just a number substraction. So I just added support
for it directly at the caller site, thus calling value_binop
only for values that it supports. Same for addition.
2. The second problem is just an oversight. You needed a variable
to store the int builtin type, and unfortunately you reused
a variable that was still in use.
See ada-lang.c (evaluate_subexp) [OP_ATR_SIZE].
For now, I just used builtin_type_int32. Not ideal, but should
be large enough for the vast majority of objects we actually
have to deal with in real life.
Two suggested patches attached...
BTW: I tested on x86-linux (DWARF & STABS) as well as on x86_64-linux
(DWARF only, obviously).
--
Joel
-------------- next part --------------
diff -r ef6e8d4d28b4 -r c0202064b824 ada-lang.c
--- a/ada-lang.c Tue Sep 09 10:27:10 2008 -0700
+++ b/ada-lang.c Tue Sep 09 12:31:38 2008 -0700
@@ -9909,6 +9909,10 @@ ada_evaluate_subexp (struct type *expect
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
+ if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_PTR)
+ return (value_from_longest
+ (value_type (arg1),
+ value_as_long (arg1) + value_as_long (arg2)));
if ((ada_is_fixed_point_type (value_type (arg1))
|| ada_is_fixed_point_type (value_type (arg2)))
&& value_type (arg1) != value_type (arg2))
@@ -9927,6 +9931,10 @@ ada_evaluate_subexp (struct type *expect
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
+ if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_PTR)
+ return (value_from_longest
+ (value_type (arg1),
+ value_as_long (arg1) - value_as_long (arg2)));
if ((ada_is_fixed_point_type (value_type (arg1))
|| ada_is_fixed_point_type (value_type (arg2)))
&& value_type (arg1) != value_type (arg2))
-------------- next part --------------
diff -r c0202064b824 -r 61698126d402 ChangeLog.joel
diff -r c0202064b824 -r 61698126d402 ada-lang.c
--- a/ada-lang.c Tue Sep 09 12:31:38 2008 -0700
+++ b/ada-lang.c Tue Sep 09 12:57:26 2008 -0700
@@ -10541,11 +10541,10 @@ ada_evaluate_subexp (struct type *expect
if (noside == EVAL_SKIP)
goto nosideret;
- type = builtin_type (exp->gdbarch)->builtin_int;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (type, not_lval);
- else
- return value_from_longest (type,
+ return value_zero (builtin_type_int32, not_lval);
+ else
+ return value_from_longest (builtin_type_int32,
TARGET_CHAR_BIT * TYPE_LENGTH (type));
case OP_ATR_VAL:
More information about the Gdb-patches
mailing list