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: [Ada/dwarf] New DW_AT_GNAT_descriptive_type DWARF attribute...


[switching to gdb-patches]

> A few years ago, we introduced a new attribute named
> DW_AT_GNAT_descriptive_type, whose purpose was to provide a direct
> link from a type to its parallel type.  For instance, for certain
> array types, the array bounds are expressed through a parallel
> type whose name is the same as the array type, but with an extra
> ___XA suffix. What GDB needs to do, then, is search all the types
> to see if it can find a type with that ___XA suffix. The new
> attribute makes that search instantaneous.
[...]
> The changes in GDB are relatively small, I think - at least in
> the DWARF reader part. We added a field in the gnat_specific part
> of struct type, and I can see how it could trigger some protests.
> But we can discuss the specifics of the patch if there are no
> objections to this new attribute.

Just FYI, here is the patch in question. It's provided as is, and
I'm not suggesting we check it in. It's just to give everyone an
idea of what the change is about.

The idea of the patch is to stuff the descriptive-type info inside
the type_specific part of struct main_type as what we call the
GNAT_AUX_INFO.  In the Ada part, when we do a parallel lookup,
we check whether we HAVE_GNAT_AUX_INFO, and if we do, then follow
that info to see if we can find our type.  Otherwise, we fallback
to the traditional method (used with stabs, for instance).

There are a couple of things that we should discuss:

  1. Detection of the use of this attribute: Right now, the FSF GCC
     does not produce this attribute, so we need to be able to
     detect when the attribute is in use and when it's not.
     AdaCore has been using it by default for a little more than
     a couple of years, so we now assume that it's available.
     For FSF GDB, however, we'll need a detection mechanism.
     The way AdaCore did it was through a special keyword in
     the DW_AT_producer CU attribute.  We parse the attribute and
     if we find the keyword, then bingo.  The goal is to use that
     keyword for a few GCC/GDB release until we can start assuming
     the attribute is always used.  Then stop checking that keyword,
     followed a while later by stopping to emit the keyword.

     It's kind of kludgy, so any other suggestion is welcome.

   2. The dreaded gnat_stuff addition to the type_specific area
      in struct main_type. Pretty kludgy, borderlining on gross :-).
      The problem, as you can see, is that we can have either some
      CPLUS_SPECIFIC or some GNAT_SPECIFIC stuff in that area
      depending on the language associated to the type.  But since
      the type doesn't provide the language, we resorted to a hack
      where we check a magic flag in the GNAT stuff.

      I think the proper way of doing this is to have a discriminant
      in struct main_type that tells us which field is active, if any.

      This part could be designed independently of adding support
      for our new attribute, which I'm happy to do.

What I'd like to do, however, is get a consensus on whether we're OK
with supporting this attribute, and how GCC is supposed to tell GDB
that the attribute is being used.  That way, we can start on the GCC
end as well.

