+ if (iterator->which == FIRST_LOCAL_BLOCK)
+ return mdict_iter_match_next (name, &iterator->mdict_iter);
+
+ return block_iter_match_step (iterator, name, 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,
+ symbol_name_match_type match_type,
+ const domain_enum domain)
+{
+ struct block_iterator iter;
+ struct symbol *sym;
+
+ lookup_name_info lookup_name (name, match_type);
+
+ if (!BLOCK_FUNCTION (block))
+ {
+ struct symbol *other = NULL;
+
+ ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym)
+ {
+ if (SYMBOL_DOMAIN (sym) == domain)
+ return sym;
+ /* This is a bit of a hack, but symbol_matches_domain might ignore
+ STRUCT vs VAR domain symbols. So if a matching symbol is found,
+ make sure there is no "better" matching symbol, i.e., one with
+ exactly the same domain. PR 16253. */
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+ SYMBOL_DOMAIN (sym), domain))
+ other = sym;
+ }
+ return other;
+ }
+ 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.
+ It's hard to define types in the parameter list (at least in
+ C/C++) so we don't do the same PR 16253 hack here that is done
+ for the !BLOCK_FUNCTION case. */
+
+ struct symbol *sym_found = NULL;
+
+ ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym)
+ {
+ 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. */
+ }