Implement support for Ada interface types.
authorJoel Brobecker <brobecker@gnat.com>
Tue, 1 Jan 2008 07:21:59 +0000 (07:21 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Tue, 1 Jan 2008 07:21:59 +0000 (07:21 +0000)
        * ada-lang.c (ada_is_dispatch_table_ptr_type): New function.
        (ada_is_ignored_field): Ignore fields that are a dispatch table
        of a tagged type.

gdb/ChangeLog
gdb/ada-lang.c

index 6dac3294524158d2ff80fcdab0f9dfe837eb7a77..41617bca52c6c048e0ffbd9e4e16c733461f2d46 100644 (file)
@@ -1,3 +1,11 @@
+2008-01-01  Joel Brobecker  <brobecker@adacore.com>
+
+       Implement support for Ada interface types.
+
+       * ada-lang.c (ada_is_dispatch_table_ptr_type): New function.
+       (ada_is_ignored_field): Ignore fields that are a dispatch table
+       of a tagged type.
+
 2008-01-01  Joel Brobecker  <brobecker@adacore.com>
 
        * top.c (print_gdb_version): Update copyright year.
index d61476225a3508c4c362b0825b538245e67d432b..949350615fb67b8f47b7c63ce6d2981af40a5b27 100644 (file)
@@ -5277,6 +5277,24 @@ ada_add_block_symbols (struct obstack *obstackp,
 \f
                                 /* Field Access */
 
+/* Return non-zero if TYPE is a pointer to the GNAT dispatch table used
+   for tagged types.  */
+
+static int
+ada_is_dispatch_table_ptr_type (struct type *type)
+{
+  char *name;
+
+  if (TYPE_CODE (type) != TYPE_CODE_PTR)
+    return 0;
+
+  name = TYPE_NAME (TYPE_TARGET_TYPE (type));
+  if (name == NULL)
+    return 0;
+
+  return (strcmp (name, "ada__tags__dispatch_table") == 0);
+}
+
 /* True if field number FIELD_NUM in struct or union type TYPE is supposed
    to be invisible to users.  */
 
@@ -5285,12 +5303,30 @@ ada_is_ignored_field (struct type *type, int field_num)
 {
   if (field_num < 0 || field_num > TYPE_NFIELDS (type))
     return 1;
-  else
-    {
-      const char *name = TYPE_FIELD_NAME (type, field_num);
-      return (name == NULL
-              || (name[0] == '_' && strncmp (name, "_parent", 7) != 0));
-    }
+   
+  /* Check the name of that field.  */
+  {
+    const char *name = TYPE_FIELD_NAME (type, field_num);
+
+    /* Anonymous field names should not be printed.
+       brobecker/2007-02-20: I don't think this can actually happen
+       but we don't want to print the value of annonymous fields anyway.  */
+    if (name == NULL)
+      return 1;
+
+    /* A field named "_parent" is internally generated by GNAT for
+       tagged types, and should not be printed either.  */
+    if (name[0] == '_' && strncmp (name, "_parent", 7) != 0)
+      return 1;
+  }
+
+  /* If this is the dispatch table of a tagged type, then ignore.  */
+  if (ada_is_tagged_type (type, 1)
+      && ada_is_dispatch_table_ptr_type (TYPE_FIELD_TYPE (type, field_num)))
+    return 1;
+
+  /* Not a special field, so it should not be ignored.  */
+  return 0;
 }
 
 /* True iff TYPE has a tag field.  If REFOK, then TYPE may also be a
This page took 0.030721 seconds and 4 git commands to generate.