aboutsummaryrefslogtreecommitdiff
path: root/gdb/block.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/block.h')
-rw-r--r--gdb/block.h44
1 files changed, 34 insertions, 10 deletions
diff --git a/gdb/block.h b/gdb/block.h
index 76fa203..8a3ea82 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -146,7 +146,11 @@ struct block : public allocate_on_obstack<block>
/* Return an iterator range for this block's multidict. */
iterator_range<mdict_iterator_wrapper> multidict_symbols () const
- { return iterator_range<mdict_iterator_wrapper> (m_multidict); }
+ {
+ mdict_iterator_wrapper begin (m_multidict);
+
+ return iterator_range<mdict_iterator_wrapper> (std::move (begin));
+ }
/* Set this block's multidict. */
void set_multidict (multidictionary *multidict)
@@ -610,9 +614,16 @@ private:
struct block_iterator m_iter;
};
-/* An iterator range for block_iterator_wrapper. */
+/* Return an iterator range for block_iterator_wrapper. */
+
+inline iterator_range<block_iterator_wrapper>
+block_iterator_range (const block *block,
+ const lookup_name_info *name = nullptr)
+{
+ block_iterator_wrapper begin (block, name);
-typedef iterator_range<block_iterator_wrapper> block_iterator_range;
+ return iterator_range<block_iterator_wrapper> (std::move (begin));
+}
/* Return true if symbol A is the best match possible for DOMAIN. */
@@ -630,14 +641,27 @@ extern struct symbol *block_lookup_symbol (const struct block *block,
const lookup_name_info &name,
const domain_search_flags domain);
-/* Search BLOCK for symbol NAME in DOMAIN but only in primary symbol table of
- BLOCK. BLOCK must be STATIC_BLOCK or GLOBAL_BLOCK. Function is useful if
- one iterates all global/static blocks of an objfile. */
+/* When searching for a symbol, the "best" symbol is preferred over
+ one that is merely acceptable. See 'best_symbol'. This class
+ keeps track of this distinction while searching. */
-extern struct symbol *block_lookup_symbol_primary
- (const struct block *block,
- const char *name,
- const domain_search_flags domain);
+struct best_symbol_tracker
+{
+ /* The symtab in which the currently best symbol appears. */
+ compunit_symtab *best_symtab = nullptr;
+
+ /* The currently best (really "better") symbol. */
+ block_symbol currently_best {};
+
+ /* Search BLOCK (which must have come from SYMTAB) for a symbol
+ matching NAME and DOMAIN. When a symbol is found, update
+ 'currently_best'. If a best symbol is found, return true.
+ Otherwise, return false. SYMTAB can be nullptr if the caller
+ does not care about this tracking. */
+ bool search (compunit_symtab *symtab,
+ const block *block, const lookup_name_info &name,
+ domain_search_flags domain);
+};
/* Find symbol NAME in BLOCK and in DOMAIN. This will return a
matching symbol whose type is not a "opaque", see TYPE_IS_OPAQUE.