* gdbtypes.h: Re-interpret struct field. Suppport address of static.
authorPer Bothner <per@bothner.com>
Tue, 5 Aug 1997 21:58:57 +0000 (21:58 +0000)
committerPer Bothner <per@bothner.com>
Tue, 5 Aug 1997 21:58:57 +0000 (21:58 +0000)
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.

gdb/ChangeLog
gdb/cp-valprint.c
gdb/dwarf2read.c
gdb/dwarfread.c
gdb/gdbtypes.h
gdb/hpread.c
gdb/mdebugread.c
gdb/stabsread.c
gdb/values.c

index b2f3eb4..30a9713 100644 (file)
@@ -1,3 +1,22 @@
+Tue Aug  5 13:37:14 1997  Per Bothner  <bothner@cygnus.com>
+
+       * 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.
+
+Sun Aug  3 08:18:09 1997  Peter Schauer  (pes@regent.e-technik.tu-muenchen.de)
+
+       * c-valprint.c (c_val_print):  Use extract_address to retrieve
+       the address of the virtual function.
+       From Peter Bloecher (Peter.Bloecher@eedn.ericsson.se).
+
+       * eval.c (evaluate_subexp_standard), valarith.c (value_x_unop):
+       Handle C++ operator *.
+
 Fri Aug  1 15:21:44 1997  Ian Lance Taylor  <ian@cygnus.com>
 
        * gdbtk.c (Tcl_Alloc): Don't provide our own version of this if
index b43da16..e6790a4 100644 (file)
@@ -333,21 +333,13 @@ cp_print_value_fields (type, valaddr, address, stream, format, recurse, pretty,
                }
              else if (TYPE_FIELD_STATIC (type, i))
                {
-                 value_ptr v;
-                 char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, i);
-                 struct symbol *sym =
-                     lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL);
-                 if (sym == NULL)
+                 value_ptr v = value_static_field (type, i);
+                 if (v == NULL)
                    fputs_filtered ("<optimized out>", stream);
                  else
-                   {
-                     v = value_at (TYPE_FIELD_TYPE (type, i),
-                                   SYMBOL_VALUE_ADDRESS (sym),
-                                   NULL);
-                     cp_print_static_field (TYPE_FIELD_TYPE (type, i), v,
-                                            stream, format, recurse + 1,
-                                            pretty);
-                   }
+                   cp_print_static_field (TYPE_FIELD_TYPE (type, i), v,
+                                          stream, format, recurse + 1,
+                                          pretty);
                }
              else
                {
index 6434246..38d80fb 100644 (file)
@@ -1710,22 +1710,22 @@ dwarf2_add_field (fip, die, objfile)
       attr = dwarf_attr (die, DW_AT_bit_size);
       if (attr)
        {
-         fp->bitsize = DW_UNSND (attr);
+         FIELD_BITSIZE (*fp) = DW_UNSND (attr);
        }
       else
        {
-         fp->bitsize = 0;
+         FIELD_BITSIZE (*fp) = 0;
        }
 
       /* Get bit offset of field.  */
       attr = dwarf_attr (die, DW_AT_data_member_location);
       if (attr)
        {
-         fp->bitpos =
+         FIELD_BITPOS (*fp) =
            decode_locdesc (DW_BLOCK (attr), objfile) * bits_per_byte;
        }
       else
-       fp->bitpos = 0;
+       FIELD_BITPOS (*fp) = 0;
       attr = dwarf_attr (die, DW_AT_bit_offset);
       if (attr)
        {
@@ -1736,7 +1736,7 @@ dwarf2_add_field (fip, die, objfile)
                 anonymous object to the MSB of the field.  We don't
                 have to do anything special since we don't need to
                 know the size of the anonymous object.  */
-             fp->bitpos += DW_UNSND (attr);
+             FIELD_BITPOS (*fp) += DW_UNSND (attr);
            }
          else
            {
@@ -1765,8 +1765,8 @@ dwarf2_add_field (fip, die, objfile)
                     bit field.  */
                  anonymous_size = TYPE_LENGTH (fp->type);
                }
-             fp->bitpos +=
-               anonymous_size * bits_per_byte - bit_offset - fp->bitsize;
+             FIELD_BITPOS (*fp) += anonymous_size * bits_per_byte
+               - bit_offset - FIELD_BITSIZE (*fp);
            }
        }
 
