* gdbtypes.c (copy_type): New function.
[deliverable/binutils-gdb.git] / gdb / gdbtypes.h
index 25b8c432f59f86a009c7abfe2e94a87ef7c93faf..2a41c5b90a6d7493c89dc40f5e2e2aa4318d1f38 100644 (file)
@@ -316,17 +316,15 @@ enum type_instance_flag_value
 #define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \
                                   & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
 
+/* Determine which field of the union main_type.fields[x].loc is used.  */
 
-/*  Array bound type.  */
-enum array_bound_type
-{
-  BOUND_SIMPLE = 0,
-  BOUND_BY_VALUE_IN_REG,
-  BOUND_BY_REF_IN_REG,
-  BOUND_BY_VALUE_ON_STACK,
-  BOUND_BY_REF_ON_STACK,
-  BOUND_CANNOT_BE_DETERMINED
-};
+enum field_loc_kind
+  {
+    FIELD_LOC_KIND_BITPOS,     /* bitpos */
+    FIELD_LOC_KIND_PHYSADDR,   /* physaddr */
+    FIELD_LOC_KIND_PHYSNAME,   /* physname */
+    FIELD_LOC_KIND_DWARF_BLOCK /* dwarf_block */
+  };
 
 /* This structure is space-critical.
    Its layout has been tweaked to reduce the space used.  */
@@ -337,12 +335,6 @@ struct main_type
 
   ENUM_BITFIELD(type_code) code : 8;
 
-  /* Array bounds.  These fields appear at this location because
-     they pack nicely here.  */
-
-  ENUM_BITFIELD(array_bound_type) upper_bound_type : 4;
-  ENUM_BITFIELD(array_bound_type) lower_bound_type : 4;
-
   /* Flags about this type.  These fields appear at this location
      because they packs nicely here.  See the TYPE_* macros for
      documentation about these fields.  */
@@ -455,19 +447,23 @@ struct main_type
 
       CORE_ADDR physaddr;
       char *physname;
+
+      /* The field location can be computed by evaluating the following DWARF
+        block.  This can be used in Fortran variable-length arrays, for
+        instance.  */
+
+      struct dwarf2_locexpr_baton *dwarf_block;
     }
     loc;
 
     /* For a function or member type, this is 1 if the argument is marked
        artificial.  Artificial arguments should not be shown to the
-       user.  */
+       user.  For TYPE_CODE_RANGE it is set if the specific bound is not
+       defined.  */
     unsigned int artificial : 1;
 
-    /* This flag is zero for non-static fields, 1 for fields whose location
-       is specified by the label loc.physname, and 2 for fields whose location
-       is specified by loc.physaddr.  */
-
-    unsigned int static_kind : 2;
+    /* Discriminant for union field_location.  */
+    ENUM_BITFIELD(field_loc_kind) loc_kind : 2;
 
     /* Size of this field, in bits, or zero if not packed.
        For an unpacked field, the field's type's length
@@ -817,10 +813,10 @@ extern void allocate_cplus_struct_type (struct type *);
 
 /* Moto-specific stuff for FORTRAN arrays */
 
-#define TYPE_ARRAY_UPPER_BOUND_TYPE(thistype) \
-       TYPE_MAIN_TYPE(thistype)->upper_bound_type
-#define TYPE_ARRAY_LOWER_BOUND_TYPE(thistype) \
-       TYPE_MAIN_TYPE(thistype)->lower_bound_type
+#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
+   (TYPE_FIELD_ARTIFICIAL((TYPE_FIELD_TYPE((arraytype),0)),1))
+#define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
+   (TYPE_FIELD_ARTIFICIAL((TYPE_FIELD_TYPE((arraytype),0)),0))
 
 #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
    (TYPE_FIELD_BITPOS((TYPE_FIELD_TYPE((arraytype),0)),1))
@@ -855,20 +851,34 @@ extern void allocate_cplus_struct_type (struct type *);
 
 #define FIELD_TYPE(thisfld) ((thisfld).type)
 #define FIELD_NAME(thisfld) ((thisfld).name)
+#define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind)
 #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos)
+#define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname)
+#define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
+#define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block)
+#define SET_FIELD_BITPOS(thisfld, bitpos)                      \
+  (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_BITPOS,           \
+   FIELD_BITPOS (thisfld) = (bitpos))
+#define SET_FIELD_PHYSNAME(thisfld, name)                      \
+  (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME,         \
+   FIELD_STATIC_PHYSNAME (thisfld) = (name))
+#define SET_FIELD_PHYSADDR(thisfld, addr)                      \
+  (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR,         \
+   FIELD_STATIC_PHYSADDR (thisfld) = (addr))
+#define SET_FIELD_DWARF_BLOCK(thisfld, addr)                   \
+  (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_DWARF_BLOCK,      \
+   FIELD_DWARF_BLOCK (thisfld) = (addr))
 #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
 #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
