diff options
author | Per Bothner <per@bothner.com> | 1997-08-05 21:58:57 +0000 |
---|---|---|
committer | Per Bothner <per@bothner.com> | 1997-08-05 21:58:57 +0000 |
commit | f7f37388dc1d7910711f89b1c6b4f3808533ff2d (patch) | |
tree | 8f18c81b7fd22c852dd579cc2afe559caea8b7ac /gdb/gdbtypes.h | |
parent | 0e25edcacc69ff157685d6653fb1304eae9b773d (diff) | |
download | gdb-f7f37388dc1d7910711f89b1c6b4f3808533ff2d.zip gdb-f7f37388dc1d7910711f89b1c6b4f3808533ff2d.tar.gz gdb-f7f37388dc1d7910711f89b1c6b4f3808533ff2d.tar.bz2 |
* gdbtypes.h: Re-interpret struct field. Suppport address of static.
Add a bunch of macros.
* coffread.c, dwarf2read.c, dwarfread.c, mdebugread.c, stabsread.c:
Update to use new macros.
* coffread.c, hpread.c, stabsread.c: Remove bugus TYPE_FIELD_VALUE.
* value.h, values.c (value_static_field): New function.
* cp-valprint.c, valops.c: Modify to use value_static_field.
Diffstat (limited to 'gdb/gdbtypes.h')
-rw-r--r-- | gdb/gdbtypes.h | 68 |
1 files changed, 46 insertions, 22 deletions
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 02e762d..37270f5 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -272,25 +272,38 @@ struct type struct field { - /* Position of this field, counting in bits from start of - containing structure. For a function type, this is the - position in the argument list of this argument. - For a range bound or enum value, this is the value itself. - (FIXME: What about ranges larger than host int size?) - For BITS_BIG_ENDIAN=1 targets, it is the bit offset to the MSB. - For BITS_BIG_ENDIAN=0 targets, it is the bit offset to the LSB. */ - int bitpos; + + union field_location + { + /* Position of this field, counting in bits from start of + containing structure. + For BITS_BIG_ENDIAN=1 targets, it is the bit offset to the MSB. + For BITS_BIG_ENDIAN=0 targets, it is the bit offset to the LSB. + For a function type, this is the position in the argument list + of this argument. + For a range bound or enum value, this is the value itself. */ + + int bitpos; + + /* For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then physaddr + is the location (in the target) of the static field. + Otherwise, physname is the mangled label of the static field. */ + + CORE_ADDR physaddr; + char* physname; + } loc; /* Size of this field, in bits, or zero if not packed. For an unpacked field, the field's type's length - says how many bytes the field occupies. */ - /* FIXME: This is abused by TYPE_FIELD_STATIC_PHYSNAME to contain - a pointer, so it has to be long. */ + says how many bytes the field occupies. + A value of -1 or -2 indicates a static field; -1 means the location + is specified by the label loc.physname; -2 means that loc.physaddr + specifies the actual address. */ - long bitsize; + int bitsize; - /* In a struct or enum type, type of this field. + /* In a struct or union type, type of this field. In a function type, type of this argument. In an array type, the domain-type of the array. */ @@ -538,18 +551,27 @@ allocate_cplus_struct_type PARAMS ((struct type *)); #define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses #define TYPE_BASECLASS_NAME(thistype,index) (thistype)->fields[index].name -#define TYPE_BASECLASS_BITPOS(thistype,index) (thistype)->fields[index].bitpos +#define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index) #define BASETYPE_VIA_PUBLIC(thistype, index) (!TYPE_FIELD_PRIVATE(thistype, index)) #define BASETYPE_VIA_VIRTUAL(thistype, index) \ B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)) +#define FIELD_TYPE(thisfld) ((thisfld).type) +#define FIELD_NAME(thisfld) ((thisfld).name) +#define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos) +#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize) +#define FIELD_PHYSNAME(thisfld) ((thisfld).loc.physname) +#define FIELD_PHYSADDR(thisfld) ((thisfld).loc.physaddr) +#define SET_FIELD_PHYSNAME(thisfld, name) \ + ((thisfld).bitsize = -1, FIELD_PHYSNAME(thisfld) = (name)) +#define SET_FIELD_PHYSADDR(thisfld, name) \ + ((thisfld).bitsize = -2, FIELD_PHYSADDR(thisfld) = (name)) #define TYPE_FIELD(thistype, n) (thistype)->fields[n] -#define TYPE_FIELD_TYPE(thistype, n) (thistype)->fields[n].type -#define TYPE_FIELD_NAME(thistype, n) (thistype)->fields[n].name -#define TYPE_FIELD_VALUE(thistype, n) (* (int*) &(thistype)->fields[n].type) -#define TYPE_FIELD_BITPOS(thistype, n) (thistype)->fields[n].bitpos -#define TYPE_FIELD_BITSIZE(thistype, n) (thistype)->fields[n].bitsize -#define TYPE_FIELD_PACKED(thistype, n) (thistype)->fields[n].bitsize +#define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE(TYPE_FIELD(thistype, n)) +#define TYPE_FIELD_NAME(thistype, n) FIELD_NAME(TYPE_FIELD(thistype, n)) +#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS(TYPE_FIELD(thistype,n)) +#define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n)) +#define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE(TYPE_FIELD(thistype,n))!=0) #define TYPE_FIELD_PRIVATE_BITS(thistype) \ TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits @@ -579,8 +601,10 @@ allocate_cplus_struct_type PARAMS ((struct type *)); #define TYPE_FIELD_VIRTUAL(thistype, n) \ B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n)) -#define TYPE_FIELD_STATIC(thistype, n) ((thistype)->fields[n].bitpos == -1) -#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((char *)(thistype)->fields[n].bitsize) +#define TYPE_FIELD_STATIC(thistype, n) ((thistype)->fields[n].bitsize < 0) +#define TYPE_FIELD_STATIC_HAS_ADDR(thistype, n) ((thistype)->fields[n].bitsize == -2) +#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_PHYSNAME(TYPE_FIELD(thistype, n)) +#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_PHYSADDR(TYPE_FIELD(thistype, n)) #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n] |