From: Joel Brobecker Date: Tue, 1 Jan 2008 07:21:59 +0000 (+0000) Subject: Implement support for Ada interface types. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=73fb9985686f8ed65ac02a63256918ce755a46b4;p=binutils-gdb.git 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6dac3294524..41617bca52c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2008-01-01 Joel Brobecker + + 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 * top.c (print_gdb_version): Update copyright year. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index d61476225a3..949350615fb 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5277,6 +5277,24 @@ ada_add_block_symbols (struct obstack *obstackp, /* 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