@@ -1806,11 +1806,10 @@ dwarf2_add_field (fip, die, objfile)
          complain (&dwarf2_bad_static_member_name, physname);
        }
 
-      fp->bitpos = -1;
-      fp->bitsize = (long) obsavestring (physname, strlen (physname),
-                                        &objfile->type_obstack);
-      fp->type = die_type (die, objfile);
-      fp->name = obsavestring (fieldname, strlen (fieldname),
+      SET_FIELD_PHYSNAME (*fp, obsavestring (physname, strlen (physname),
+                                           &objfile->type_obstack));
+      FIELD_TYPE (*fp) = die_type (die, objfile);
+      FIELD_NAME (*fp) = obsavestring (fieldname, strlen (fieldname),
                               &objfile->type_obstack);
     }
   else if (die->tag == DW_TAG_inheritance)
@@ -1818,10 +1817,10 @@ dwarf2_add_field (fip, die, objfile)
       /* C++ base class field.  */
       attr = dwarf_attr (die, DW_AT_data_member_location);
       if (attr)
-       fp->bitpos = decode_locdesc (DW_BLOCK (attr), objfile) * bits_per_byte;
-      fp->bitsize = 0;
-      fp->type = die_type (die, objfile);
-      fp->name = type_name_no_tag (fp->type);
+       FIELD_BITPOS (*fp) = decode_locdesc (DW_BLOCK (attr), objfile) * bits_per_byte;
+      FIELD_BITSIZE (*fp) = 0;
+      FIELD_TYPE (*fp) = die_type (die, objfile);
+      FIELD_NAME (*fp) = type_name_no_tag (fp->type);
       fip->nbaseclasses++;
     }
 }
@@ -2379,10 +2378,10 @@ read_enumeration (die, objfile)
                                    * sizeof (struct field));
                    }
 
-                 fields[num_fields].name = SYMBOL_NAME (sym);
-                 fields[num_fields].type = NULL;
-                 fields[num_fields].bitpos = SYMBOL_VALUE (sym);
-                 fields[num_fields].bitsize = 0;
+                 FIELD_NAME (fields[num_fields]) = SYMBOL_NAME (sym);
+                 FIELD_TYPE (fields[num_fields]) = NULL;
+                 FIELD_BITPOS (fields[num_fields]) = SYMBOL_VALUE (sym);
+                 FIELD_BITSIZE (fields[num_fields]) = 0;
 
                  num_fields++;
                }
index cec763a..07358bd 100644 (file)
@@ -1086,10 +1086,10 @@ struct_type (dip, thisdie, enddie, objfile)
          list -> field.name =
              obsavestring (mbr.at_name, strlen (mbr.at_name),
                            &objfile -> type_obstack);
-         list -> field.type = decode_die_type (&mbr);
-         list -> field.bitpos = 8 * locval (&mbr);
+         FIELD_TYPE (list->field) = decode_die_type (&mbr);
+         FIELD_BITPOS (list->field) = 8 * locval (&mbr);
          /* Handle bit fields. */
-         list -> field.bitsize = mbr.at_bit_size;
+         FIELD_BITSIZE (list->field) = mbr.at_bit_size;
          if (BITS_BIG_ENDIAN)
            {
              /* For big endian bits, the at_bit_offset gives the
@@ -1097,7 +1097,7 @@ struct_type (dip, thisdie, enddie, objfile)
                 anonymous object to the MSB of the field.  We don't
                 have to do anything special since we don't need to
                 know the size of the anonymous object. */
-             list -> field.bitpos += mbr.at_bit_offset;
+             FIELD_BITPOS (list->field) += mbr.at_bit_offset;
            }
          else
            {
@@ -1127,7 +1127,7 @@ struct_type (dip, thisdie, enddie, objfile)
                         a debug information size optimization. */
                      anonymous_size = TYPE_LENGTH (list -> field.type);
                    }
-                 list -> field.bitpos +=
+                 FIELD_BITPOS (list->field) +=
                    anonymous_size * 8 - mbr.at_bit_offset - mbr.at_bit_size;
                }
            }