-#define FIELD_STATIC_KIND(thisfld) ((thisfld).static_kind)
-#define FIELD_PHYSNAME(thisfld) ((thisfld).loc.physname)
-#define FIELD_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
-#define SET_FIELD_PHYSNAME(thisfld, name) \
-  ((thisfld).static_kind = 1, FIELD_PHYSNAME(thisfld) = (name))
-#define SET_FIELD_PHYSADDR(thisfld, name) \
-  ((thisfld).static_kind = 2, FIELD_PHYSADDR(thisfld) = (name))
+
 #define TYPE_FIELD(thistype, n) TYPE_MAIN_TYPE(thistype)->fields[n]
 #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_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n))
+#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
+#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
+#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n))
+#define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n))
 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(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)
@@ -903,12 +913,6 @@ extern void allocate_cplus_struct_type (struct type *);
   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n)))
 
-#define TYPE_FIELD_STATIC(thistype, n) (TYPE_MAIN_TYPE (thistype)->fields[n].static_kind != 0)
-#define TYPE_FIELD_STATIC_KIND(thistype, n) TYPE_MAIN_TYPE (thistype)->fields[n].static_kind
-#define TYPE_FIELD_STATIC_HAS_ADDR(thistype, n) (TYPE_MAIN_TYPE (thistype)->fields[n].static_kind == 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]
 #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
@@ -977,12 +981,6 @@ struct builtin_type
 
   /* Integral types.  */
 
-  /* We use these for the '/c' print format, because c_char is just a
-     one-byte integral type, which languages less laid back than C
-     will print as ... well, a one-byte integral type.  */
-  struct type *builtin_true_char;
-  struct type *builtin_true_unsigned_char;
-
   /* Implicit size/sign (based on the the architecture's ABI).  */
   struct type *builtin_void;
   struct type *builtin_char;
@@ -1011,54 +1009,6 @@ struct builtin_type
 /* Return the type table for the specified architecture.  */
 extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
 
-/* Compatibility macros to access types for the current architecture.  */
-#define builtin_type_void_data_ptr \
-       (builtin_type (current_gdbarch)->builtin_data_ptr)
-#define builtin_type_void_func_ptr \
-       (builtin_type (current_gdbarch)->builtin_func_ptr)
-#define builtin_type_CORE_ADDR \
-       (builtin_type (current_gdbarch)->builtin_core_addr)
-#define builtin_type_true_char \
-       (builtin_type (current_gdbarch)->builtin_true_char)
-#define builtin_type_void \
-       (builtin_type (current_gdbarch)->builtin_void)
-#define builtin_type_char \
-       (builtin_type (current_gdbarch)->builtin_char)
-#define builtin_type_short \
-       (builtin_type (current_gdbarch)->builtin_short)
-#define builtin_type_int \
-       (builtin_type (current_gdbarch)->builtin_int)
-#define builtin_type_long \
-       (builtin_type (current_gdbarch)->builtin_long)
-#define builtin_type_signed_char \
-       (builtin_type (current_gdbarch)->builtin_signed_char)
-#define builtin_type_unsigned_char \
-       (builtin_type (current_gdbarch)->builtin_unsigned_char)
-#define builtin_type_unsigned_short \
-       (builtin_type (current_gdbarch)->builtin_unsigned_short)
-#define builtin_type_unsigned_int \
-       (builtin_type (current_gdbarch)->builtin_unsigned_int)
-#define builtin_type_unsigned_long \
-       (builtin_type (current_gdbarch)->builtin_unsigned_long)
-#define builtin_type_float \
-       (builtin_type (current_gdbarch)->builtin_float)
-#define builtin_type_double \
-       (builtin_type (current_gdbarch)->builtin_double)
-#define builtin_type_long_double \
-       (builtin_type (current_gdbarch)->builtin_long_double)
-#define builtin_type_complex \
-       (builtin_type (current_gdbarch)->builtin_complex)
-#define builtin_type_double_complex \
-       (builtin_type (current_gdbarch)->builtin_double_complex)
-#define builtin_type_string \
-       (builtin_type (current_gdbarch)->builtin_string)
-#define builtin_type_bool \
-       (builtin_type (current_gdbarch)->builtin_bool)
-#define builtin_type_long_long \
-       (builtin_type (current_gdbarch)->builtin_long_long)
-#define builtin_type_unsigned_long_long \
-       (builtin_type (current_gdbarch)->builtin_unsigned_long_long)
-
  
 /* Explicit sizes - see C9X <intypes.h> for naming scheme.  The "int0"
    is for when an architecture needs to describe a register that has
@@ -1096,88 +1046,22 @@ extern struct type *builtin_type_arm_ext;
 extern struct type *builtin_type_ia64_spill;
 extern struct type *builtin_type_ia64_quad;
 
-/* This type represents a type that was unrecognized in symbol
-   read-in.  */
-
-extern struct type *builtin_type_error;
-
+/* Platform-neutral void type.  Never attempt to construct a pointer
+   or reference type to this, because those cannot be platform-neutral.
+   You must use builtin_type (...)->builtin_void in those cases.  */
+extern struct type *builtin_type_void;
 
