diff options
author | Doug Evans <xdje42@gmail.com> | 2014-11-06 22:32:25 -0800 |
---|---|---|
committer | Doug Evans <xdje42@gmail.com> | 2014-11-06 22:32:25 -0800 |
commit | 16b2eaa164b48aa0529304eec38102f1c60578be (patch) | |
tree | 001b7127c5e558db04bf0f2a2ba5a868dd36dec9 /gdb/block.c | |
parent | 405724050266e30fcc8cbcee416cde41862e8e8f (diff) | |
download | binutils-16b2eaa164b48aa0529304eec38102f1c60578be.zip binutils-16b2eaa164b48aa0529304eec38102f1c60578be.tar.gz binutils-16b2eaa164b48aa0529304eec38102f1c60578be.tar.bz2 |
Move lookup_block_symbol to block.c, rename to block_lookup_symbol.
There is another function, lookup_symbol_aux_block, and
the names lookup_block_symbol and lookup_symbol_aux_block don't
convey any real difference between them.
The difference is that lookup_block_symbol lives in the lower level
block API, and lookup_symbol_aux_block lives in the higher level symtab API.
This patch makes this distinction clear.
gdb/ChangeLog:
* symtab.c (lookup_block_symbol): Moved to ...
* block.c (block_lookup_symbol): ... here and renamed.
All callers updated.
* block.h (block_lookup_symbol): Declare.
* symtab.h (lookup_block_symbol): Delete.
Diffstat (limited to 'gdb/block.c')
-rw-r--r-- | gdb/block.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/gdb/block.c b/gdb/block.c index 8d40c9d..3bb9de0 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -685,3 +685,61 @@ block_iter_match_next (const char *name, return block_iter_match_step (iterator, name, compare, 0); } + +/* See block.h. + + Note that if NAME is the demangled form of a C++ symbol, we will fail + to find a match during the binary search of the non-encoded names, but + for now we don't worry about the slight inefficiency of looking for + a match we'll never find, since it will go pretty quick. Once the + binary search terminates, we drop through and do a straight linear + search on the symbols. Each symbol which is marked as being a ObjC/C++ + symbol (language_cplus or language_objc set) has both the encoded and + non-encoded names tested for a match. */ + +struct symbol * +block_lookup_symbol (const struct block *block, const char *name, + const domain_enum domain) +{ + struct block_iterator iter; + struct symbol *sym; + + if (!BLOCK_FUNCTION (block)) + { + for (sym = block_iter_name_first (block, name, &iter); + sym != NULL; + sym = block_iter_name_next (name, &iter)) + { + if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), + SYMBOL_DOMAIN (sym), domain)) + return sym; + } + return NULL; + } + else + { + /* Note that parameter symbols do not always show up last in the + list; this loop makes sure to take anything else other than + parameter symbols first; it only uses parameter symbols as a + last resort. Note that this only takes up extra computation + time on a match. */ + + struct symbol *sym_found = NULL; + + for (sym = block_iter_name_first (block, name, &iter); + sym != NULL; + sym = block_iter_name_next (name, &iter)) + { + if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), + SYMBOL_DOMAIN (sym), domain)) + { + sym_found = sym; + if (!SYMBOL_IS_ARGUMENT (sym)) + { + break; + } + } + } + return (sym_found); /* Will be NULL if not found. */ + } +} |