aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2015-05-27 11:50:38 -0700
committerDoug Evans <dje@google.com>2015-05-27 11:50:38 -0700
commitb2e2f908b863c27abb00108a03ebe2598baec55c (patch)
tree2d80ad0c354497e91d57aafadaf2d438cb0eb352 /gdb/symtab.c
parentf62fce356bf1df27e01fc40a3a277fc924019ee7 (diff)
downloadgdb-b2e2f908b863c27abb00108a03ebe2598baec55c.zip
gdb-b2e2f908b863c27abb00108a03ebe2598baec55c.tar.gz
gdb-b2e2f908b863c27abb00108a03ebe2598baec55c.tar.bz2
PR symtab/18258
gdb/ChangeLog: * block.c (block_find_symbol): New function. (block_find_non_opaque_type): Ditto. (block_find_non_opaque_type_preferred): Ditto. * block.h (block_symbol_matcher_ftype): New typedef. (block_find_symbol): Declare. (block_find_non_opaque_type): Ditto. (block_find_non_opaque_type_preferred): Ditto. * dwarf2read.c (dw2_lookup_symbol): Call block_find_symbol. * psymtab.c (psym_lookup_symbol): Ditto. * symtab.c (basic_lookup_transparent_type_1): New function. (basic_lookup_transparent_type): Call it. gdb/testsuite/ChangeLog: * gdb.dwarf2/opaque-type-lookup-2.c: New file. * gdb.dwarf2/opaque-type-lookup.c: New file. * gdb.dwarf2/opaque-type-lookup.exp: New file.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c61
1 files changed, 37 insertions, 24 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 72df872..6693930 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2804,12 +2804,39 @@ basic_lookup_transparent_type_quick (struct objfile *objfile, int block_index,
bv = COMPUNIT_BLOCKVECTOR (cust);
block = BLOCKVECTOR_BLOCK (bv, block_index);
- sym = block_lookup_symbol (block, name, STRUCT_DOMAIN);
- if (!sym)
+ sym = block_find_symbol (block, name, STRUCT_DOMAIN,
+ block_find_non_opaque_type, NULL);
+ if (sym == NULL)
error_in_psymtab_expansion (block_index, name, cust);
+ gdb_assert (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)));
+ return SYMBOL_TYPE (sym);
+}
+
+/* Subroutine of basic_lookup_transparent_type to simplify it.
+ Look up the non-opaque definition of NAME in BLOCK_INDEX of OBJFILE.
+ BLOCK_INDEX is either GLOBAL_BLOCK or STATIC_BLOCK. */
- if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
- return SYMBOL_TYPE (sym);
+static struct type *
+basic_lookup_transparent_type_1 (struct objfile *objfile, int block_index,
+ const char *name)
+{
+ const struct compunit_symtab *cust;
+ const struct blockvector *bv;
+ const struct block *block;
+ const struct symbol *sym;
+
+ ALL_OBJFILE_COMPUNITS (objfile, cust)
+ {
+ bv = COMPUNIT_BLOCKVECTOR (cust);
+ block = BLOCKVECTOR_BLOCK (bv, block_index);
+ sym = block_find_symbol (block, name, STRUCT_DOMAIN,
+ block_find_non_opaque_type, NULL);
+ if (sym != NULL)
+ {
+ gdb_assert (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)));
+ return SYMBOL_TYPE (sym);
+ }
+ }
return NULL;
}
@@ -2837,16 +2864,9 @@ basic_lookup_transparent_type (const char *name)
ALL_OBJFILES (objfile)
{
- ALL_OBJFILE_COMPUNITS (objfile, cust)
- {
- bv = COMPUNIT_BLOCKVECTOR (cust);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = block_lookup_symbol (block, name, STRUCT_DOMAIN);
- if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
- {
- return SYMBOL_TYPE (sym);
- }
- }
+ t = basic_lookup_transparent_type_1 (objfile, GLOBAL_BLOCK, name);
+ if (t)
+ return t;
}
ALL_OBJFILES (objfile)
@@ -2865,16 +2885,9 @@ basic_lookup_transparent_type (const char *name)
ALL_OBJFILES (objfile)
{
- ALL_OBJFILE_COMPUNITS (objfile, cust)
- {
- bv = COMPUNIT_BLOCKVECTOR (cust);
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = block_lookup_symbol (block, name, STRUCT_DOMAIN);
- if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
- {
- return SYMBOL_TYPE (sym);
- }
- }
+ t = basic_lookup_transparent_type_1 (objfile, STATIC_BLOCK, name);
+ if (t)
+ return t;
}
ALL_OBJFILES (objfile)