Thanks,
-- 
Joel
commit fa841722941a08bbc208776bd3cbd1bca948671d
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Thu Apr 23 16:31:26 2009 -0700

    Add support for DW_AT_GNAT_descriptive_type...

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 09d6897..447f916 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -162,6 +162,9 @@ static struct value *evaluate_subexp (struct type *, struct expression *,
 
 static struct value *evaluate_subexp_type (struct expression *, int *);
 
+static struct type *ada_find_parallel_type_with_name (struct type *,
+                                                      const char *);
+
 static int is_dynamic_field (struct type *, int);
 
 static struct type *to_fixed_variant_branch_type (struct type *,
@@ -1782,13 +1785,13 @@ decode_packed_array_type (struct type *type)
   memcpy (name, raw_name, tail - raw_name);
   name[tail - raw_name] = '\000';
 
-  sym = standard_lookup (name, get_selected_block (0), VAR_DOMAIN);
-  if (sym == NULL || SYMBOL_TYPE (sym) == NULL)
+  shadow_type = ada_find_parallel_type_with_name (type, name);
+
+  if (shadow_type == NULL)
     {
       lim_warning (_("could not find bounds information on packed array"));
       return NULL;
     }
-  shadow_type = SYMBOL_TYPE (sym);
   CHECK_TYPEDEF (shadow_type);
 
   if (TYPE_CODE (shadow_type) != TYPE_CODE_ARRAY)
@@ -6617,31 +6620,90 @@ ada_type_name (struct type *type)
     return TYPE_TAG_NAME (type);
 }
 
-/* Find a parallel type to TYPE whose name is formed by appending
+/* Search the list of "descriptive" types associated to TYPE for a type
+   whose name is NAME.  */
+
+static struct type *
+find_parallel_type_by_descriptive_type (struct type *type, const char *name)
+{
+  struct type *result;
+
+  /* If there no descriptive-type info, then there is no parallel type
+     to be found.  */
+  if (!HAVE_GNAT_AUX_INFO (type))
+    return NULL;
+
+  result = TYPE_DESCRIPTIVE_TYPE (type);
+  while (result != NULL)
+    {
+      char *result_name = ada_type_name (result);
+
+      if (result_name == NULL)
+        {
+          warning (_("unexpected null name on descriptive type"));
+          return NULL;
+        }
+
+      /* If the names match, stop.  */
+      if (strcmp (result_name, name) == 0)
+	break;
+
+      /* Otherwise, look at the next item on the list, if any.  */
+      if (HAVE_GNAT_AUX_INFO (result))
+	result = TYPE_DESCRIPTIVE_TYPE (result);
+      else
+	result = NULL;
+    }
+
+  /* If we didn't find a match, see whether this is a packed array.  With
+     older compilers, the descriptive type information is either absent or
+     irrelevant when it comes to packed arrays so the above lookup fails.
+     Fall back to using a parallel lookup by name in this case.  */
+  if (result == NULL && ada_is_packed_array_type (type))
+    return ada_find_any_type (name);
+
+  return result;
+}
+
+/* Find a parallel type to TYPE with the specified NAME, using the
+   descriptive type taken from the debugging information, if available,
+   and otherwise using the (slower) name-based method.  */
+
+static struct type *
+ada_find_parallel_type_with_name (struct type *type, const char *name)
+{
+  struct type *result = NULL;
+
+  if (HAVE_GNAT_AUX_INFO (type))
+    result = find_parallel_type_by_descriptive_type (type, name);
+  else
+    result = ada_find_any_type (name);
+
+  return result;
+}
+
+/* Same as above, but specify the name of the parallel type by appending
    SUFFIX to the name of TYPE.  */
 
 struct type *
 ada_find_parallel_type (struct type *type, const char *suffix)
 {
-  static char *name;
-  static size_t name_len = 0;
+  char *name, *typename = ada_type_name (type);
   int len;
-  char *typename = ada_type_name (type);
 
   if (typename == NULL)
     return NULL;
 
   len = strlen (typename);
 
-  GROW_VECT (name, name_len, len + strlen (suffix) + 1);
+  name = (char *) alloca (len + strlen (suffix) + 1);
 
   strcpy (name, typename);
   strcpy (name + len, suffix);
 
-  return ada_find_any_type (name);
+  return ada_find_parallel_type_with_name (type, name);
 }
 
-
 /* If TYPE is a variable-size record type, return the corresponding template
    type describing its fields.  Otherwise, return NULL.  */
 
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 3da58ea..6aa7131 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -1098,8 +1098,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 
 	  /* Bitfields require special handling, especially due to byte
 	     order problems.  */
-	  if (TYPE_CPLUS_SPECIFIC (type) != NULL
-	      && TYPE_FIELD_IGNORE (type, i))
+	  if (HAVE_CPLUS_STRUCT (type) && TYPE_FIELD_IGNORE (type, i))
 	    {
 	      fputs_filtered (_("<optimized out or zero length>"), stream);
 	    }
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index c3f3838..13d5c13 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -914,6 +914,13 @@ static void dwarf2_const_value_data (struct attribute *attr,
 
 static struct type *die_type (struct die_info *, struct dwarf2_cu *);
 
+static int need_gnat_info (struct dwarf2_cu *);
+
+static struct type *die_descriptive_type (struct die_info *, struct dwarf2_cu *);
+
+static void set_descriptive_type (struct type *, struct die_info *,
+				  struct dwarf2_cu *);
+
 static struct type *die_containing_type (struct die_info *,
 					 struct dwarf2_cu *);
 
@@ -3801,7 +3808,7 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
     TYPE_ALLOC (type, sizeof (struct field) * nfields);
   memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields);
 
-  if (fip->non_public_fields)
+  if (fip->non_public_fields && cu->language != language_ada)
     {
       ALLOCATE_CPLUS_STRUCT_TYPE (type);
 
@@ -3820,7 +3827,7 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
 
   /* If the type has baseclasses, allocate and clear a bit vector for
      TYPE_FIELD_VIRTUAL_BITS.  */
-  if (fip->nbaseclasses)
+  if (fip->nbaseclasses && cu->language != language_ada)
     {
       int num_bytes = B_BYTES (fip->nbaseclasses);
       unsigned char *pointer;
@@ -3841,11 +3848,13 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
       switch (fip->fields->accessibility)
 	{
 	case DW_ACCESS_private:
-	  SET_TYPE_FIELD_PRIVATE (type, nfields);
+	  if (cu->language != language_ada)
+	    SET_TYPE_FIELD_PRIVATE (type, nfields);
 	  break;
 
 	case DW_ACCESS_protected:
-	  SET_TYPE_FIELD_PROTECTED (type, nfields);
+	  if (cu->language != language_ada)
+	    SET_TYPE_FIELD_PROTECTED (type, nfields);
 	  break;
 
 	case DW_ACCESS_public:
@@ -3865,6 +3874,8 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
 	    {
 	    case DW_VIRTUALITY_virtual:
 	    case DW_VIRTUALITY_pure_virtual:
+	      if (cu->language == language_ada)
+		error ("unexpected virtuality in component of Ada type");
 	      SET_TYPE_FIELD_VIRTUAL (type, nfields);
 	      break;
 	    }
@@ -3889,6 +3900,9 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
   struct nextfnfield *new_fnfield;
   struct type *this_type;
 
+  if (cu->language == language_ada)
+    error ("unexpected member function in Ada type");
+
   /* Get name of member function.  */
   fieldname = dwarf2_name (die, cu);
   if (fieldname == NULL)
@@ -4024,6 +4038,9 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type,
   int total_length = 0;
   int i;
 
+  if (cu->language == language_ada)
+    error ("unexpected member functions in Ada type");
+
   ALLOCATE_CPLUS_STRUCT_TYPE (type);
   TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
     TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * fip->nfnfields);
@@ -4208,6 +4225,8 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
   if (die_is_declaration (die, cu))
     TYPE_STUB (type) = 1;
 
+  set_descriptive_type (type, die, cu);
+
   /* We need to add the type field to the die immediately so we don't
      infinitely recurse when dealing with pointers to the structure
      type within the structure itself. */
@@ -4608,6 +4627,8 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
   if (name)
     TYPE_NAME (type) = name;
   
+  set_descriptive_type (type, die, cu);
+
   do_cleanups (back_to);
 
   /* Install the type in the die. */
@@ -5247,6 +5268,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
   if (attr)
     TYPE_LENGTH (range_type) = DW_UNSND (attr);
 
+  set_descriptive_type (range_type, die, cu);
+
   return set_die_type (die, range_type, cu);
 }
   
@@ -7970,6 +7993,69 @@ die_type (struct die_info *die, struct dwarf2_cu *cu)
   return type;
 }
 
+/* True iff CU's producer generates GNAT Ada auxiliary information
+   that allows to find parallel types through that information instead
+   of having to do expensive parallel lookups by type name.  */
+
+static int
+need_gnat_info (struct dwarf2_cu *cu)
+{
+  /* Assume that the Ada compiler was GNAT, which always produces
+     the auxiliary information.  */
+  return (cu->language == language_ada);
+}
+
+
+/* Return the auxiliary type of the die in question using its
+   DW_AT_GNAT_descriptive_type attribute.  Returns NULL if the
+   attribute is not present.  */
+
+static struct type *
+die_descriptive_type (struct die_info *die, struct dwarf2_cu *cu)
+{
+  struct type *type;
+  struct attribute *type_attr;
+  struct die_info *type_die;
+
+  type_attr = dwarf2_attr (die, DW_AT_GNAT_descriptive_type, cu);
+  if (!type_attr)
+    {
+      return NULL;
+    }
+  else
+    type_die = follow_die_ref (die, type_attr, &cu);
+
+  type = tag_type_to_type (type_die, cu);
+  if (!type)
+    {
+      dump_die_for_error (type_die);
+      error (_("Dwarf Error: Problem turning type die at offset into gdb type [in module %s]"),
+		      cu->objfile->name);
+    }
+  return type;
+}
+
+/* If DIE has a descriptive_type attribute, then set the TYPE's
+   descriptive type accordingly.  */
+
+static void
+set_descriptive_type (struct type *type, struct die_info *die,
+		      struct dwarf2_cu *cu)
+{
+  struct type *descriptive_type = die_descriptive_type (die, cu);
+
+  if (descriptive_type)
+    {
+      /* Call INIT_GNAT_SPECIFIC before allocating the GNAT AUX type.
+         ALLOCATE_GNAT_AUX_TYPE makes the assumption that the type-
+         specific stuff should already be initialized with GNAT-specific 
+         data.  */
+      INIT_GNAT_SPECIFIC (type);
+      ALLOCATE_GNAT_AUX_TYPE (type);
+      TYPE_DESCRIPTIVE_TYPE (type) = descriptive_type;
+    }
+}
+
 /* Return the containing type of the die in question using its
    DW_AT_containing_type attribute.  */
 
@@ -10686,6 +10772,19 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 {
   struct dwarf2_offset_and_type **slot, ofs;
 
+  /* For Ada types, make sure that the gnat-specific data is always
+     initialized (if not already set).  There are a few types where
+     we should not be doing so, because the type-specific area is
+     already used to hold some other piece of info (eg: TYPE_CODE_FLT
+     where the type-specific area is used to store the floatformat).
+     But this is not a problem, because the gnat-specific information
+     is actually not needed for these types.  */
+  if (need_gnat_info (cu)
+      && TYPE_CODE (type) != TYPE_CODE_FUNC
+      && TYPE_CODE (type) != TYPE_CODE_FLT
+      && !HAVE_GNAT_AUX_INFO (type))
+    INIT_GNAT_SPECIFIC (type);
+
   if (cu->type_hash == NULL)
     {
       gdb_assert (cu->per_cu != NULL);
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index fb52e1a..2fc8252 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1208,6 +1208,7 @@ struct type *
 lookup_struct_elt_type (struct type *type, char *name, int noerr)
 {
   int i;
+  int n_base_classes;
 
   for (;;)
     {
@@ -1242,7 +1243,11 @@ lookup_struct_elt_type (struct type *type, char *name, int noerr)
   }
 #endif
 
-  for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
+  if (! HAVE_CPLUS_STRUCT (type))
+    n_base_classes = 0;
+  else
+    n_base_classes = TYPE_N_BASECLASSES (type);
+  for (i = TYPE_NFIELDS (type) - 1; i >= n_base_classes; i -= 1)
     {
       char *t_field_name = TYPE_FIELD_NAME (type, i);
 
@@ -1253,7 +1258,7 @@ lookup_struct_elt_type (struct type *type, char *name, int noerr)
     }
 
   /* OK, it's not in this class.  Recursively check the baseclasses.  */
-  for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
+  for (i = n_base_classes - 1; i >= 0; i--)
     {
       struct type *t;
 
@@ -1733,12 +1738,31 @@ allocate_cplus_struct_type (struct type *type)
 {
   if (!HAVE_CPLUS_STRUCT (type))
     {
-      TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
+      if (HAVE_GNAT_AUX_INFO (type))
+	error (_("type has both Ada and C++ auxiliary information"));
+      TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
 	TYPE_ALLOC (type, sizeof (struct cplus_struct_type));
-      *(TYPE_CPLUS_SPECIFIC (type)) = cplus_struct_default;
+      *(TYPE_RAW_CPLUS_SPECIFIC (type)) = cplus_struct_default;
+    }
+}
+
+const struct gnat_aux_type gnat_aux_default =
+  { -1, 0, 0 };
+
+void allocate_gnat_aux_type (struct type *type)
+{
+  if (HAVE_CPLUS_STRUCT (type))
+    error (_("type has both Ada and C++ auxiliary information"));
+  if (!HAVE_GNAT_AUX_INFO (type) 
+      || TYPE_GNAT_SPECIFIC (type) == &gnat_aux_default)
+    {
+      TYPE_GNAT_SPECIFIC (type) = (struct gnat_aux_type *)
+	TYPE_ALLOC (type, sizeof (struct gnat_aux_type));
+      *(TYPE_GNAT_SPECIFIC (type)) = gnat_aux_default;
     }
 }
 
+
 /* Helper function to initialize the standard scalar types.
 
    If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy of
@@ -2587,7 +2611,7 @@ recursive_dump_type (struct type *type, int spaces)
     obstack_begin (&dont_print_type_obstack, 0);
 
   if (TYPE_NFIELDS (type) > 0
-      || (TYPE_CPLUS_SPECIFIC (type) && TYPE_NFN_FIELDS (type) > 0))
+      || (HAVE_CPLUS_STRUCT (type) && TYPE_NFN_FIELDS (type) > 0))
     {
       struct type **first_dont_print
 	= (struct type **) obstack_base (&dont_print_type_obstack);
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 3c4e948..50e87cf 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -520,6 +520,14 @@ struct main_type
 
     const struct floatformat **floatformat;
 
+    /* GNAT_STUFF is for types for which the GNAT Ada compiler
+       provides additional information.  It may apply to
+       TYPE_CODE_STRUCT, and TYPE_CODE_UNION, where it is
+       distinguished from a cplus_stuff by the value of its first
+       field (a short), which is <0 for GNAT types.  
+       FIXME: This is kludgy. */
+    struct gnat_aux_type *gnat_stuff;
+
     /* For TYPE_CODE_FUNC types, the calling convention for targets
        supporting multiple ABIs.  Right now this is only fetched from
        the Dwarf-2 DW_AT_calling_convention attribute.  */
@@ -777,6 +785,24 @@ struct badness_vector
     int *rank;
   };
 
+/* GNAT Ada-specific information for TYPE_CODE_STRUCT,  TYPE_CODE_UNION, 
+   ... (FIXME) */
+
+struct gnat_aux_type
+  {
+    /* Always -1 for gnat_aux_type data.  Chosen to be impossible
+     * value for cplus_struct_type field. */
+    short magic_flag;
+    
+    /* String encoding various Ada-specific additional type
+       information. */
+    const char* encoding;
+
+    /* Parallel type used to encode information about dynamic unions
+       and structs used in Ada. */
+    struct type* descriptive_type;
+  };
+
 /* The default value of TYPE_CPLUS_SPECIFIC(T) points to the
    this shared static structure. */
 
@@ -785,10 +811,33 @@ extern const struct cplus_struct_type cplus_struct_default;
 extern void allocate_cplus_struct_type (struct type *);
 
 #define INIT_CPLUS_SPECIFIC(type) \
-  (TYPE_CPLUS_SPECIFIC(type)=(struct cplus_struct_type*)&cplus_struct_default)
+  (TYPE_RAW_CPLUS_SPECIFIC(type)=(struct cplus_struct_type*)&cplus_struct_default)
 #define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
 #define HAVE_CPLUS_STRUCT(type) \
-  (TYPE_CPLUS_SPECIFIC(type) != &cplus_struct_default)
+  (TYPE_RAW_CPLUS_SPECIFIC(type) != &cplus_struct_default \
+   && !HAVE_GNAT_AUX_INFO(type))
+
+extern const struct gnat_aux_type gnat_aux_default;
+
+extern void allocate_gnat_aux_type (struct type *);
+
+#define INIT_GNAT_SPECIFIC(type) \
+  (TYPE_GNAT_SPECIFIC(type)=(struct gnat_aux_type*)&gnat_aux_default)
+#define ALLOCATE_GNAT_AUX_TYPE(type) allocate_gnat_aux_type (type)
+/* A macro that returns non-zero if the type-specific data should be
+   read as "gnat-stuff".  Normally, we do this by checking that the
+   gnat_stuff pointer is not NULL, and then by checking that it points
+   to a structure where the magic_flag is -1.  See the description
+   of the gnat_aux_type declaration for more detail.
+
+   We do however have to be careful of TYPE_CODE_FUNC types. For such
+   types, we know that GNAT doesn't generate any descriptive_type info,
+   whereas core GDB uses the type-specific union to store the calling
+   convention.  So never check the gnat_stuff pointer for such types.  */
+#define HAVE_GNAT_AUX_INFO(type) \
+  (TYPE_CODE (type) != TYPE_CODE_FUNC \
+   && TYPE_GNAT_SPECIFIC (type) != NULL \
+   && TYPE_MAGIC_FLAG(type) == -1)
 
 #define TYPE_INSTANCE_FLAGS(thistype) (thistype)->instance_flags
 #define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
@@ -839,8 +888,15 @@ extern void allocate_cplus_struct_type (struct type *);
 #define TYPE_NTEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ntemplate_args
 #define TYPE_DECLARED_TYPE(thistype) TYPE_CPLUS_SPECIFIC(thistype)->declared_type
 #define	TYPE_TYPE_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific
-#define TYPE_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
+#define TYPE_CPLUS_SPECIFIC(thistype) \
+   (HAVE_GNAT_AUX_INFO(thistype) ? (struct cplus_struct_type*)&cplus_struct_default\
+    : TYPE_RAW_CPLUS_SPECIFIC(thistype))
+#define TYPE_RAW_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
 #define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
+#define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff
+#define TYPE_MAGIC_FLAG(thistype) TYPE_GNAT_SPECIFIC(thistype)->magic_flag
+#define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type
+#define TYPE_GNAT_ENCODING(thistype) TYPE_GNAT_SPECIFIC(thistype)->encoding
 #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.calling_convention
 #define TYPE_BASECLASS(thistype,index) TYPE_MAIN_TYPE(thistype)->fields[index].type
 #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
@@ -951,7 +1007,7 @@ extern void allocate_cplus_struct_type (struct type *);
 #define TYPE_IS_OPAQUE(thistype) (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) ||        \
                                    (TYPE_CODE (thistype) == TYPE_CODE_UNION))        && \
                                   (TYPE_NFIELDS (thistype) == 0)                     && \
-                                  (TYPE_CPLUS_SPECIFIC (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)) && \
+                                  (HAVE_CPLUS_STRUCT (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)) && \
                                   (TYPE_STUB (thistype) || !TYPE_STUB_SUPPORTED (thistype)))
 
 struct builtin_type
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 6579d42..ed5eae1 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -183,7 +183,7 @@ total_number_of_methods (struct type *type)
   int count;
 
   CHECK_TYPEDEF (type);
-  if (TYPE_CPLUS_SPECIFIC (type) == NULL)
+  if (! HAVE_CPLUS_STRUCT (type))
     return 0;
   count = TYPE_NFN_FIELDS_TOTAL (type);
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 7cbcc59..db0de05 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4698,7 +4698,7 @@ new_type (char *name)
 
   t = alloc_type (current_objfile);
   TYPE_NAME (t) = name;
-  TYPE_CPLUS_SPECIFIC (t) = (struct cplus_struct_type *) &cplus_struct_default;
+  INIT_CPLUS_SPECIFIC (t);
   return t;
 }
 

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