@@ -1771,9 +1771,9 @@ enum_type (dip, objfile)
          new = (struct nextfield *) alloca (sizeof (struct nextfield));
          new -> next = list;
          list = new;
-         list -> field.type = NULL;
-         list -> field.bitsize = 0;
-         list -> field.bitpos =
+         FIELD_TYPE (list->field) = NULL;
+         FIELD_BITSIZE (list->field) = 0;
+         FIELD_BITPOS (list->field) =
            target_to_host (scan, TARGET_FT_LONG_SIZE (objfile), GET_SIGNED,
                            objfile);
          scan += TARGET_FT_LONG_SIZE (objfile);
@@ -1791,7 +1791,7 @@ enum_type (dip, objfile)
          SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
          SYMBOL_CLASS (sym) = LOC_CONST;
          SYMBOL_TYPE (sym) = type;
-         SYMBOL_VALUE (sym) = list -> field.bitpos;
+         SYMBOL_VALUE (sym) = FIELD_BITPOS (list->field);
          if (SYMBOL_VALUE (sym) < 0)
            unsigned_enum = 0;
          add_symbol_to_list (sym, list_in_scope);
index 02e762d..37270f5 100644 (file)
@@ -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]
index 68bb40f..9afaff1 100644 (file)
@@ -1330,7 +1330,6 @@ hpread_read_enum_type (hp_type, dn_bufp, objfile)
          struct symbol *xsym = syms->symbol[j];
          SYMBOL_TYPE (xsym) = type;
          TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
-         TYPE_FIELD_VALUE (type, n) = 0;
          TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
          TYPE_FIELD_BITSIZE (type, n) = 0;
        }
index 6adba9b..0e3f3e8 100644 (file)
@@ -1124,10 +1124,10 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
                if (tsym.st != stMember)
                  break;
 
-               f->bitpos = tsym.value;
-               f->type = t;
-               f->name = debug_info->ss + cur_fdr->issBase + tsym.iss;
-               f->bitsize = 0;
+               FIELD_BITPOS (*f) = tsym.value;
+               FIELD_TYPE (*f) = t;
+               FIELD_NAME (*f) = debug_info->ss + cur_fdr->issBase + tsym.iss;
+               FIELD_BITSIZE (*f) = 0;
 
                enum_sym = ((struct symbol *)
                            obstack_alloc (&current_objfile->symbol_obstack,
@@ -1314,11 +1314,11 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
 
     case stMember:             /* member of struct or union */
       f = &TYPE_FIELDS (top_stack->cur_type)[top_stack->cur_field++];
-      f->name = name;
-      f->bitpos = sh->value;
+      FIELD_NAME (*f) = name;
+      FIELD_BITPOS (*f) = sh->value;
       bitsize = 0;
-      f->type = parse_type (cur_fd, ax, sh->index, &bitsize, bigend, name);
-      f->bitsize = bitsize;
+      FIELD_TYPE (*f) = parse_type (cur_fd, ax, sh->index, &bitsize, bigend, name);
+      FIELD_BITSIZE (*f) = bitsize;
       break;
 
     case stIndirect:           /* forward declaration on Irix5 */
index e779c93..f052a3b 100644 (file)
@@ -655,7 +655,7 @@ read_cfront_baseclasses (fip, pp, type, objfile)
       memset (new, 0, sizeof (struct nextfield));
       new -> next = fip -> list;
       fip -> list = new;
-      new -> field.bitsize = 0; /* this should be an unpacked field! */
+      FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */
 
       STABS_CONTINUE (pp, objfile);
 
@@ -703,7 +703,7 @@ read_cfront_baseclasses (fip, pp, type, objfile)
           Assuming no multiple inheritance for now FIXME! */
        /* We may have read this in the structure definition;
           now we should fixup the members to be the actual base classes */
-        new -> field.bitpos = 0;
+        FIELD_BITPOS (new->field) = 0;
 
        /* Get the base class name and type */
          {
@@ -2832,12 +2832,12 @@ read_cpp_abbrev (fip, pp, type, objfile)
 
       {
        int nbits;
-       fip->list->field.bitpos = read_huge_number (pp, ';', &nbits);
+       FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ';', &nbits);
        if (nbits != 0)
          return 0;
       }
       /* This field is unpacked.  */
-      fip->list->field.bitsize = 0;
+      FIELD_BITSIZE (fip->list->field) = 0;
       fip->list->visibility = VISIBILITY_PRIVATE;
     }
   else
@@ -2875,12 +2875,12 @@ read_one_struct_field (fip, pp, p, type, objfile)
           dem_p = strrchr (dem, ':');
           if (dem_p != 0 && *(dem_p-1)==':')
             dem_p++;
-          fip->list->field.name =
+          FIELD_NAME (fip->list->field) =
             obsavestring (dem_p, strlen(dem_p), &objfile -> type_obstack);
         }
       else
         {
-          fip->list->field.name =
+          FIELD_NAME (fip->list->field) =
             obsavestring (*pp, p - *pp, &objfile -> type_obstack);
         }
       *p = save_p;
