+
+/* See block.h. */
+
+struct symbol *
+block_lookup_symbol_primary (const struct block *block, const char *name,
+ const domain_enum domain)
+{
+ struct symbol *sym, *other;
+ struct dict_iterator dict_iter;
+
+ /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
+ gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
+ || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
+
+ other = NULL;
+ for (sym = dict_iter_name_first (block->dict, name, &dict_iter);
+ sym != NULL;
+ sym = dict_iter_name_next (name, &dict_iter))
+ {
+ 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;
+}
+
+/* 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 = (struct symbol **) data;
+
+ if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+ return 1;
+ *best = sym;
+ return 0;
+}