-/* Modula-2 types */
+/* Platform-neutral character types.
+   We use these for the '/c' print format, because c_char is just a
+   one-byte integral type, which languages less laid back than C
+   will print as ... well, a one-byte integral type.  */
+extern struct type *builtin_type_true_char;
+extern struct type *builtin_type_true_unsigned_char;
 
-struct builtin_m2_type
-{
-  struct type *builtin_char;
-  struct type *builtin_int;
-  struct type *builtin_card;
-  struct type *builtin_real;
-  struct type *builtin_bool;
-};
-
-/* Return the Modula-2 type table for the specified architecture.  */
-extern const struct builtin_m2_type *builtin_m2_type (struct gdbarch *gdbarch);
-
-/* Compatibility macros to access types for the current architecture.  */
-#define builtin_type_m2_char \
-       (builtin_m2_type (current_gdbarch)->builtin_char)
-#define builtin_type_m2_int \
-       (builtin_m2_type (current_gdbarch)->builtin_int)
-#define builtin_type_m2_card \
-       (builtin_m2_type (current_gdbarch)->builtin_card)
-#define builtin_type_m2_real \
-       (builtin_m2_type (current_gdbarch)->builtin_real)
-#define builtin_type_m2_bool \
-       (builtin_m2_type (current_gdbarch)->builtin_bool)
-
-
-/* Fortran (F77) types */
 
-struct builtin_f_type
-{
-  struct type *builtin_character;
-  struct type *builtin_integer;
-  struct type *builtin_integer_s2;
-  struct type *builtin_logical;
-  struct type *builtin_logical_s1;
-  struct type *builtin_logical_s2;
-  struct type *builtin_real;
-  struct type *builtin_real_s8;
-  struct type *builtin_real_s16;
-  struct type *builtin_complex_s8;
-  struct type *builtin_complex_s16;
-  struct type *builtin_complex_s32;
-  struct type *builtin_void;
-};
-
-/* Return the Fortran type table for the specified architecture.  */
-extern const struct builtin_f_type *builtin_f_type (struct gdbarch *gdbarch);
-
-/* Compatibility macros to access types for the current architecture.  */
-#define builtin_type_f_character \
-       (builtin_f_type (current_gdbarch)->builtin_character)
-#define builtin_type_f_integer \
-       (builtin_f_type (current_gdbarch)->builtin_integer)
-#define builtin_type_f_integer_s2 \
-       (builtin_f_type (current_gdbarch)->builtin_integer_s2)
-#define builtin_type_f_logical \
-       (builtin_f_type (current_gdbarch)->builtin_logical)
-#define builtin_type_f_logical_s1 \
-       (builtin_f_type (current_gdbarch)->builtin_logical_s1)
-#define builtin_type_f_logical_s2 \
-       (builtin_f_type (current_gdbarch)->builtin_logical_s2)
-#define builtin_type_f_real \
-       (builtin_f_type (current_gdbarch)->builtin_real)
-#define builtin_type_f_real_s8 \
-       (builtin_f_type (current_gdbarch)->builtin_real_s8)
-#define builtin_type_f_real_s16 \
-       (builtin_f_type (current_gdbarch)->builtin_real_s16)
-#define builtin_type_f_complex_s8 \
-       (builtin_f_type (current_gdbarch)->builtin_complex_s8)
-#define builtin_type_f_complex_s16 \
-       (builtin_f_type (current_gdbarch)->builtin_complex_s16)
-#define builtin_type_f_complex_s32 \
-       (builtin_f_type (current_gdbarch)->builtin_complex_s32)
-#define builtin_type_f_void \
-       (builtin_f_type (current_gdbarch)->builtin_void)
+/* This type represents a type that was unrecognized in symbol
+   read-in.  */
+extern struct type *builtin_type_error;
 
 
 /* RTTI for C++ */
@@ -1358,6 +1242,8 @@ extern int rank_one_type (struct type *, struct type *);
 
 extern void recursive_dump_type (struct type *, int);
 
+extern int field_is_static (struct field *);
+
 /* printcmd.c */
 
 extern void print_scalar_formatted (const void *, struct type *, int, int,
@@ -1375,4 +1261,6 @@ extern struct type *copy_type_recursive (struct objfile *objfile,
                                         struct type *type,
                                         htab_t copied_types);
 
+extern struct type *copy_type (const struct type *type);
+
 #endif /* GDBTYPES_H */
This page took 0.026756 seconds and 4 git commands to generate.