@@ -2915,17 +2915,14 @@ read_one_struct_field (fip, pp, p, type, objfile)
          fip -> list -> field.bitpos = (long)-2; /* nested type */
          p = ++(*pp);
        }
-      else
+      else ...;
 #endif
-       {
-         /* Static class member.  */
-         fip -> list -> field.bitpos = (long) -1;
-       }
       while (*p != ';') 
        {
          p++;
        }
-      fip -> list -> field.bitsize = (long) savestring (*pp, p - *pp);
+      /* Static class member.  */
+      SET_FIELD_PHYSNAME (fip->list->field, savestring (*pp, p - *pp));
       *pp = p + 1;
       return;
     }
@@ -2940,13 +2937,13 @@ read_one_struct_field (fip, pp, p, type, objfile)
 
   {
     int nbits;
-    fip -> list -> field.bitpos = read_huge_number (pp, ',', &nbits);
+    FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ',', &nbits);
     if (nbits != 0)
       {
        complain (&stabs_general_complaint, "bad structure-type format");
        return;
       }
-    fip -> list -> field.bitsize = read_huge_number (pp, ';', &nbits);
+    FIELD_BITSIZE (fip->list->field) = read_huge_number (pp, ';', &nbits);
     if (nbits != 0)
       {
        complain (&stabs_general_complaint, "bad structure-type format");
@@ -2954,7 +2951,8 @@ read_one_struct_field (fip, pp, p, type, objfile)
       }
   }
 
-  if (fip -> list -> field.bitpos == 0 && fip -> list -> field.bitsize == 0)
+  if (FIELD_BITPOS (fip->list->field) == 0
+      && FIELD_BITSIZE (fip->list->field) == 0)
     {
       /* This can happen in two cases: (1) at least for gcc 2.4.5 or so,
         it is a field which has been optimized out.  The correct stab for
@@ -2980,23 +2978,21 @@ read_one_struct_field (fip, pp, p, type, objfile)
         Note that forward refs cannot be packed,
         and treat enums as if they had the width of ints.  */
 
-      if (TYPE_CODE (fip -> list -> field.type) != TYPE_CODE_INT
-         && TYPE_CODE (fip -> list -> field.type) != TYPE_CODE_BOOL
-         && TYPE_CODE (fip -> list -> field.type) != TYPE_CODE_ENUM)
+      if (TYPE_CODE (FIELD_TYPE (fip->list->field)) != TYPE_CODE_INT
+         && TYPE_CODE (FIELD_TYPE (fip->list->field)) != TYPE_CODE_BOOL
+         && TYPE_CODE (FIELD_TYPE (fip->list->field)) != TYPE_CODE_ENUM)
        {
-         fip -> list -> field.bitsize = 0;
+         FIELD_BITSIZE (fip->list->field) = 0;
        }
-      if ((fip -> list -> field.bitsize 
-          == TARGET_CHAR_BIT * TYPE_LENGTH (fip -> list -> field.type)
-          || (TYPE_CODE (fip -> list -> field.type) == TYPE_CODE_ENUM
-              && (fip -> list -> field.bitsize
-                  == TARGET_INT_BIT)
-              )
+      if ((FIELD_BITSIZE (fip->list->field) 
+          == TARGET_CHAR_BIT * TYPE_LENGTH (FIELD_TYPE (fip->list->field))
+          || (TYPE_CODE (FIELD_TYPE (fip->list->field)) == TYPE_CODE_ENUM
+              && FIELD_BITSIZE (fip->list->field) == TARGET_INT_BIT )
           )
          &&
-         fip -> list -> field.bitpos % 8 == 0)
+         FIELD_BITPOS (fip->list->field) % 8 == 0)
        {
-         fip -> list -> field.bitsize = 0;
+         FIELD_BITSIZE (fip->list->field) = 0;
        }
     }
 }
