Re: [rfc][00/37] Eliminate builtin_type_ macros

Joel Brobecker
2008-09-10T06:18:00Z

> > 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.
[...]
> I see. In that case, your patch would be a bugfix completely
> independently of my patch set. Do you want to commit it right away?

Sure! I don't know what this didn't cross my mind earlier, I guess
I was in a bit of a crunch... Will do that tomorrow (I'm also planning
on submitting a bunch of patches tomorrow as well, if things go as
planned - so that'll be a good time for that).

> > 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.
>
> Huh? I'm not sure what base this patch is against:

It was on top of your patch - If I am not mistaken, it should apply
cleanly after you apply yours. I did, however, generate the patch
against AdaCore's gdb-head (which is a merge between our changes
and nearly-top-of-fsf-tree) to which I applied your patch. So there
might indeed be some differences that would cause a conflict; I just
don't see any, right now.

Perhaps there are some withspace differences? I hate those tabs with a
passion, and always having them right is really difficult and fustrating
for me.

> > --- 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:
>
> The OP_ATR_SIZE in ada_evaluate_subexp in current head looks like this:
>
> case OP_ATR_SIZE:
> arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
> if (noside == EVAL_SKIP)
> goto nosideret;
> else if (noside == EVAL_AVOID_SIDE_EFFECTS)
> return value_zero (builtin_type_int, not_lval);
> else
> return value_from_longest (builtin_type_int,
> TARGET_CHAR_BIT
> * TYPE_LENGTH (value_type (arg1)));
>
> and after my patch set we have:
>
> case OP_ATR_SIZE:
> arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
> 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,
> TARGET_CHAR_BIT
> * TYPE_LENGTH (value_type (arg1)));
>
--
Joel