This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Joel Brobecker wrote:

>   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.

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?

>   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:

> --- 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)));

Do you have some other patches applied?

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]