@@ -3170,7 +3166,7 @@ read_baseclasses (fip, pp, type, objfile)
       memset (new, 0, sizeof (struct nextfield));
       new -> next = fip -> list;
       fip -> list = new;
-      new -> field.bitsize = 0;        /* this should be an unpacked field! */
+      FIELD_BITSIZE (new->field) = 0;  /* this should be an unpacked field! */
 
       STABS_CONTINUE (pp, objfile);
       switch (**pp)
@@ -3216,7 +3212,7 @@ read_baseclasses (fip, pp, type, objfile)
           corresponding to this baseclass.  Always zero in the absence of
           multiple inheritance.  */
 
-       new -> field.bitpos = read_huge_number (pp, ',', &nbits);
+       FIELD_BITPOS (new->field) = read_huge_number (pp, ',', &nbits);
        if (nbits != 0)
          return 0;
       }
@@ -3403,9 +3399,7 @@ read_cfront_static_fields(fip, pp, type, objfile)
       fip -> list -> field.type = stype; 
 
       /* set bitpos & bitsize */
-      fip -> list -> field.bitpos = (long) -1; /* -1 signifies a static member */
-      /* YUK!  what a hack!  bitsize used for physname when field is static */
-      fip -> list -> field.bitsize = (long) savestring (sname, strlen(sname));
+      SET_FIELD_PHYSNAME (fip->list->field, savestring (sname, strlen(sname)));
 
       /* set name field */
       /* The following is code to work around cfront generated stabs.
@@ -3817,7 +3811,6 @@ read_enum_type (pp, type, objfile)
          struct symbol *xsym = syms->symbol[j];
          SYMBOL_TYPE (xsym) = type;
          TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
-         TYPE_FIELD_VALUE (type, n) = 0;
          TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
          TYPE_FIELD_BITSIZE (type, n) = 0;
        }
index ff29d31..6f631ac 100644 (file)
@@ -714,12 +714,37 @@ unpack_pointer (type, valaddr)
   return unpack_long (type, valaddr);
 }
 \f
+/* Get the value of the FIELDN'th field (which must be static) of TYPE. */
+
+value_ptr
+value_static_field (type, fieldno)
+     struct type *type;
+     int fieldno;
+{
+  CORE_ADDR addr;
+  asection *sect;
+  if (TYPE_FIELD_STATIC_HAS_ADDR (type, fieldno))
+    {
+      addr = TYPE_FIELD_STATIC_PHYSADDR (type, fieldno);
+      sect = NULL;
+    }
+  else
+    {
+      char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
+      struct symbol *sym = lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL);
+      if (sym == NULL)
+       return NULL;
+      addr = SYMBOL_VALUE_ADDRESS (sym);
+      sect = SYMBOL_BFD_SECTION (sym);
+      SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno), addr);
+    }
+  return value_at (TYPE_FIELD_TYPE (type, fieldno), addr, sect);
+}
+
 /* Given a value ARG1 (offset by OFFSET bytes)
    of a struct or union type ARG_TYPE,
-   extract and return the value of one of its fields.
-   FIELDNO says which field.
-
-   For C++, must also be able to return values from static fields */
+   extract and return the value of one of its (non-static) fields.
+   FIELDNO says which field. */
 
 value_ptr
 value_primitive_field (arg1, offset, fieldno, arg_type)
@@ -764,10 +789,8 @@ value_primitive_field (arg1, offset, fieldno, arg_type)
 }
 
 /* Given a value ARG1 of a struct or union type,
-   extract and return the value of one of its fields.
-   FIELDNO says which field.
-
-   For C++, must also be able to return values from static fields */
+   extract and return the value of one of its (non-static) fields.
+   FIELDNO says which field. */
 
 value_ptr
 value_field (arg1, fieldno)