diff options
author | Doug Evans <dje@google.com> | 2015-05-27 11:50:38 -0700 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2015-05-27 11:50:38 -0700 |
commit | b2e2f908b863c27abb00108a03ebe2598baec55c (patch) | |
tree | 2d80ad0c354497e91d57aafadaf2d438cb0eb352 /gdb/block.c | |
parent | f62fce356bf1df27e01fc40a3a277fc924019ee7 (diff) | |
download | binutils-gdb-b2e2f908b863c27abb00108a03ebe2598baec55c.tar.gz |
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/block.c')
-rw-r--r-- | gdb/block.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gdb/block.c b/gdb/block.c index 00a7012f3ec..79a8f195db8 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -797,3 +797,50 @@ block_lookup_symbol_primary (const struct block *block, const char *name, return NULL; } + +/* See block.h. */ + +struct symbol * +block_find_symbol (const struct block *block, const char *name, + const domain_enum domain, + block_symbol_matcher_ftype *matcher, void *data) +{ + struct block_iterator iter; + struct symbol *sym; + + /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */ + gdb_assert (BLOCK_SUPERBLOCK (block) == NULL + || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL); + + ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym) + { + /* MATCHER is deliberately called second here so that it never sees + a non-domain-matching symbol. */ + if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), + SYMBOL_DOMAIN (sym), domain) + && matcher (sym, data)) + return sym; + } + return NULL; +} + +/* See block.h. */ + +int +block_find_non_opaque_type (struct symbol *sym, void *data) +{ + return !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)); +} + +/* See block.h. */ + +int +block_find_non_opaque_type_preferred (struct symbol *sym, void *data) +{ + struct symbol **best = data; + + if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym))) + return 1; + *best = sym; + return 0; +} |