This is the mail archive of the gdb-patches@sourceware.cygnus.com 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]

Re: (patch) hpjyg23: gdbtypes.[ch] & values.c


Jimmy Guo wrote:
> 
> ***
> Patch dependency: hpjyg11 (gdbtypes.h)
> ***
> 
> This patch covers misc. fixes to gdbtypes.c and values.c, and introduces
> builtin_type_CORE_ADDR (for 32x64 fix) as well as is_float_type.
> 
> ChangeLog:
> 
> 1999-11-12      Jimmy Guo       <guo@cup.hp.com>
> 
>         * gdbtypes.c: Misc. fixes and builtin_type_CORE_ADDR support.
>         (rank_one_type): return INTEGER_PROMOTION_BADNESS if parm is of
>         TYPE_CODE_ENUM, arg is of a compatible type, but TYPE_LENGTH
>         (arg) <= TYPE_LENGTH (parm); when both parm and arg are of
>         TYPE_CODE_STRUCT, return 0 if the tag names are the same (for
>         same type in different shared libraries), same for
>         TYPE_CODE_UNION.
>         (build_gdbtypes): init builtin_type_CORE_ADDR to
>         builtin_type_unsigned_long_long (64bit) or
>         builtin_type_unsigned_long (32bit).
>         (is_float_type): New function.
> 
>         * gdbtypes.h: Misc. fixes and builtin_type_CORE_ADDR support.
>         (TYPE_IS_OPAQUE): include TYPE_CODE_TEMPLATE too.
>         (builtin_type_CORE_ADDR): Declare.
>         (builtin_type_f_integer_s2,builtin_type_f_integer_s8,
>         builtin_type_f_logical_s8): Declare, for Fortran support.
>         (is_float_type): Declare.
> 
>         * values.c: Misc. 32x64 fixes.

> +
> + #ifdef BFD64
> +   builtin_type_CORE_ADDR = builtin_type_unsigned_long_long;
> + #else
> +   builtin_type_CORE_ADDR = builtin_type_unsigned_long;
> + #endif

Can you expand a little - looks like there isn't a builtin_type_* for
pointer :-(  That makes makes the introduction of a builtin_type for
target pointers a pretty good idea.

BFD64:  I'm not sure this is the right test. Should some characteristic
of the ABFD be tested instead?
I suspect that builtin_type_uint{32,64} would be safer.  There are
machines with 64 bit longs :-)


***************
*** 955,964 ****
           * the beginning of the vtable; but first we have to adjust
           * by HP_ACC_VFUNC_START to account for other entries */
  
!         /* pai: FIXME: 32x64 problem here, a word may be 8 bytes in
!          * which case the multiplier should be 8 and values should be
long */
!         vp = value_at (builtin_type_int,
!                        coreptr + 4 * (TYPE_FN_FIELD_VOFFSET (f, j) +
HP_ACC_VFUNC_START), NULL);
  
          coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (vp));
          /* coreptr now contains the address of the virtual function */
--- 954,965 ----
           * the beginning of the vtable; but first we have to adjust
           * by HP_ACC_VFUNC_START to account for other entries */
  
!         vp = value_at (builtin_type_CORE_ADDR,
!                        coreptr +
!                        sizeof (CORE_ADDR) *
!                        (TYPE_FN_FIELD_VOFFSET (f, j) +
!                         HP_ACC_VFUNC_START),
!                        NULL);
  
          coreptr = *(CORE_ADDR *) (VALUE_CONTENTS (vp));
          /* coreptr now contains the address of the virtual function */

FYI, you can't trust sizeof (CORE_ADDR).  CORE_ADDR is a type that is
large enough to fit a target pointer.  Often it is larger.  Generally
code uses TARGET_PTR_BIT (?), with builtin_type_CORE_ADDR perhaphs an
attribute of that can be used.


	enjoy,
		Andrew

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