Use domain_search_flags in lookup_symbol et al

This changes lookup_symbol and associated APIs to accept
domain_search_flags rather than a domain_enum.

Note that this introduces some new constants to Python and Guile.  I
chose to break out the documentation patch for this, because the
internals here do not change until a later patch, and it seemed
simpler to patch the docs just once, rather than twice.
This commit is contained in:
Tom Tromey
2023-03-30 23:00:26 -06:00
parent 6c01521494
commit ccf41c2487
64 changed files with 342 additions and 312 deletions

View File

@@ -13675,19 +13675,15 @@ public:
struct block_symbol lookup_symbol_nonlocal struct block_symbol lookup_symbol_nonlocal
(const char *name, const struct block *block, (const char *name, const struct block *block,
const domain_enum domain) const override const domain_search_flags domain) const override
{ {
struct block_symbol sym; struct block_symbol sym;
domain_search_flags flags = to_search_flags (domain);
if (domain == VAR_DOMAIN)
flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN;
sym = ada_lookup_symbol (name, sym = ada_lookup_symbol (name,
(block == nullptr (block == nullptr
? nullptr ? nullptr
: block->static_block ()), : block->static_block ()),
flags); domain);
if (sym.symbol != NULL) if (sym.symbol != NULL)
return sym; return sym;
@@ -13703,7 +13699,7 @@ public:
languages, we search the primitive types this late and only after languages, we search the primitive types this late and only after
having searched the global symbols without success. */ having searched the global symbols without success. */
if (domain == VAR_DOMAIN) if ((domain & SEARCH_TYPE_DOMAIN) != 0)
{ {
struct gdbarch *gdbarch; struct gdbarch *gdbarch;

View File

@@ -520,16 +520,17 @@ ada_get_tcb_types_info (void)
C-like) lookups to get the first match. */ C-like) lookups to get the first match. */
struct symbol *atcb_sym = struct symbol *atcb_sym =
lookup_symbol_in_language (atcb_name, NULL, STRUCT_DOMAIN, lookup_symbol_in_language (atcb_name, NULL, SEARCH_STRUCT_DOMAIN,
language_c, NULL).symbol; language_c, NULL).symbol;
const struct symbol *common_atcb_sym = const struct symbol *common_atcb_sym =
lookup_symbol_in_language (common_atcb_name, NULL, STRUCT_DOMAIN, lookup_symbol_in_language (common_atcb_name, NULL, SEARCH_STRUCT_DOMAIN,
language_c, NULL).symbol; language_c, NULL).symbol;
const struct symbol *private_data_sym = const struct symbol *private_data_sym =
lookup_symbol_in_language (private_data_name, NULL, STRUCT_DOMAIN, lookup_symbol_in_language (private_data_name, NULL, SEARCH_STRUCT_DOMAIN,
language_c, NULL).symbol; language_c, NULL).symbol;
const struct symbol *entry_call_record_sym = const struct symbol *entry_call_record_sym =
lookup_symbol_in_language (entry_call_record_name, NULL, STRUCT_DOMAIN, lookup_symbol_in_language (entry_call_record_name, NULL,
SEARCH_STRUCT_DOMAIN,
language_c, NULL).symbol; language_c, NULL).symbol;
if (atcb_sym == NULL || atcb_sym->type () == NULL) if (atcb_sym == NULL || atcb_sym->type () == NULL)
@@ -537,7 +538,7 @@ ada_get_tcb_types_info (void)
/* In Ravenscar run-time libs, the ATCB does not have a dynamic /* In Ravenscar run-time libs, the ATCB does not have a dynamic
size, so the symbol name differs. */ size, so the symbol name differs. */
atcb_sym = lookup_symbol_in_language (atcb_name_fixed, NULL, atcb_sym = lookup_symbol_in_language (atcb_name_fixed, NULL,
STRUCT_DOMAIN, language_c, SEARCH_STRUCT_DOMAIN, language_c,
NULL).symbol; NULL).symbol;
if (atcb_sym == NULL || atcb_sym->type () == NULL) if (atcb_sym == NULL || atcb_sym->type () == NULL)
@@ -929,7 +930,8 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
data->known_tasks_addr = msym.value_address (); data->known_tasks_addr = msym.value_address ();
/* Try to get pointer type and array length from the symtab. */ /* Try to get pointer type and array length from the symtab. */
sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL, VAR_DOMAIN, sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL,
SEARCH_VAR_DOMAIN,
language_c, NULL).symbol; language_c, NULL).symbol;
if (sym != NULL) if (sym != NULL)
{ {
@@ -975,7 +977,8 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
data->known_tasks_addr = msym.value_address (); data->known_tasks_addr = msym.value_address ();
data->known_tasks_length = 1; data->known_tasks_length = 1;
sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL, VAR_DOMAIN, sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL,
SEARCH_VAR_DOMAIN,
language_c, NULL).symbol; language_c, NULL).symbol;
if (sym != NULL && sym->value_address () != 0) if (sym != NULL && sym->value_address () != 0)
{ {

View File

@@ -106,7 +106,7 @@ find_proc_desc (CORE_ADDR pc)
symbol reading. */ symbol reading. */
sym = NULL; sym = NULL;
else else
sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN, sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, SEARCH_LABEL_DOMAIN,
0).symbol; 0).symbol;
} }

View File

@@ -1453,7 +1453,8 @@ gen_static_field (struct agent_expr *ax, struct axs_value *value,
else else
{ {
const char *phys_name = type->field (fieldno).loc_physname (); const char *phys_name = type->field (fieldno).loc_physname ();
struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0).symbol; struct symbol *sym = lookup_symbol (phys_name, 0,
SEARCH_VAR_DOMAIN, 0).symbol;
if (sym) if (sym)
{ {
@@ -1544,7 +1545,7 @@ gen_maybe_namespace_elt (struct agent_expr *ax, struct axs_value *value,
sym = cp_lookup_symbol_namespace (namespace_name, name, sym = cp_lookup_symbol_namespace (namespace_name, name,
block_for_pc (ax->scope), block_for_pc (ax->scope),
VAR_DOMAIN); SEARCH_VAR_DOMAIN);
if (sym.symbol == NULL) if (sym.symbol == NULL)
return 0; return 0;

View File

@@ -630,26 +630,32 @@ block_iterator_next (struct block_iterator *iterator)
/* See block.h. */ /* See block.h. */
bool bool
best_symbol (struct symbol *a, const domain_enum domain) best_symbol (struct symbol *a, const domain_search_flags domain)
{ {
return (a->domain () == domain if (a->aclass () == LOC_UNRESOLVED)
&& a->aclass () != LOC_UNRESOLVED); return false;
if ((domain & SEARCH_VAR_DOMAIN) != 0)
return a->domain () == VAR_DOMAIN;
return a->matches (domain);
} }
/* See block.h. */ /* See block.h. */
struct symbol * struct symbol *
better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain) better_symbol (struct symbol *a, struct symbol *b,
const domain_search_flags domain)
{ {
if (a == NULL) if (a == NULL)
return b; return b;
if (b == NULL) if (b == NULL)
return a; return a;
if (a->domain () == domain && b->domain () != domain) if (a->matches (domain) && !b->matches (domain))
return a; return a;
if (b->domain () == domain && a->domain () != domain) if (b->matches (domain) && !a->matches (domain))
return b; return b;
if (a->aclass () != LOC_UNRESOLVED && b->aclass () == LOC_UNRESOLVED) if (a->aclass () != LOC_UNRESOLVED && b->aclass () == LOC_UNRESOLVED)
@@ -675,7 +681,7 @@ better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain)
struct symbol * struct symbol *
block_lookup_symbol (const struct block *block, const char *name, block_lookup_symbol (const struct block *block, const char *name,
symbol_name_match_type match_type, symbol_name_match_type match_type,
const domain_enum domain) const domain_search_flags domain)
{ {
lookup_name_info lookup_name (name, match_type); lookup_name_info lookup_name (name, match_type);
@@ -730,7 +736,7 @@ block_lookup_symbol (const struct block *block, const char *name,
struct symbol * struct symbol *
block_lookup_symbol_primary (const struct block *block, const char *name, block_lookup_symbol_primary (const struct block *block, const char *name,
const domain_enum domain) const domain_search_flags domain)
{ {
struct symbol *sym, *other; struct symbol *sym, *other;
struct mdict_iterator mdict_iter; struct mdict_iterator mdict_iter;
@@ -792,7 +798,7 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
struct symbol * struct symbol *
block_find_symbol (const struct block *block, const lookup_name_info &name, block_find_symbol (const struct block *block, const lookup_name_info &name,
const domain_enum domain, struct symbol **stub) const domain_search_flags domain, struct symbol **stub)
{ {
/* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */ /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
gdb_assert (block->superblock () == NULL gdb_assert (block->superblock () == NULL

View File

@@ -554,28 +554,29 @@ typedef iterator_range<block_iterator_wrapper> block_iterator_range;
/* Return true if symbol A is the best match possible for DOMAIN. */ /* Return true if symbol A is the best match possible for DOMAIN. */
extern bool best_symbol (struct symbol *a, const domain_enum domain); extern bool best_symbol (struct symbol *a, const domain_search_flags domain);
/* Return symbol B if it is a better match than symbol A for DOMAIN. /* Return symbol B if it is a better match than symbol A for DOMAIN.
Otherwise return A. */ Otherwise return A. */
extern struct symbol *better_symbol (struct symbol *a, struct symbol *b, extern struct symbol *better_symbol (struct symbol *a, struct symbol *b,
const domain_enum domain); const domain_search_flags domain);
/* Search BLOCK for symbol NAME in DOMAIN. */ /* Search BLOCK for symbol NAME in DOMAIN. */
extern struct symbol *block_lookup_symbol (const struct block *block, extern struct symbol *block_lookup_symbol (const struct block *block,
const char *name, const char *name,
symbol_name_match_type match_type, symbol_name_match_type match_type,
const domain_enum domain); const domain_search_flags domain);
/* Search BLOCK for symbol NAME in DOMAIN but only in primary symbol table of /* 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 BLOCK. BLOCK must be STATIC_BLOCK or GLOBAL_BLOCK. Function is useful if
one iterates all global/static blocks of an objfile. */ one iterates all global/static blocks of an objfile. */
extern struct symbol *block_lookup_symbol_primary (const struct block *block, extern struct symbol *block_lookup_symbol_primary
(const struct block *block,
const char *name, const char *name,
const domain_enum domain); const domain_search_flags domain);
/* Find symbol NAME in BLOCK and in DOMAIN. This will return a /* Find symbol NAME in BLOCK and in DOMAIN. This will return a
matching symbol whose type is not a "opaque", see TYPE_IS_OPAQUE. matching symbol whose type is not a "opaque", see TYPE_IS_OPAQUE.
@@ -584,7 +585,7 @@ extern struct symbol *block_lookup_symbol_primary (const struct block *block,
extern struct symbol *block_find_symbol (const struct block *block, extern struct symbol *block_find_symbol (const struct block *block,
const lookup_name_info &name, const lookup_name_info &name,
const domain_enum domain, const domain_search_flags domain,
struct symbol **stub); struct symbol **stub);
/* Given a vector of pairs, allocate and build an obstack allocated /* Given a vector of pairs, allocate and build an obstack allocated

View File

@@ -1087,9 +1087,10 @@ block : block COLONCOLON name
std::string copy = copy_name ($3); std::string copy = copy_name ($3);
struct symbol *tem struct symbol *tem
= lookup_symbol (copy.c_str (), $1, = lookup_symbol (copy.c_str (), $1,
VAR_DOMAIN, NULL).symbol; SEARCH_FUNCTION_DOMAIN,
nullptr).symbol;
if (!tem || tem->aclass () != LOC_BLOCK) if (tem == nullptr)
error (_("No function \"%s\" in specified context."), error (_("No function \"%s\" in specified context."),
copy.c_str ()); copy.c_str ());
$$ = tem->value_block (); } $$ = tem->value_block (); }
@@ -1113,7 +1114,7 @@ variable: block COLONCOLON name
std::string copy = copy_name ($3); std::string copy = copy_name ($3);
struct block_symbol sym struct block_symbol sym
= lookup_symbol (copy.c_str (), $1, = lookup_symbol (copy.c_str (), $1,
VAR_DOMAIN, NULL); SEARCH_VFT, NULL);
if (sym.symbol == 0) if (sym.symbol == 0)
error (_("No symbol \"%s\" in specified context."), error (_("No symbol \"%s\" in specified context."),
@@ -1168,7 +1169,7 @@ variable: qualified_name
struct block_symbol sym struct block_symbol sym
= lookup_symbol (name.c_str (), = lookup_symbol (name.c_str (),
(const struct block *) NULL, (const struct block *) NULL,
VAR_DOMAIN, NULL); SEARCH_VFT, NULL);
pstate->push_symbol (name.c_str (), sym); pstate->push_symbol (name.c_str (), sym);
} }
; ;
@@ -1833,7 +1834,7 @@ name_not_typename : NAME
$$.sym $$.sym
= lookup_symbol ($1.ptr, = lookup_symbol ($1.ptr,
pstate->expression_context_block, pstate->expression_context_block,
VAR_DOMAIN, SEARCH_VFT,
&is_a_field_of_this); &is_a_field_of_this);
$$.is_a_field_of_this $$.is_a_field_of_this
= is_a_field_of_this.type != NULL; = is_a_field_of_this.type != NULL;
@@ -2969,7 +2970,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
if (lookup_symbol (copy.c_str (), if (lookup_symbol (copy.c_str (),
pstate->expression_context_block, pstate->expression_context_block,
VAR_DOMAIN, SEARCH_VFT,
(par_state->language ()->la_language (par_state->language ()->la_language
== language_cplus ? &is_a_field_of_this == language_cplus ? &is_a_field_of_this
: NULL)).symbol : NULL)).symbol
@@ -3037,7 +3038,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
we can refer to it unconditionally below. */ we can refer to it unconditionally below. */
memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this)); memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
bsym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, bsym = lookup_symbol (copy.c_str (), block, SEARCH_VFT,
par_state->language ()->name_of_this () par_state->language ()->name_of_this ()
? &is_a_field_of_this : NULL); ? &is_a_field_of_this : NULL);
@@ -3060,7 +3061,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
{ {
struct field_of_this_result inner_is_a_field_of_this; struct field_of_this_result inner_is_a_field_of_this;
bsym = lookup_symbol (copy.c_str (), block, STRUCT_DOMAIN, bsym = lookup_symbol (copy.c_str (), block, SEARCH_STRUCT_DOMAIN,
&inner_is_a_field_of_this); &inner_is_a_field_of_this);
if (bsym.symbol != NULL) if (bsym.symbol != NULL)
{ {
@@ -3167,7 +3168,7 @@ classify_inner_name (struct parser_state *par_state,
std::string copy = copy_name (yylval.ssym.stoken); std::string copy = copy_name (yylval.ssym.stoken);
/* N.B. We assume the symbol can only be in VAR_DOMAIN. */ /* N.B. We assume the symbol can only be in VAR_DOMAIN. */
yylval.ssym.sym = cp_lookup_nested_symbol (type, copy.c_str (), block, yylval.ssym.sym = cp_lookup_nested_symbol (type, copy.c_str (), block,
VAR_DOMAIN); SEARCH_VFT);
/* If no symbol was found, search for a matching base class named /* If no symbol was found, search for a matching base class named
COPY. This will allow users to enter qualified names of class members COPY. This will allow users to enter qualified names of class members

View File

@@ -1014,7 +1014,7 @@ public:
struct block_symbol lookup_symbol_nonlocal struct block_symbol lookup_symbol_nonlocal
(const char *name, const struct block *block, (const char *name, const struct block *block,
const domain_enum domain) const override const domain_search_flags domain) const override
{ {
return cp_lookup_symbol_nonlocal (this, name, block, domain); return cp_lookup_symbol_nonlocal (this, name, block, domain);
} }

View File

@@ -205,7 +205,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
{ {
const char *search_name = msymbol.minsym->search_name (); const char *search_name = msymbol.minsym->search_name ();
wsym = lookup_symbol_search_name (search_name, NULL, wsym = lookup_symbol_search_name (search_name, NULL,
VAR_DOMAIN).symbol; SEARCH_VAR_DOMAIN).symbol;
} }
if (wsym) if (wsym)

View File

@@ -210,7 +210,7 @@ convert_one_symbol (compile_c_instance *context,
static void static void
convert_symbol_sym (compile_c_instance *context, const char *identifier, convert_symbol_sym (compile_c_instance *context, const char *identifier,
struct block_symbol sym, domain_enum domain) struct block_symbol sym, domain_search_flags domain)
{ {
int is_local_symbol; int is_local_symbol;
@@ -325,19 +325,19 @@ gcc_convert_symbol (void *datum,
{ {
compile_c_instance *context compile_c_instance *context
= static_cast<compile_c_instance *> (datum); = static_cast<compile_c_instance *> (datum);
domain_enum domain; domain_search_flags domain;
int found = 0; int found = 0;
switch (request) switch (request)
{ {
case GCC_C_ORACLE_SYMBOL: case GCC_C_ORACLE_SYMBOL:
domain = VAR_DOMAIN; domain = SEARCH_VFT;
break; break;
case GCC_C_ORACLE_TAG: case GCC_C_ORACLE_TAG:
domain = STRUCT_DOMAIN; domain = SEARCH_STRUCT_DOMAIN;
break; break;
case GCC_C_ORACLE_LABEL: case GCC_C_ORACLE_LABEL:
domain = LABEL_DOMAIN; domain = SEARCH_LABEL_DOMAIN;
break; break;
default: default:
gdb_assert_not_reached ("Unrecognized oracle request."); gdb_assert_not_reached ("Unrecognized oracle request.");
@@ -355,7 +355,7 @@ gcc_convert_symbol (void *datum,
convert_symbol_sym (context, identifier, sym, domain); convert_symbol_sym (context, identifier, sym, domain);
found = 1; found = 1;
} }
else if (domain == VAR_DOMAIN) else if (request == GCC_C_ORACLE_SYMBOL)
{ {
struct bound_minimal_symbol bmsym; struct bound_minimal_symbol bmsym;
@@ -398,8 +398,9 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
struct symbol *sym; struct symbol *sym;
/* We only need global functions here. */ /* We only need global functions here. */
sym = lookup_symbol (identifier, NULL, VAR_DOMAIN, NULL).symbol; sym = lookup_symbol (identifier, nullptr, SEARCH_FUNCTION_DOMAIN,
if (sym != NULL && sym->aclass () == LOC_BLOCK) nullptr).symbol;
if (sym != nullptr)
{ {
if (compile_debug) if (compile_debug)
gdb_printf (gdb_stdlog, gdb_printf (gdb_stdlog,

View File

@@ -227,7 +227,7 @@ convert_one_symbol (compile_cplus_instance *instance,
static void static void
convert_symbol_sym (compile_cplus_instance *instance, convert_symbol_sym (compile_cplus_instance *instance,
const char *identifier, struct block_symbol sym, const char *identifier, struct block_symbol sym,
domain_enum domain) domain_search_flags domain)
{ {
/* If we found a symbol and it is not in the static or global /* If we found a symbol and it is not in the static or global
scope, then we should first convert any static or global scope scope, then we should first convert any static or global scope
@@ -355,12 +355,12 @@ gcc_cplus_convert_symbol (void *datum,
This will find variables in the current scope. */ This will find variables in the current scope. */
struct block_symbol sym struct block_symbol sym
= lookup_symbol (identifier, instance->block (), VAR_DOMAIN, nullptr); = lookup_symbol (identifier, instance->block (), SEARCH_VFT, nullptr);
if (sym.symbol != nullptr) if (sym.symbol != nullptr)
{ {
found = true; found = true;
convert_symbol_sym (instance, identifier, sym, VAR_DOMAIN); convert_symbol_sym (instance, identifier, sym, SEARCH_VFT);
} }
/* Then use linespec.c's multi-symbol search. This should find /* Then use linespec.c's multi-symbol search. This should find
@@ -378,7 +378,7 @@ gcc_cplus_convert_symbol (void *datum,
{ {
found = true; found = true;
convert_symbol_sym (instance, identifier, it, convert_symbol_sym (instance, identifier, it,
it.symbol->domain ()); to_search_flags (it.symbol->domain ()));
} }
} }
@@ -437,9 +437,10 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context,
try try
{ {
struct symbol *sym struct symbol *sym
= lookup_symbol (identifier, nullptr, VAR_DOMAIN, nullptr).symbol; = lookup_symbol (identifier, nullptr, SEARCH_FUNCTION_DOMAIN,
nullptr).symbol;
if (sym != nullptr && sym->aclass () == LOC_BLOCK) if (sym != nullptr)
{ {
if (compile_debug) if (compile_debug)
gdb_printf (gdb_stdlog, gdb_printf (gdb_stdlog,

View File

@@ -154,7 +154,7 @@ type_name_to_scope (const char *type_name, const struct block *block)
/* Look up the resulting name. */ /* Look up the resulting name. */
struct block_symbol bsymbol struct block_symbol bsymbol
= lookup_symbol (lookup_name.c_str (), block, VAR_DOMAIN, nullptr); = lookup_symbol (lookup_name.c_str (), block, SEARCH_VFT, nullptr);
if (bsymbol.symbol != nullptr) if (bsymbol.symbol != nullptr)
{ {
@@ -384,7 +384,7 @@ compile_cplus_instance::new_scope (const char *type_name, struct type *type)
scope_component comp scope_component comp
= { = {
decl_name (type->name ()).get (), decl_name (type->name ()).get (),
lookup_symbol (type->name (), block (), VAR_DOMAIN, nullptr) lookup_symbol (type->name (), block (), SEARCH_VFT, nullptr)
}; };
scope.push_back (comp); scope.push_back (comp);
} }
@@ -617,7 +617,7 @@ compile_cplus_convert_struct_or_union_members
const char *physname = type->field (i).loc_physname (); const char *physname = type->field (i).loc_physname ();
struct block_symbol sym struct block_symbol sym
= lookup_symbol (physname, instance->block (), = lookup_symbol (physname, instance->block (),
VAR_DOMAIN, nullptr); SEARCH_VFT, nullptr);
if (sym.symbol == nullptr) if (sym.symbol == nullptr)
{ {
@@ -729,7 +729,7 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance,
gcc_type method_type; gcc_type method_type;
struct block_symbol sym struct block_symbol sym
= lookup_symbol (TYPE_FN_FIELD_PHYSNAME (methods, j), = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (methods, j),
instance->block (), VAR_DOMAIN, nullptr); instance->block (), SEARCH_VFT, nullptr);
if (sym.symbol == nullptr) if (sym.symbol == nullptr)
{ {

View File

@@ -437,7 +437,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
gdb_val_sym = block_lookup_symbol (block, gdb_val_sym = block_lookup_symbol (block,
COMPILE_I_EXPR_VAL, COMPILE_I_EXPR_VAL,
symbol_name_match_type::SEARCH_NAME, symbol_name_match_type::SEARCH_NAME,
VAR_DOMAIN); SEARCH_VFT);
if (gdb_val_sym == NULL) if (gdb_val_sym == NULL)
continue; continue;
@@ -463,7 +463,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
gdb_ptr_type_sym = block_lookup_symbol (block, COMPILE_I_EXPR_PTR_TYPE, gdb_ptr_type_sym = block_lookup_symbol (block, COMPILE_I_EXPR_PTR_TYPE,
symbol_name_match_type::SEARCH_NAME, symbol_name_match_type::SEARCH_NAME,
VAR_DOMAIN); SEARCH_VFT);
if (gdb_ptr_type_sym == NULL) if (gdb_ptr_type_sym == NULL)
error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE); error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE);
gdb_ptr_type = gdb_ptr_type_sym->type (); gdb_ptr_type = gdb_ptr_type_sym->type ();
@@ -652,7 +652,7 @@ compile_object_load (const compile_file_names &file_names,
func_sym = lookup_global_symbol_from_objfile (objfile, func_sym = lookup_global_symbol_from_objfile (objfile,
GLOBAL_BLOCK, GLOBAL_BLOCK,
GCC_FE_WRAPPER_FUNCTION, GCC_FE_WRAPPER_FUNCTION,
VAR_DOMAIN).symbol; SEARCH_VFT).symbol;
if (func_sym == NULL) if (func_sym == NULL)
error (_("Cannot find function \"%s\" in compiled module \"%s\"."), error (_("Cannot find function \"%s\" in compiled module \"%s\"."),
GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile)); GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile));

View File

@@ -42,7 +42,7 @@ static struct block_symbol
const char *nested_name, const char *nested_name,
const char *concatenated_name, const char *concatenated_name,
const struct block *block, const struct block *block,
const domain_enum domain, const domain_search_flags domain,
int basic_lookup, int is_in_anonymous); int basic_lookup, int is_in_anonymous);
static struct type *cp_lookup_transparent_type_loop (const char *name, static struct type *cp_lookup_transparent_type_loop (const char *name,
@@ -129,7 +129,7 @@ cp_is_in_anonymous (const char *symbol_name)
static struct block_symbol static struct block_symbol
cp_basic_lookup_symbol (const char *name, const struct block *block, cp_basic_lookup_symbol (const char *name, const struct block *block,
const domain_enum domain, int is_in_anonymous) const domain_search_flags domain, int is_in_anonymous)
{ {
struct block_symbol sym; struct block_symbol sym;
@@ -172,7 +172,7 @@ cp_basic_lookup_symbol (const char *name, const struct block *block,
static struct block_symbol static struct block_symbol
cp_lookup_bare_symbol (const struct language_defn *langdef, cp_lookup_bare_symbol (const struct language_defn *langdef,
const char *name, const struct block *block, const char *name, const struct block *block,
const domain_enum domain, int search) const domain_search_flags domain, int search)
{ {
struct block_symbol sym; struct block_symbol sym;
@@ -192,7 +192,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
shared libraries we could search all of them only to find out the shared libraries we could search all of them only to find out the
builtin type isn't defined in any of them. This is common for types builtin type isn't defined in any of them. This is common for types
like "void". */ like "void". */
if (langdef != NULL && domain == VAR_DOMAIN) if (langdef != nullptr && (domain & SEARCH_TYPE_DOMAIN) != 0)
{ {
struct gdbarch *gdbarch; struct gdbarch *gdbarch;
@@ -251,7 +251,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
static struct block_symbol static struct block_symbol
cp_search_static_and_baseclasses (const char *name, cp_search_static_and_baseclasses (const char *name,
const struct block *block, const struct block *block,
const domain_enum domain, const domain_search_flags domain,
unsigned int prefix_len, unsigned int prefix_len,
int is_in_anonymous) int is_in_anonymous)
{ {
@@ -273,9 +273,9 @@ cp_search_static_and_baseclasses (const char *name,
symbol_matches_domain (which should be replaced with something symbol_matches_domain (which should be replaced with something
else, but it's what we have today). */ else, but it's what we have today). */
block_symbol scope_sym = lookup_symbol_in_static_block (scope.c_str (), block_symbol scope_sym = lookup_symbol_in_static_block (scope.c_str (),
block, VAR_DOMAIN); block, SEARCH_VFT);
if (scope_sym.symbol == NULL) if (scope_sym.symbol == NULL)
scope_sym = lookup_global_symbol (scope.c_str (), block, VAR_DOMAIN); scope_sym = lookup_global_symbol (scope.c_str (), block, SEARCH_VFT);
if (scope_sym.symbol == NULL) if (scope_sym.symbol == NULL)
return {}; return {};
@@ -285,9 +285,9 @@ cp_search_static_and_baseclasses (const char *name,
static variable. E.g., "print 'function()::static_var'". */ static variable. E.g., "print 'function()::static_var'". */
if ((scope_type->code () == TYPE_CODE_FUNC if ((scope_type->code () == TYPE_CODE_FUNC
|| scope_type->code () == TYPE_CODE_METHOD) || scope_type->code () == TYPE_CODE_METHOD)
&& domain == VAR_DOMAIN) && (domain & SEARCH_VAR_DOMAIN) != 0)
return lookup_symbol (nested, scope_sym.symbol->value_block (), return lookup_symbol (nested, scope_sym.symbol->value_block (),
VAR_DOMAIN, NULL); domain, NULL);
/* Look for a symbol named NESTED in this class/namespace. /* Look for a symbol named NESTED in this class/namespace.
The caller is assumed to have already have done a basic lookup of NAME. The caller is assumed to have already have done a basic lookup of NAME.
@@ -308,7 +308,7 @@ cp_search_static_and_baseclasses (const char *name,
static struct block_symbol static struct block_symbol
cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name, cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain, int search) const domain_search_flags domain, int search)
{ {
char *concatenated_name = NULL; char *concatenated_name = NULL;
int is_in_anonymous; int is_in_anonymous;
@@ -382,7 +382,7 @@ static void
cp_lookup_symbol_via_imports (const char *scope, cp_lookup_symbol_via_imports (const char *scope,
const char *name, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain, const domain_search_flags domain,
const int search_scope_first, const int search_scope_first,
const int declaration_only, const int declaration_only,
const int search_parents, const int search_parents,
@@ -503,7 +503,7 @@ static struct block_symbol
cp_lookup_symbol_via_imports (const char *scope, cp_lookup_symbol_via_imports (const char *scope,
const char *name, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain, const domain_search_flags domain,
const int declaration_only, const int declaration_only,
const int search_parents) const int search_parents)
{ {
@@ -560,13 +560,14 @@ struct block_symbol
cp_lookup_symbol_imports_or_template (const char *scope, cp_lookup_symbol_imports_or_template (const char *scope,
const char *name, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
struct symbol *function = block->function (); struct symbol *function = block->function ();
symbol_lookup_debug_printf symbol_lookup_debug_printf
("cp_lookup_symbol_imports_or_template (%s, %s, %s, %s)", ("cp_lookup_symbol_imports_or_template (%s, %s, %s, %s)",
scope, name, host_address_to_string (block), domain_name (domain)); scope, name, host_address_to_string (block),
domain_name (domain).c_str ());
if (function != NULL && function->language () == language_cplus) if (function != NULL && function->language () == language_cplus)
{ {
@@ -646,7 +647,7 @@ cp_lookup_symbol_imports_or_template (const char *scope,
static struct block_symbol static struct block_symbol
cp_lookup_symbol_via_all_imports (const char *scope, const char *name, cp_lookup_symbol_via_all_imports (const char *scope, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
struct block_symbol sym; struct block_symbol sym;
@@ -671,13 +672,13 @@ struct block_symbol
cp_lookup_symbol_namespace (const char *scope, cp_lookup_symbol_namespace (const char *scope,
const char *name, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
struct block_symbol sym; struct block_symbol sym;
symbol_lookup_debug_printf ("cp_lookup_symbol_namespace (%s, %s, %s, %s)", symbol_lookup_debug_printf ("cp_lookup_symbol_namespace (%s, %s, %s, %s)",
scope, name, host_address_to_string (block), scope, name, host_address_to_string (block),
domain_name (domain)); domain_name (domain).c_str ());
/* First, try to find the symbol in the given namespace. */ /* First, try to find the symbol in the given namespace. */
sym = cp_lookup_symbol_in_namespace (scope, name, block, domain, 1); sym = cp_lookup_symbol_in_namespace (scope, name, block, domain, 1);
@@ -711,7 +712,7 @@ static struct block_symbol
lookup_namespace_scope (const struct language_defn *langdef, lookup_namespace_scope (const struct language_defn *langdef,
const char *name, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain, const domain_search_flags domain,
const char *scope, const char *scope,
int scope_len) int scope_len)
{ {
@@ -768,14 +769,15 @@ struct block_symbol
cp_lookup_symbol_nonlocal (const struct language_defn *langdef, cp_lookup_symbol_nonlocal (const struct language_defn *langdef,
const char *name, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
struct block_symbol sym; struct block_symbol sym;
const char *scope = block == nullptr ? "" : block->scope (); const char *scope = block == nullptr ? "" : block->scope ();
symbol_lookup_debug_printf symbol_lookup_debug_printf
("cp_lookup_symbol_non_local (%s, %s (scope %s), %s)", ("cp_lookup_symbol_non_local (%s, %s (scope %s), %s)",
name, host_address_to_string (block), scope, domain_name (domain)); name, host_address_to_string (block), scope,
domain_name (domain).c_str ());
/* First, try to find the symbol in the given namespace, and all /* First, try to find the symbol in the given namespace, and all
containing namespaces. */ containing namespaces. */
@@ -826,7 +828,8 @@ cp_find_type_baseclass_by_name (struct type *parent_type, const char *name)
static struct block_symbol static struct block_symbol
find_symbol_in_baseclass (struct type *parent_type, const char *name, find_symbol_in_baseclass (struct type *parent_type, const char *name,
const struct block *block, const domain_enum domain, const struct block *block,
const domain_search_flags domain,
int is_in_anonymous) int is_in_anonymous)
{ {
int i; int i;
@@ -869,7 +872,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type,
const char *nested_name, const char *nested_name,
const char *concatenated_name, const char *concatenated_name,
const struct block *block, const struct block *block,
const domain_enum domain, const domain_search_flags domain,
int basic_lookup, int is_in_anonymous) int basic_lookup, int is_in_anonymous)
{ {
struct block_symbol sym; struct block_symbol sym;
@@ -933,7 +936,7 @@ struct block_symbol
cp_lookup_nested_symbol (struct type *parent_type, cp_lookup_nested_symbol (struct type *parent_type,
const char *nested_name, const char *nested_name,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
/* type_name_or_error provides better error reporting using the /* type_name_or_error provides better error reporting using the
original type. */ original type. */
@@ -948,7 +951,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
symbol_lookup_debug_printf ("cp_lookup_nested_symbol (%s, %s, %s, %s)", symbol_lookup_debug_printf ("cp_lookup_nested_symbol (%s, %s, %s, %s)",
type_name != NULL ? type_name : "unnamed", type_name != NULL ? type_name : "unnamed",
nested_name, host_address_to_string (block), nested_name, host_address_to_string (block),
domain_name (domain)); domain_name (domain).c_str ());
} }
switch (parent_type->code ()) switch (parent_type->code ())

View File

@@ -151,7 +151,7 @@ inspect_type (struct demangle_parse_info *info,
try try
{ {
sym = lookup_symbol (name, 0, VAR_DOMAIN, 0).symbol; sym = lookup_symbol (name, 0, SEARCH_VFT, 0).symbol;
} }
catch (const gdb_exception &except) catch (const gdb_exception &except)
{ {
@@ -505,7 +505,7 @@ replace_typedefs (struct demangle_parse_info *info,
try try
{ {
sym = lookup_symbol (local_name.get (), 0, sym = lookup_symbol (local_name.get (), 0,
VAR_DOMAIN, 0).symbol; SEARCH_VFT, 0).symbol;
} }
catch (const gdb_exception &except) catch (const gdb_exception &except)
{ {
@@ -1500,7 +1500,7 @@ cp_lookup_rtti_type (const char *name, const struct block *block)
/* Use VAR_DOMAIN here as NAME may be a typedef. PR 18141, 18417. /* Use VAR_DOMAIN here as NAME may be a typedef. PR 18141, 18417.
Classes "live" in both STRUCT_DOMAIN and VAR_DOMAIN. */ Classes "live" in both STRUCT_DOMAIN and VAR_DOMAIN. */
rtti_sym = lookup_symbol (name, block, VAR_DOMAIN, NULL).symbol; rtti_sym = lookup_symbol (name, block, SEARCH_VFT, NULL).symbol;
if (rtti_sym == NULL) if (rtti_sym == NULL)
{ {

View File

@@ -141,25 +141,25 @@ extern struct block_symbol cp_lookup_symbol_nonlocal
(const struct language_defn *langdef, (const struct language_defn *langdef,
const char *name, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain); const domain_search_flags domain);
extern struct block_symbol extern struct block_symbol
cp_lookup_symbol_namespace (const char *the_namespace, cp_lookup_symbol_namespace (const char *the_namespace,
const char *name, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain); const domain_search_flags domain);
extern struct block_symbol cp_lookup_symbol_imports_or_template extern struct block_symbol cp_lookup_symbol_imports_or_template
(const char *scope, (const char *scope,
const char *name, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain); const domain_search_flags domain);
extern struct block_symbol extern struct block_symbol
cp_lookup_nested_symbol (struct type *parent_type, cp_lookup_nested_symbol (struct type *parent_type,
const char *nested_name, const char *nested_name,
const struct block *block, const struct block *block,
const domain_enum domain); const domain_search_flags domain);
struct type *cp_lookup_transparent_type (const char *name); struct type *cp_lookup_transparent_type (const char *name);

View File

@@ -444,7 +444,7 @@ PrimaryExpression:
/* Handle VAR, which could be local or global. */ /* Handle VAR, which could be local or global. */
sym = lookup_symbol (copy.c_str (), sym = lookup_symbol (copy.c_str (),
pstate->expression_context_block, pstate->expression_context_block,
VAR_DOMAIN, &is_a_field_of_this); SEARCH_VFT, &is_a_field_of_this);
if (sym.symbol && sym.symbol->aclass () != LOC_TYPEDEF) if (sym.symbol && sym.symbol->aclass () != LOC_TYPEDEF)
{ {
if (symbol_read_needs_frame (sym.symbol)) if (symbol_read_needs_frame (sym.symbol))
@@ -493,7 +493,7 @@ PrimaryExpression:
sym = sym =
lookup_symbol (name.c_str (), lookup_symbol (name.c_str (),
(const struct block *) NULL, (const struct block *) NULL,
VAR_DOMAIN, NULL); SEARCH_VFT, NULL);
pstate->push_symbol (name.c_str (), sym); pstate->push_symbol (name.c_str (), sym);
} }
else else
@@ -1337,7 +1337,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
std::string copy = copy_name (yylval.sval); std::string copy = copy_name (yylval.sval);
sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this); sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this);
if (sym.symbol && sym.symbol->aclass () == LOC_TYPEDEF) if (sym.symbol && sym.symbol->aclass () == LOC_TYPEDEF)
{ {
yylval.tsym.type = sym.symbol->type (); yylval.tsym.type = sym.symbol->type ();
@@ -1346,9 +1346,11 @@ classify_name (struct parser_state *par_state, const struct block *block)
else if (sym.symbol == NULL) else if (sym.symbol == NULL)
{ {
/* Look-up first for a module name, then a type. */ /* Look-up first for a module name, then a type. */
sym = lookup_symbol (copy.c_str (), block, MODULE_DOMAIN, NULL); sym = lookup_symbol (copy.c_str (), block, SEARCH_MODULE_DOMAIN,
nullptr);
if (sym.symbol == NULL) if (sym.symbol == NULL)
sym = lookup_symbol (copy.c_str (), block, STRUCT_DOMAIN, NULL); sym = lookup_symbol (copy.c_str (), block, SEARCH_STRUCT_DOMAIN,
nullptr);
if (sym.symbol != NULL) if (sym.symbol != NULL)
{ {

View File

@@ -171,7 +171,7 @@ public:
struct block_symbol lookup_symbol_nonlocal struct block_symbol lookup_symbol_nonlocal
(const char *name, const struct block *block, (const char *name, const struct block *block,
const domain_enum domain) const override const domain_search_flags domain) const override
{ {
return d_lookup_symbol_nonlocal (this, name, block, domain); return d_lookup_symbol_nonlocal (this, name, block, domain);
} }

View File

@@ -69,10 +69,11 @@ extern const struct builtin_d_type *builtin_d_type (struct gdbarch *);
/* Defined in d-namespace.c */ /* Defined in d-namespace.c */
extern struct block_symbol d_lookup_symbol_nonlocal (const struct language_defn *, extern struct block_symbol d_lookup_symbol_nonlocal
(const struct language_defn *,
const char *, const char *,
const struct block *, const struct block *,
const domain_enum); const domain_search_flags);
extern struct block_symbol d_lookup_nested_symbol (struct type *, const char *, extern struct block_symbol d_lookup_nested_symbol (struct type *, const char *,
const struct block *); const struct block *);

View File

@@ -78,7 +78,7 @@ d_entire_prefix_len (const char *name)
static struct block_symbol static struct block_symbol
d_lookup_symbol (const struct language_defn *langdef, d_lookup_symbol (const struct language_defn *langdef,
const char *name, const struct block *block, const char *name, const struct block *block,
const domain_enum domain, int search) const domain_search_flags domain, int search)
{ {
struct block_symbol sym; struct block_symbol sym;
@@ -88,7 +88,7 @@ d_lookup_symbol (const struct language_defn *langdef,
/* If we didn't find a definition for a builtin type in the static block, /* If we didn't find a definition for a builtin type in the static block,
such as "ucent" which is a specialist type, search for it now. */ such as "ucent" which is a specialist type, search for it now. */
if (langdef != NULL && domain == VAR_DOMAIN) if (langdef != nullptr && (domain & SEARCH_TYPE_DOMAIN) != 0)
{ {
struct gdbarch *gdbarch; struct gdbarch *gdbarch;
@@ -166,7 +166,7 @@ d_lookup_symbol (const struct language_defn *langdef,
static struct block_symbol static struct block_symbol
d_lookup_symbol_in_module (const char *module, const char *name, d_lookup_symbol_in_module (const char *module, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain, int search) const domain_search_flags domain, int search)
{ {
char *concatenated_name = NULL; char *concatenated_name = NULL;
@@ -198,7 +198,7 @@ d_lookup_symbol_in_module (const char *module, const char *name,
static struct block_symbol static struct block_symbol
lookup_module_scope (const struct language_defn *langdef, lookup_module_scope (const struct language_defn *langdef,
const char *name, const struct block *block, const char *name, const struct block *block,
const domain_enum domain, const char *scope, const domain_search_flags domain, const char *scope,
int scope_len) int scope_len)
{ {
char *module; char *module;
@@ -261,7 +261,7 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name,
/* Search this particular base class. */ /* Search this particular base class. */
sym = d_lookup_symbol_in_module (base_name, name, block, sym = d_lookup_symbol_in_module (base_name, name, block,
VAR_DOMAIN, 0); SEARCH_VFT, 0);
if (sym.symbol != NULL) if (sym.symbol != NULL)
break; break;
@@ -270,14 +270,14 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name,
what we want is possibly there. */ what we want is possibly there. */
std::string concatenated_name = std::string (base_name) + "." + name; std::string concatenated_name = std::string (base_name) + "." + name;
sym = lookup_symbol_in_static_block (concatenated_name.c_str (), block, sym = lookup_symbol_in_static_block (concatenated_name.c_str (), block,
VAR_DOMAIN); SEARCH_VFT);
if (sym.symbol != NULL) if (sym.symbol != NULL)
break; break;
/* Nope. We now have to search all static blocks in all objfiles, /* Nope. We now have to search all static blocks in all objfiles,
even if block != NULL, because there's no guarantees as to which even if block != NULL, because there's no guarantees as to which
symtab the symbol we want is in. */ symtab the symbol we want is in. */
sym = lookup_static_symbol (concatenated_name.c_str (), VAR_DOMAIN); sym = lookup_static_symbol (concatenated_name.c_str (), SEARCH_VFT);
if (sym.symbol != NULL) if (sym.symbol != NULL)
break; break;
@@ -320,7 +320,7 @@ d_lookup_nested_symbol (struct type *parent_type,
const char *parent_name = type_name_or_error (saved_parent_type); const char *parent_name = type_name_or_error (saved_parent_type);
struct block_symbol sym struct block_symbol sym
= d_lookup_symbol_in_module (parent_name, nested_name, = d_lookup_symbol_in_module (parent_name, nested_name,
block, VAR_DOMAIN, 0); block, SEARCH_VFT, 0);
char *concatenated_name; char *concatenated_name;
if (sym.symbol != NULL) if (sym.symbol != NULL)
@@ -337,7 +337,7 @@ d_lookup_nested_symbol (struct type *parent_type,
xsnprintf (concatenated_name, size, "%s.%s", xsnprintf (concatenated_name, size, "%s.%s",
parent_name, nested_name); parent_name, nested_name);
sym = lookup_static_symbol (concatenated_name, VAR_DOMAIN); sym = lookup_static_symbol (concatenated_name, SEARCH_VFT);
if (sym.symbol != NULL) if (sym.symbol != NULL)
return sym; return sym;
@@ -361,7 +361,7 @@ d_lookup_nested_symbol (struct type *parent_type,
static struct block_symbol static struct block_symbol
d_lookup_symbol_imports (const char *scope, const char *name, d_lookup_symbol_imports (const char *scope, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
struct using_direct *current; struct using_direct *current;
struct block_symbol sym; struct block_symbol sym;
@@ -473,7 +473,7 @@ d_lookup_symbol_imports (const char *scope, const char *name,
static struct block_symbol static struct block_symbol
d_lookup_symbol_module (const char *scope, const char *name, d_lookup_symbol_module (const char *scope, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
struct block_symbol sym; struct block_symbol sym;
@@ -509,7 +509,7 @@ struct block_symbol
d_lookup_symbol_nonlocal (const struct language_defn *langdef, d_lookup_symbol_nonlocal (const struct language_defn *langdef,
const char *name, const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
struct block_symbol sym; struct block_symbol sym;
const char *scope = block == nullptr ? "" : block->scope (); const char *scope = block == nullptr ? "" : block->scope ();

View File

@@ -103,7 +103,7 @@ ada_alias_get_block_value (const struct symbol *sym)
{ {
const char *name = get_imported_name (sym); const char *name = get_imported_name (sym);
block_symbol real_symbol = lookup_global_symbol (name, nullptr, block_symbol real_symbol = lookup_global_symbol (name, nullptr,
VAR_DOMAIN); SEARCH_VFT);
if (real_symbol.symbol == nullptr) if (real_symbol.symbol == nullptr)
error (_("could not find alias '%s' for function '%s'"), error (_("could not find alias '%s' for function '%s'"),
name, sym->print_name ()); name, sym->print_name ());

View File

@@ -624,7 +624,7 @@ func_get_frame_base_dwarf_block (struct symbol *framefunc, CORE_ADDR pc,
value * value *
compute_var_value (const char *name) compute_var_value (const char *name)
{ {
struct block_symbol sym = lookup_symbol (name, nullptr, VAR_DOMAIN, struct block_symbol sym = lookup_symbol (name, nullptr, SEARCH_VAR_DOMAIN,
nullptr); nullptr);
if (sym.symbol != nullptr) if (sym.symbol != nullptr)
return value_of_variable (sym.symbol, sym.block); return value_of_variable (sym.symbol, sym.block);

View File

@@ -730,7 +730,7 @@ scope_operation::evaluate_funcall (struct type *expect_type,
function = cp_lookup_symbol_namespace (type->name (), function = cp_lookup_symbol_namespace (type->name (),
name.c_str (), name.c_str (),
get_selected_block (0), get_selected_block (0),
VAR_DOMAIN).symbol; SEARCH_FUNCTION_DOMAIN).symbol;
if (function == NULL) if (function == NULL)
error (_("No symbol \"%s\" in namespace \"%s\"."), error (_("No symbol \"%s\" in namespace \"%s\"."),
name.c_str (), type->name ()); name.c_str (), type->name ());
@@ -1106,7 +1106,8 @@ eval_op_func_static_var (struct type *expect_type, struct expression *exp,
{ {
CORE_ADDR addr = func->address (); CORE_ADDR addr = func->address ();
const block *blk = block_for_pc (addr); const block *blk = block_for_pc (addr);
struct block_symbol sym = lookup_symbol (var, blk, VAR_DOMAIN, NULL); struct block_symbol sym = lookup_symbol (var, blk, SEARCH_VAR_DOMAIN,
nullptr);
if (sym.symbol == NULL) if (sym.symbol == NULL)
error (_("No symbol \"%s\" in specified context."), var); error (_("No symbol \"%s\" in specified context."), var);
return evaluate_var_value (noside, sym.block, sym.symbol); return evaluate_var_value (noside, sym.block, sym.symbol);

View File

@@ -1640,11 +1640,11 @@ yylex (void)
{ {
std::string tmp = copy_name (yylval.sval); std::string tmp = copy_name (yylval.sval);
struct block_symbol result; struct block_symbol result;
const domain_enum lookup_domains[] = const domain_search_flags lookup_domains[] =
{ {
STRUCT_DOMAIN, SEARCH_STRUCT_DOMAIN,
VAR_DOMAIN, SEARCH_VFT,
MODULE_DOMAIN SEARCH_MODULE_DOMAIN
}; };
int hextype; int hextype;

View File

@@ -1715,7 +1715,7 @@ f_language::search_name_hash (const char *name) const
struct block_symbol struct block_symbol
f_language::lookup_symbol_nonlocal (const char *name, f_language::lookup_symbol_nonlocal (const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const const domain_search_flags domain) const
{ {
return cp_lookup_symbol_nonlocal (this, name, block, domain); return cp_lookup_symbol_nonlocal (this, name, block, domain);
} }

View File

@@ -142,7 +142,7 @@ public:
struct block_symbol lookup_symbol_nonlocal struct block_symbol lookup_symbol_nonlocal
(const char *name, const struct block *block, (const char *name, const struct block *block,
const domain_enum domain) const override; const domain_search_flags domain) const override;
/* See language.h. */ /* See language.h. */

View File

@@ -552,7 +552,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
value field before printing its value. */ value field before printing its value. */
struct block_symbol sym struct block_symbol sym
= lookup_symbol (field_name, get_selected_block (nullptr), = lookup_symbol (field_name, get_selected_block (nullptr),
VAR_DOMAIN, nullptr); SEARCH_VFT, nullptr);
if (sym.symbol == nullptr) if (sym.symbol == nullptr)
error (_("failed to find symbol for name list component %s"), error (_("failed to find symbol for name list component %s"),
field_name); field_name);

View File

@@ -1960,8 +1960,9 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data)
{ {
/* Fetch offsets from debug symbols in rtld. */ /* Fetch offsets from debug symbols in rtld. */
struct symbol *obj_entry_sym struct symbol *obj_entry_sym
= lookup_symbol_in_language ("Struct_Obj_Entry", NULL, STRUCT_DOMAIN, = lookup_symbol_in_language ("Struct_Obj_Entry", nullptr,
language_c, NULL).symbol; SEARCH_STRUCT_DOMAIN,
language_c, nullptr).symbol;
if (obj_entry_sym == NULL) if (obj_entry_sym == NULL)
error (_("Unable to find Struct_Obj_Entry symbol")); error (_("Unable to find Struct_Obj_Entry symbol"));
data->off_linkmap = lookup_struct_elt (obj_entry_sym->type (), data->off_linkmap = lookup_struct_elt (obj_entry_sym->type (),

View File

@@ -2559,7 +2559,8 @@ inside_main_func (frame_info_ptr this_frame)
/* In some language (for example Fortran) there will be no minimal /* In some language (for example Fortran) there will be no minimal
symbol with the name of the main function. In this case we should symbol with the name of the main function. In this case we should
search the full symbols to see if we can find a match. */ search the full symbols to see if we can find a match. */
struct block_symbol bs = lookup_symbol (name, NULL, VAR_DOMAIN, 0); struct block_symbol bs = lookup_symbol (name, nullptr,
SEARCH_VFT, nullptr);
/* We might have found some unrelated symbol. For example, the /* We might have found some unrelated symbol. For example, the
Rust compiler can emit both a subprogram and a namespace with Rust compiler can emit both a subprogram and a namespace with

View File

@@ -297,7 +297,8 @@ ft32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
plg_end = ft32_analyze_prologue (func_addr, plg_end = ft32_analyze_prologue (func_addr,
func_end, &cache, gdbarch); func_end, &cache, gdbarch);
/* Found a function. */ /* Found a function. */
sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol; sym = lookup_symbol (func_name, nullptr, SEARCH_FUNCTION_DOMAIN,
nullptr).symbol;
/* Don't use line number debug info for assembly source files. */ /* Don't use line number debug info for assembly source files. */
if ((sym != NULL) && sym->language () != language_asm) if ((sym != NULL) && sym->language () != language_asm)
{ {

View File

@@ -1655,7 +1655,7 @@ lookup_typename (const struct language_defn *language,
{ {
struct symbol *sym; struct symbol *sym;
sym = lookup_symbol_in_language (name, block, VAR_DOMAIN, sym = lookup_symbol_in_language (name, block, SEARCH_VFT,
language->la_language, NULL).symbol; language->la_language, NULL).symbol;
if (sym != NULL && sym->aclass () == LOC_TYPEDEF) if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
{ {
@@ -1699,7 +1699,7 @@ lookup_struct (const char *name, const struct block *block)
{ {
struct symbol *sym; struct symbol *sym;
sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol;
if (sym == NULL) if (sym == NULL)
{ {
@@ -1722,7 +1722,7 @@ lookup_union (const char *name, const struct block *block)
struct symbol *sym; struct symbol *sym;
struct type *t; struct type *t;
sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol;
if (sym == NULL) if (sym == NULL)
error (_("No union type named %s."), name); error (_("No union type named %s."), name);
@@ -1745,7 +1745,7 @@ lookup_enum (const char *name, const struct block *block)
{ {
struct symbol *sym; struct symbol *sym;
sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol;
if (sym == NULL) if (sym == NULL)
{ {
error (_("No enum type named %s."), name); error (_("No enum type named %s."), name);
@@ -1772,7 +1772,8 @@ lookup_template_type (const char *name, struct type *type,
nam += type->name (); nam += type->name ();
nam += " >"; /* FIXME, extra space still introduced in gcc? */ nam += " >"; /* FIXME, extra space still introduced in gcc? */
symbol *sym = lookup_symbol (nam.c_str (), block, VAR_DOMAIN, 0).symbol; symbol *sym = lookup_symbol (nam.c_str (), block,
SEARCH_STRUCT_DOMAIN, 0).symbol;
if (sym == NULL) if (sym == NULL)
{ {
@@ -2994,7 +2995,8 @@ check_typedef (struct type *type)
stub_noname_complaint (); stub_noname_complaint ();
return make_qualified_type (type, instance_flags, NULL); return make_qualified_type (type, instance_flags, NULL);
} }
sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol; sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN,
nullptr).symbol;
if (sym) if (sym)
type->set_target_type (sym->type ()); type->set_target_type (sym->type ());
else /* TYPE_CODE_UNDEF */ else /* TYPE_CODE_UNDEF */
@@ -3084,7 +3086,8 @@ check_typedef (struct type *type)
stub_noname_complaint (); stub_noname_complaint ();
return make_qualified_type (type, instance_flags, NULL); return make_qualified_type (type, instance_flags, NULL);
} }
sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol; sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN,
nullptr).symbol;
if (sym) if (sym)
{ {
/* Same as above for opaque types, we can replace the stub /* Same as above for opaque types, we can replace the stub

View File

@@ -1079,7 +1079,7 @@ gnuv3_get_typeid_type (struct gdbarch *gdbarch)
struct symbol *typeinfo; struct symbol *typeinfo;
struct type *typeinfo_type; struct type *typeinfo_type;
typeinfo = lookup_symbol ("std::type_info", NULL, STRUCT_DOMAIN, typeinfo = lookup_symbol ("std::type_info", NULL, SEARCH_STRUCT_DOMAIN,
NULL).symbol; NULL).symbol;
if (typeinfo == NULL) if (typeinfo == NULL)
{ {

View File

@@ -1293,7 +1293,8 @@ package_name_p (const char *name, const struct block *block)
struct symbol *sym; struct symbol *sym;
struct field_of_this_result is_a_field_of_this; struct field_of_this_result is_a_field_of_this;
sym = lookup_symbol (name, block, STRUCT_DOMAIN, &is_a_field_of_this).symbol; sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN,
&is_a_field_of_this).symbol;
if (sym if (sym
&& sym->aclass () == LOC_TYPEDEF && sym->aclass () == LOC_TYPEDEF
@@ -1335,7 +1336,7 @@ classify_packaged_name (const struct block *block)
std::string copy = copy_name (yylval.sval); std::string copy = copy_name (yylval.sval);
sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this); sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this);
if (sym.symbol) if (sym.symbol)
{ {
@@ -1378,7 +1379,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
/* TODO: What about other types? */ /* TODO: What about other types? */
sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this); sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this);
if (sym.symbol) if (sym.symbol)
{ {
@@ -1403,7 +1404,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
strlen (current_package_name.get ()), strlen (current_package_name.get ()),
copy.c_str (), copy.size ()); copy.c_str (), copy.size ());
sym = lookup_symbol (sval.ptr, block, VAR_DOMAIN, sym = lookup_symbol (sval.ptr, block, SEARCH_VFT,
&is_a_field_of_this); &is_a_field_of_this);
if (sym.symbol) if (sym.symbol)
{ {

View File

@@ -937,7 +937,7 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest)
if (block == NULL) if (block == NULL)
block = get_frame_block (frame_info_ptr (frame), NULL); block = get_frame_block (frame_info_ptr (frame), NULL);
lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, lookup_sym = lookup_symbol (var_name.get (), block, SEARCH_VFT,
NULL); NULL);
var = lookup_sym.symbol; var = lookup_sym.symbol;
block = lookup_sym.block; block = lookup_sym.block;

View File

@@ -617,7 +617,8 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest)
gdbscm_gdb_exception except {}; gdbscm_gdb_exception except {};
try try
{ {
symbol = lookup_symbol (name, block, (domain_enum) domain, domain_search_flags flags = from_scripting_domain (domain);
symbol = lookup_symbol (name, block, flags,
&is_a_field_of_this).symbol; &is_a_field_of_this).symbol;
} }
catch (const gdb_exception &ex) catch (const gdb_exception &ex)
@@ -654,7 +655,8 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest)
try try
{ {
symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; domain_search_flags flags = from_scripting_domain (domain);
symbol = lookup_global_symbol (name, NULL, flags).symbol;
} }
catch (const gdb_exception &ex) catch (const gdb_exception &ex)
{ {
@@ -696,14 +698,15 @@ static const scheme_integer_constant symbol_integer_constants[] =
#undef X #undef X
#define DOMAIN(X) \ #define DOMAIN(X) \
{ "SYMBOL_" #X "_DOMAIN", X ## _DOMAIN }, { "SYMBOL_" #X "_DOMAIN", to_scripting_domain (X ## _DOMAIN) }, \
{ "SEARCH_" #X "_DOMAIN", to_scripting_domain (SEARCH_ ## X ## _DOMAIN) },
#include "sym-domains.def" #include "sym-domains.def"
#undef DOMAIN #undef DOMAIN
/* These were never correct. */ /* Historical. */
{ "SYMBOL_VARIABLES_DOMAIN", VAR_DOMAIN }, { "SYMBOL_VARIABLES_DOMAIN", to_scripting_domain (SEARCH_VAR_DOMAIN) },
{ "SYMBOL_FUNCTIONS_DOMAIN", VAR_DOMAIN }, { "SYMBOL_FUNCTIONS_DOMAIN", to_scripting_domain (SEARCH_FUNCTION_DOMAIN) },
{ "SYMBOL_TYPES_DOMAIN", VAR_DOMAIN }, { "SYMBOL_TYPES_DOMAIN", to_scripting_domain (SEARCH_TYPE_DOMAIN) },
END_INTEGER_CONSTANTS END_INTEGER_CONSTANTS
}; };

View File

@@ -8831,7 +8831,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
struct breakpoint *bp; struct breakpoint *bp;
vsym = lookup_symbol_search_name (sym->search_name (), vsym = lookup_symbol_search_name (sym->search_name (),
b, VAR_DOMAIN); b, SEARCH_VAR_DOMAIN);
value = read_var_value (vsym.symbol, vsym.block, frame); value = read_var_value (vsym.symbol, vsym.block, frame);
/* If the value was optimized out, revert to the old behavior. */ /* If the value was optimized out, revert to the old behavior. */
if (! value->optimized_out ()) if (! value->optimized_out ())

View File

@@ -944,7 +944,8 @@ language_arch_info::bool_type () const
{ {
struct symbol *sym; struct symbol *sym;
sym = lookup_symbol (m_bool_type_name, NULL, VAR_DOMAIN, NULL).symbol; sym = lookup_symbol (m_bool_type_name, nullptr, SEARCH_TYPE_DOMAIN,
nullptr).symbol;
if (sym != nullptr) if (sym != nullptr)
{ {
struct type *type = sym->type (); struct type *type = sym->type ();

View File

@@ -513,7 +513,7 @@ struct language_defn
virtual struct block_symbol lookup_symbol_nonlocal virtual struct block_symbol lookup_symbol_nonlocal
(const char *name, (const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const; const domain_search_flags domain) const;
/* Return an expression that can be used for a location /* Return an expression that can be used for a location
watchpoint. TYPE is a pointer type that points to the memory watchpoint. TYPE is a pointer type that points to the memory

View File

@@ -3923,7 +3923,7 @@ find_label_symbols_in_block (const struct block *block,
for (struct symbol *sym : block_iterator_range (block)) for (struct symbol *sym : block_iterator_range (block))
{ {
if (sym->matches (LABEL_DOMAIN) if (sym->domain () == LABEL_DOMAIN
&& cmp (sym->search_name (), name, name_len) == 0) && cmp (sym->search_name (), name, name_len) == 0)
{ {
result->push_back ({sym, block}); result->push_back ({sym, block});
@@ -3934,7 +3934,7 @@ find_label_symbols_in_block (const struct block *block,
else else
{ {
struct block_symbol label_sym struct block_symbol label_sym
= lookup_symbol (name, block, LABEL_DOMAIN, 0); = lookup_symbol (name, block, SEARCH_LABEL_DOMAIN, 0);
if (label_sym.symbol != NULL) if (label_sym.symbol != NULL)
{ {

View File

@@ -494,7 +494,7 @@ fblock : BLOCKNAME
{ struct symbol *sym { struct symbol *sym
= lookup_symbol (copy_name ($1).c_str (), = lookup_symbol (copy_name ($1).c_str (),
pstate->expression_context_block, pstate->expression_context_block,
VAR_DOMAIN, 0).symbol; SEARCH_VFT, 0).symbol;
$$ = sym;} $$ = sym;}
; ;
@@ -503,7 +503,7 @@ fblock : BLOCKNAME
fblock : block COLONCOLON BLOCKNAME fblock : block COLONCOLON BLOCKNAME
{ struct symbol *tem { struct symbol *tem
= lookup_symbol (copy_name ($3).c_str (), $1, = lookup_symbol (copy_name ($3).c_str (), $1,
VAR_DOMAIN, 0).symbol; SEARCH_VFT, 0).symbol;
if (!tem || tem->aclass () != LOC_BLOCK) if (!tem || tem->aclass () != LOC_BLOCK)
error (_("No function \"%s\" in specified context."), error (_("No function \"%s\" in specified context."),
copy_name ($3).c_str ()); copy_name ($3).c_str ());
@@ -528,7 +528,7 @@ variable: DOLLAR_VARIABLE
variable: block COLONCOLON NAME variable: block COLONCOLON NAME
{ struct block_symbol sym { struct block_symbol sym
= lookup_symbol (copy_name ($3).c_str (), $1, = lookup_symbol (copy_name ($3).c_str (), $1,
VAR_DOMAIN, 0); SEARCH_VFT, 0);
if (sym.symbol == 0) if (sym.symbol == 0)
error (_("No symbol \"%s\" in specified context."), error (_("No symbol \"%s\" in specified context."),
@@ -549,7 +549,7 @@ variable: NAME
sym sym
= lookup_symbol (name.c_str (), = lookup_symbol (name.c_str (),
pstate->expression_context_block, pstate->expression_context_block,
VAR_DOMAIN, SEARCH_VFT,
&is_a_field_of_this); &is_a_field_of_this);
pstate->push_symbol (name.c_str (), sym); pstate->push_symbol (name.c_str (), sym);
@@ -927,7 +927,7 @@ yylex (void)
if (lookup_symtab (tmp.c_str ())) if (lookup_symtab (tmp.c_str ()))
return BLOCKNAME; return BLOCKNAME;
sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
VAR_DOMAIN, 0).symbol; SEARCH_VFT, 0).symbol;
if (sym && sym->aclass () == LOC_BLOCK) if (sym && sym->aclass () == LOC_BLOCK)
return BLOCKNAME; return BLOCKNAME;
if (lookup_typename (pstate->language (), if (lookup_typename (pstate->language (),

View File

@@ -636,8 +636,9 @@ list_args_or_locals (const frame_print_options &fp_opts,
struct frame_arg arg, entryarg; struct frame_arg arg, entryarg;
if (sym->is_argument ()) if (sym->is_argument ())
sym2 = lookup_symbol_search_name (sym->search_name (), sym2 = (lookup_symbol_search_name
block, VAR_DOMAIN).symbol; (sym->search_name (),
block, SEARCH_VAR_DOMAIN).symbol);
else else
sym2 = sym; sym2 = sym;
gdb_assert (sym2 != NULL); gdb_assert (sym2 != NULL);

View File

@@ -226,7 +226,8 @@ moxie_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
plg_end = moxie_analyze_prologue (func_addr, plg_end = moxie_analyze_prologue (func_addr,
func_end, &cache, gdbarch); func_end, &cache, gdbarch);
/* Found a function. */ /* Found a function. */
sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol; sym = lookup_symbol (func_name, nullptr,
SEARCH_FUNCTION_DOMAIN, nullptr).symbol;
/* Don't use line number debug info for assembly source /* Don't use line number debug info for assembly source
files. */ files. */
if (sym && sym->language () != language_asm) if (sym && sym->language () != language_asm)

View File

@@ -87,7 +87,7 @@ lookup_struct_typedef (const char *name, const struct block *block, int noerr)
{ {
struct symbol *sym; struct symbol *sym;
sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol;
if (sym == NULL) if (sym == NULL)
{ {
@@ -1129,7 +1129,7 @@ find_imps (const char *method, std::vector<const char *> *symbol_names)
add the selector itself as a symbol, if it exists. */ add the selector itself as a symbol, if it exists. */
if (selector_case && !symbol_names->empty ()) if (selector_case && !symbol_names->empty ())
{ {
struct symbol *sym = lookup_symbol (selector, NULL, VAR_DOMAIN, struct symbol *sym = lookup_symbol (selector, NULL, SEARCH_VFT,
0).symbol; 0).symbol;
if (sym != NULL) if (sym != NULL)

View File

@@ -562,7 +562,7 @@ public:
contains !TYPE_OPAQUE symbol prefer its compunit. If it contains contains !TYPE_OPAQUE symbol prefer its compunit. If it contains
only TYPE_OPAQUE symbol(s), return at least that compunit. */ only TYPE_OPAQUE symbol(s), return at least that compunit. */
struct compunit_symtab *lookup_symbol (block_enum kind, const char *name, struct compunit_symtab *lookup_symbol (block_enum kind, const char *name,
domain_enum domain); domain_search_flags domain);
/* See quick_symbol_functions. */ /* See quick_symbol_functions. */
void print_stats (bool print_bcache); void print_stats (bool print_bcache);

View File

@@ -629,9 +629,10 @@ block : block COLONCOLON name
std::string copy = copy_name ($3); std::string copy = copy_name ($3);
struct symbol *tem struct symbol *tem
= lookup_symbol (copy.c_str (), $1, = lookup_symbol (copy.c_str (), $1,
VAR_DOMAIN, NULL).symbol; SEARCH_FUNCTION_DOMAIN,
nullptr).symbol;
if (!tem || tem->aclass () != LOC_BLOCK) if (tem == nullptr)
error (_("No function \"%s\" in specified context."), error (_("No function \"%s\" in specified context."),
copy.c_str ()); copy.c_str ());
$$ = tem->value_block (); } $$ = tem->value_block (); }
@@ -642,7 +643,7 @@ variable: block COLONCOLON name
std::string copy = copy_name ($3); std::string copy = copy_name ($3);
sym = lookup_symbol (copy.c_str (), $1, sym = lookup_symbol (copy.c_str (), $1,
VAR_DOMAIN, NULL); SEARCH_VFT, NULL);
if (sym.symbol == 0) if (sym.symbol == 0)
error (_("No symbol \"%s\" in specified context."), error (_("No symbol \"%s\" in specified context."),
copy.c_str ()); copy.c_str ());
@@ -672,7 +673,7 @@ variable: qualified_name
struct block_symbol sym struct block_symbol sym
= lookup_symbol (name.c_str (), nullptr, = lookup_symbol (name.c_str (), nullptr,
VAR_DOMAIN, nullptr); SEARCH_VFT, nullptr);
pstate->push_symbol (name.c_str (), sym); pstate->push_symbol (name.c_str (), sym);
} }
; ;
@@ -1400,7 +1401,7 @@ yylex (void)
static const char this_name[] = "this"; static const char this_name[] = "this";
if (lookup_symbol (this_name, pstate->expression_context_block, if (lookup_symbol (this_name, pstate->expression_context_block,
VAR_DOMAIN, NULL).symbol) SEARCH_VFT, NULL).symbol)
{ {
free (uptokstart); free (uptokstart);
return THIS; return THIS;
@@ -1440,7 +1441,7 @@ yylex (void)
sym = NULL; sym = NULL;
else else
sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
VAR_DOMAIN, &is_a_field_of_this).symbol; SEARCH_VFT, &is_a_field_of_this).symbol;
/* second chance uppercased (as Free Pascal does). */ /* second chance uppercased (as Free Pascal does). */
if (!sym && is_a_field_of_this.type == NULL && !is_a_field) if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
{ {
@@ -1456,7 +1457,7 @@ yylex (void)
sym = NULL; sym = NULL;
else else
sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
VAR_DOMAIN, &is_a_field_of_this).symbol; SEARCH_VFT, &is_a_field_of_this).symbol;
} }
/* Third chance Capitalized (as GPC does). */ /* Third chance Capitalized (as GPC does). */
if (!sym && is_a_field_of_this.type == NULL && !is_a_field) if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
@@ -1479,7 +1480,7 @@ yylex (void)
sym = NULL; sym = NULL;
else else
sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
VAR_DOMAIN, &is_a_field_of_this).symbol; SEARCH_VFT, &is_a_field_of_this).symbol;
} }
if (is_a_field || (is_a_field_of_this.type != NULL)) if (is_a_field || (is_a_field_of_this.type != NULL))
@@ -1576,7 +1577,7 @@ yylex (void)
cur_sym cur_sym
= lookup_symbol (ncopy, = lookup_symbol (ncopy,
pstate->expression_context_block, pstate->expression_context_block,
VAR_DOMAIN, NULL).symbol; SEARCH_VFT, NULL).symbol;
if (cur_sym) if (cur_sym)
{ {
if (cur_sym->aclass () == LOC_TYPEDEF) if (cur_sym->aclass () == LOC_TYPEDEF)

View File

@@ -253,7 +253,7 @@ pascal_language::value_print_inner (struct value *val,
{ {
const char *search_name = msymbol.minsym->search_name (); const char *search_name = msymbol.minsym->search_name ();
wsym = lookup_symbol_search_name (search_name, NULL, wsym = lookup_symbol_search_name (search_name, NULL,
VAR_DOMAIN).symbol; SEARCH_VFT).symbol;
} }
if (wsym) if (wsym)

View File

@@ -225,7 +225,8 @@ parser_state::push_dollar (struct stoken str)
/* On some systems, such as HP-UX and hppa-linux, certain system routines /* On some systems, such as HP-UX and hppa-linux, certain system routines
have names beginning with $ or $$. Check for those, first. */ have names beginning with $ or $$. Check for those, first. */
sym = lookup_symbol (copy.c_str (), NULL, VAR_DOMAIN, NULL); sym = lookup_symbol (copy.c_str (), nullptr,
SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN, nullptr);
if (sym.symbol) if (sym.symbol)
{ {
push_new<expr::var_value_operation> (sym); push_new<expr::var_value_operation> (sym);

View File

@@ -1582,7 +1582,7 @@ info_address_command (const char *exp, int from_tty)
if (exp == 0) if (exp == 0)
error (_("Argument required.")); error (_("Argument required."));
sym = lookup_symbol (exp, get_selected_block (&context_pc), VAR_DOMAIN, sym = lookup_symbol (exp, get_selected_block (&context_pc), SEARCH_VFT,
&is_a_field_of_this).symbol; &is_a_field_of_this).symbol;
if (sym == NULL) if (sym == NULL)
{ {

View File

@@ -1507,7 +1507,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
sym = block_lookup_symbol (b, psym->ginfo.search_name (), sym = block_lookup_symbol (b, psym->ginfo.search_name (),
symbol_name_match_type::SEARCH_NAME, symbol_name_match_type::SEARCH_NAME,
psym->domain); to_search_flags (psym->domain));
if (!sym) if (!sym)
{ {
gdb_printf ("Static symbol `"); gdb_printf ("Static symbol `");
@@ -1522,7 +1522,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
{ {
sym = block_lookup_symbol (b, psym->ginfo.search_name (), sym = block_lookup_symbol (b, psym->ginfo.search_name (),
symbol_name_match_type::SEARCH_NAME, symbol_name_match_type::SEARCH_NAME,
psym->domain); to_search_flags (psym->domain));
if (!sym) if (!sym)
{ {
gdb_printf ("Global symbol `"); gdb_printf ("Global symbol `");

View File

@@ -532,7 +532,8 @@ frapy_read_var (PyObject *self, PyObject *args, PyObject *kw)
if (!block) if (!block)
block = get_frame_block (frame, NULL); block = get_frame_block (frame, NULL);
lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, NULL); lookup_sym = lookup_symbol (var_name.get (), block,
SEARCH_VFT, nullptr);
var = lookup_sym.symbol; var = lookup_sym.symbol;
block = lookup_sym.block; block = lookup_sym.block;
} }

View File

@@ -479,8 +479,9 @@ objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
try try
{ {
domain_search_flags flags = from_scripting_domain (domain);
struct symbol *sym = lookup_global_symbol_from_objfile struct symbol *sym = lookup_global_symbol_from_objfile
(obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol; (obj->objfile, GLOBAL_BLOCK, symbol_name, flags).symbol;
if (sym == nullptr) if (sym == nullptr)
Py_RETURN_NONE; Py_RETURN_NONE;
@@ -513,8 +514,9 @@ objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
try try
{ {
domain_search_flags flags = from_scripting_domain (domain);
struct symbol *sym = lookup_global_symbol_from_objfile struct symbol *sym = lookup_global_symbol_from_objfile
(obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain).symbol; (obj->objfile, STATIC_BLOCK, symbol_name, flags).symbol;
if (sym == nullptr) if (sym == nullptr)
Py_RETURN_NONE; Py_RETURN_NONE;

View File

@@ -432,8 +432,8 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
try try
{ {
symbol = lookup_symbol (name, block, (domain_enum) domain, domain_search_flags flags = from_scripting_domain (domain);
&is_a_field_of_this).symbol; symbol = lookup_symbol (name, block, flags, &is_a_field_of_this).symbol;
} }
catch (const gdb_exception &except) catch (const gdb_exception &except)
{ {
@@ -481,7 +481,8 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
try try
{ {
symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; domain_search_flags flags = from_scripting_domain (domain);
symbol = lookup_global_symbol (name, NULL, flags).symbol;
} }
catch (const gdb_exception &except) catch (const gdb_exception &except)
{ {
@@ -542,13 +543,14 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
try try
{ {
domain_search_flags flags = from_scripting_domain (domain);
if (block != nullptr) if (block != nullptr)
symbol symbol
= lookup_symbol_in_static_block (name, block, = lookup_symbol_in_static_block (name, block, flags).symbol;
(domain_enum) domain).symbol;
if (symbol == nullptr) if (symbol == nullptr)
symbol = lookup_static_symbol (name, (domain_enum) domain).symbol; symbol = lookup_static_symbol (name, flags).symbol;
} }
catch (const gdb_exception &except) catch (const gdb_exception &except)
{ {
@@ -592,6 +594,8 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
try try
{ {
domain_search_flags flags = from_scripting_domain (domain);
/* Expand any symtabs that contain potentially matching symbols. */ /* Expand any symtabs that contain potentially matching symbols. */
lookup_name_info lookup_name (name, symbol_name_match_type::FULL); lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
expand_symtabs_matching (NULL, lookup_name, NULL, NULL, expand_symtabs_matching (NULL, lookup_name, NULL, NULL,
@@ -613,7 +617,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
if (block != nullptr) if (block != nullptr)
{ {
symbol *symbol = lookup_symbol_in_static_block symbol *symbol = lookup_symbol_in_static_block
(name, block, (domain_enum) domain).symbol; (name, block, flags).symbol;
if (symbol != nullptr) if (symbol != nullptr)
{ {
@@ -675,7 +679,9 @@ gdbpy_initialize_symbols (void)
#define DOMAIN(X) \ #define DOMAIN(X) \
if (PyModule_AddIntConstant (gdb_module, "SYMBOL_" #X "_DOMAIN", \ if (PyModule_AddIntConstant (gdb_module, "SYMBOL_" #X "_DOMAIN", \
X ## _DOMAIN) < 0) \ to_scripting_domain (X ## _DOMAIN)) < 0 \
|| PyModule_AddIntConstant (gdb_module, "SEARCH_" #X "_DOMAIN", \
to_scripting_domain (SEARCH_ ## X ## _DOMAIN)) < 0) \
return -1; return -1;
#include "sym-domains.def" #include "sym-domains.def"
#undef DOMAIN #undef DOMAIN

View File

@@ -1563,7 +1563,8 @@ rust_structop::evaluate_funcall (struct type *expect_type,
const struct block *block = get_selected_block (0); const struct block *block = get_selected_block (0);
struct block_symbol sym = lookup_symbol (name.c_str (), block, struct block_symbol sym = lookup_symbol (name.c_str (), block,
VAR_DOMAIN, NULL); SEARCH_VFT,
nullptr);
if (sym.symbol == NULL) if (sym.symbol == NULL)
error (_("Could not find function named '%s'"), name.c_str ()); error (_("Could not find function named '%s'"), name.c_str ());
@@ -1699,7 +1700,7 @@ rust_language::is_string_type_p (struct type *type) const
struct block_symbol struct block_symbol
rust_language::lookup_symbol_nonlocal rust_language::lookup_symbol_nonlocal
(const char *name, const struct block *block, (const char *name, const struct block *block,
const domain_enum domain) const const domain_search_flags domain) const
{ {
struct block_symbol result = {}; struct block_symbol result = {};
@@ -1707,7 +1708,7 @@ rust_language::lookup_symbol_nonlocal
symbol_lookup_debug_printf symbol_lookup_debug_printf
("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)", ("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)",
name, host_address_to_string (block), scope, name, host_address_to_string (block), scope,
domain_name (domain)); domain_name (domain).c_str ());
/* Look up bare names in the block's scope. */ /* Look up bare names in the block's scope. */
std::string scopedname; std::string scopedname;

View File

@@ -151,7 +151,7 @@ public:
struct block_symbol lookup_symbol_nonlocal struct block_symbol lookup_symbol_nonlocal
(const char *name, const struct block *block, (const char *name, const struct block *block,
const domain_enum domain) const override; const domain_search_flags domain) const override;
/* See language.h. */ /* See language.h. */

View File

@@ -308,7 +308,7 @@ struct rust_parser
void update_innermost_block (struct block_symbol sym); void update_innermost_block (struct block_symbol sym);
struct block_symbol lookup_symbol (const char *name, struct block_symbol lookup_symbol (const char *name,
const struct block *block, const struct block *block,
const domain_enum domain); const domain_search_flags domain);
struct type *rust_lookup_type (const char *name); struct type *rust_lookup_type (const char *name);
/* Clear some state. This is only used for testing. */ /* Clear some state. This is only used for testing. */
@@ -431,7 +431,7 @@ munge_name_and_block (const char **name, const struct block **block)
struct block_symbol struct block_symbol
rust_parser::lookup_symbol (const char *name, const struct block *block, rust_parser::lookup_symbol (const char *name, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
struct block_symbol result; struct block_symbol result;
@@ -454,7 +454,7 @@ rust_parser::rust_lookup_type (const char *name)
const struct block *block = pstate->expression_context_block; const struct block *block = pstate->expression_context_block;
munge_name_and_block (&name, &block); munge_name_and_block (&name, &block);
result = ::lookup_symbol (name, block, STRUCT_DOMAIN, NULL); result = ::lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, NULL);
if (result.symbol != NULL) if (result.symbol != NULL)
{ {
update_innermost_block (result); update_innermost_block (result);
@@ -1221,7 +1221,7 @@ rust_parser::name_to_operation (const std::string &name)
{ {
struct block_symbol sym = lookup_symbol (name.c_str (), struct block_symbol sym = lookup_symbol (name.c_str (),
pstate->expression_context_block, pstate->expression_context_block,
VAR_DOMAIN); SEARCH_VFT);
if (sym.symbol != nullptr && sym.symbol->aclass () != LOC_TYPEDEF) if (sym.symbol != nullptr && sym.symbol->aclass () != LOC_TYPEDEF)
return make_operation<var_value_operation> (sym); return make_operation<var_value_operation> (sym);

View File

@@ -316,8 +316,9 @@ select_source_symtab ()
/* Make the default place to list be the function `main' /* Make the default place to list be the function `main'
if one exists. */ if one exists. */
block_symbol bsym = lookup_symbol (main_name (), 0, VAR_DOMAIN, 0); block_symbol bsym = lookup_symbol (main_name (), nullptr,
if (bsym.symbol != nullptr && bsym.symbol->aclass () == LOC_BLOCK) SEARCH_FUNCTION_DOMAIN, nullptr);
if (bsym.symbol != nullptr)
{ {
symtab_and_line sal = find_function_start_sal (bsym.symbol, true); symtab_and_line sal = find_function_start_sal (bsym.symbol, true);
if (sal.symtab == NULL) if (sal.symtab == NULL)

View File

@@ -817,7 +817,7 @@ print_frame_args (const frame_print_options &fp_opts,
struct symbol *nsym; struct symbol *nsym;
nsym = lookup_symbol_search_name (sym->search_name (), nsym = lookup_symbol_search_name (sym->search_name (),
b, VAR_DOMAIN).symbol; b, SEARCH_VAR_DOMAIN).symbol;
gdb_assert (nsym != NULL); gdb_assert (nsym != NULL);
if (nsym->aclass () == LOC_REGISTER if (nsym->aclass () == LOC_REGISTER
&& !nsym->is_argument ()) && !nsym->is_argument ())
@@ -2485,7 +2485,7 @@ iterate_over_block_arg_vars (const struct block *b,
struct symbol *sym2 struct symbol *sym2
= lookup_symbol_search_name (sym->search_name (), = lookup_symbol_search_name (sym->search_name (),
b, VAR_DOMAIN).symbol; b, SEARCH_VAR_DOMAIN).symbol;
cb (sym->print_name (), sym2); cb (sym->print_name (), sym2);
} }
} }

View File

@@ -240,7 +240,8 @@ objfile::map_symtabs_matching_filename
} }
struct compunit_symtab * struct compunit_symtab *
objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) objfile::lookup_symbol (block_enum kind, const char *name,
domain_search_flags domain)
{ {
struct compunit_symtab *retval = nullptr; struct compunit_symtab *retval = nullptr;
@@ -248,7 +249,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
gdb_printf (gdb_stdlog, gdb_printf (gdb_stdlog,
"qf->lookup_symbol (%s, %d, \"%s\", %s)\n", "qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
objfile_debug_name (this), kind, name, objfile_debug_name (this), kind, name,
domain_name (domain)); domain_name (domain).c_str ());
lookup_name_info lookup_name (name, symbol_name_match_type::FULL); lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
@@ -277,10 +278,6 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
return true; return true;
}; };
domain_search_flags flags = to_search_flags (domain);
if (domain == VAR_DOMAIN)
flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN;
for (const auto &iter : qf) for (const auto &iter : qf)
{ {
if (!iter->expand_symtabs_matching (this, if (!iter->expand_symtabs_matching (this,
@@ -291,7 +288,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
kind == GLOBAL_BLOCK kind == GLOBAL_BLOCK
? SEARCH_GLOBAL_BLOCK ? SEARCH_GLOBAL_BLOCK
: SEARCH_STATIC_BLOCK, : SEARCH_STATIC_BLOCK,
flags)) domain))
break; break;
} }

View File

@@ -1697,8 +1697,8 @@ set_initial_language_callback ()
{ {
const char *name = main_name (); const char *name = main_name ();
struct symbol *sym struct symbol *sym
= lookup_symbol_in_language (name, NULL, VAR_DOMAIN, default_lang, = lookup_symbol_in_language (name, nullptr, SEARCH_FUNCTION_DOMAIN,
NULL).symbol; default_lang, nullptr).symbol;
if (sym != NULL) if (sym != NULL)
lang = sym->language (); lang = sym->language ();

View File

@@ -85,7 +85,7 @@ static struct block_symbol
lookup_symbol_aux (const char *name, lookup_symbol_aux (const char *name,
symbol_name_match_type match_type, symbol_name_match_type match_type,
const struct block *block, const struct block *block,
const domain_enum domain, const domain_search_flags domain,
enum language language, enum language language,
struct field_of_this_result *); struct field_of_this_result *);
@@ -93,13 +93,14 @@ static
struct block_symbol lookup_local_symbol (const char *name, struct block_symbol lookup_local_symbol (const char *name,
symbol_name_match_type match_type, symbol_name_match_type match_type,
const struct block *block, const struct block *block,
const domain_enum domain, const domain_search_flags domain,
enum language language); enum language language);
static struct block_symbol static struct block_symbol
lookup_symbol_in_objfile (struct objfile *objfile, lookup_symbol_in_objfile (struct objfile *objfile,
enum block_enum block_index, enum block_enum block_index,
const char *name, const domain_enum domain); const char *name,
const domain_search_flags domain);
static void set_main_name (program_space *pspace, const char *name, static void set_main_name (program_space *pspace, const char *name,
language lang); language lang);
@@ -171,14 +172,14 @@ struct symbol_cache_slot
lookup was saved in the cache, but cache space is pretty cheap. */ lookup was saved in the cache, but cache space is pretty cheap. */
const struct objfile *objfile_context; const struct objfile *objfile_context;
/* The domain that was searched for initially. This must exactly
match. */
domain_search_flags domain;
union union
{ {
struct block_symbol found; struct block_symbol found;
struct
{
char *name; char *name;
domain_enum domain;
} not_found;
} value; } value;
}; };
@@ -188,7 +189,7 @@ static void
symbol_cache_clear_slot (struct symbol_cache_slot *slot) symbol_cache_clear_slot (struct symbol_cache_slot *slot)
{ {
if (slot->state == SYMBOL_SLOT_NOT_FOUND) if (slot->state == SYMBOL_SLOT_NOT_FOUND)
xfree (slot->value.not_found.name); xfree (slot->value.name);
slot->state = SYMBOL_SLOT_UNUSED; slot->state = SYMBOL_SLOT_UNUSED;
} }
@@ -1243,18 +1244,13 @@ matching_obj_sections (struct obj_section *obj_first,
static unsigned int static unsigned int
hash_symbol_entry (const struct objfile *objfile_context, hash_symbol_entry (const struct objfile *objfile_context,
const char *name, domain_enum domain) const char *name, domain_search_flags domain)
{ {
unsigned int hash = (uintptr_t) objfile_context; unsigned int hash = (uintptr_t) objfile_context;
if (name != NULL) if (name != NULL)
hash += htab_hash_string (name); hash += htab_hash_string (name);
/* Because of symbol_matches_domain we need VAR_DOMAIN and STRUCT_DOMAIN
to map to the same slot. */
if (domain == STRUCT_DOMAIN)
hash += VAR_DOMAIN * 7;
else
hash += domain * 7; hash += domain * 7;
return hash; return hash;
@@ -1265,10 +1261,9 @@ hash_symbol_entry (const struct objfile *objfile_context,
static int static int
eq_symbol_entry (const struct symbol_cache_slot *slot, eq_symbol_entry (const struct symbol_cache_slot *slot,
const struct objfile *objfile_context, const struct objfile *objfile_context,
const char *name, domain_enum domain) const char *name, domain_search_flags domain)
{ {
const char *slot_name; const char *slot_name;
domain_enum slot_domain;
if (slot->state == SYMBOL_SLOT_UNUSED) if (slot->state == SYMBOL_SLOT_UNUSED)
return 0; return 0;
@@ -1276,16 +1271,11 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
if (slot->objfile_context != objfile_context) if (slot->objfile_context != objfile_context)
return 0; return 0;
domain_search_flags slot_domain = slot->domain;
if (slot->state == SYMBOL_SLOT_NOT_FOUND) if (slot->state == SYMBOL_SLOT_NOT_FOUND)
{ slot_name = slot->value.name;
slot_name = slot->value.not_found.name;
slot_domain = slot->value.not_found.domain;
}
else else
{
slot_name = slot->value.found.symbol->search_name (); slot_name = slot->value.found.symbol->search_name ();
slot_domain = slot->value.found.symbol->domain ();
}
/* NULL names match. */ /* NULL names match. */
if (slot_name == NULL && name == NULL) if (slot_name == NULL && name == NULL)
@@ -1301,18 +1291,18 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
the first time through. If the slot records a found symbol, the first time through. If the slot records a found symbol,
then this means using the symbol name comparison function of then this means using the symbol name comparison function of
the symbol's language with symbol->search_name (). See the symbol's language with symbol->search_name (). See
dictionary.c. It also means using symbol_matches_domain for dictionary.c.
found symbols. See block.c.
If the slot records a not-found symbol, then require a precise match. If the slot records a not-found symbol, then require a precise match.
We could still be lax with whitespace like strcmp_iw though. */ We could still be lax with whitespace like strcmp_iw though. */
if (slot_domain != domain)
return 0;
if (slot->state == SYMBOL_SLOT_NOT_FOUND) if (slot->state == SYMBOL_SLOT_NOT_FOUND)
{ {
if (strcmp (slot_name, name) != 0) if (strcmp (slot_name, name) != 0)
return 0; return 0;
if (slot_domain != domain)
return 0;
} }
else else
{ {
@@ -1321,9 +1311,6 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
if (!symbol_matches_search_name (sym, lookup_name)) if (!symbol_matches_search_name (sym, lookup_name))
return 0; return 0;
if (!symbol_matches_domain (sym->language (), slot_domain, domain))
return 0;
} }
} }
else else
@@ -1443,7 +1430,7 @@ set_symbol_cache_size_handler (const char *args, int from_tty,
static struct block_symbol static struct block_symbol
symbol_cache_lookup (struct symbol_cache *cache, symbol_cache_lookup (struct symbol_cache *cache,
struct objfile *objfile_context, enum block_enum block, struct objfile *objfile_context, enum block_enum block,
const char *name, domain_enum domain, const char *name, domain_search_flags domain,
struct block_symbol_cache **bsc_ptr, struct block_symbol_cache **bsc_ptr,
struct symbol_cache_slot **slot_ptr) struct symbol_cache_slot **slot_ptr)
{ {
@@ -1474,7 +1461,7 @@ symbol_cache_lookup (struct symbol_cache *cache,
block == GLOBAL_BLOCK ? "Global" : "Static", block == GLOBAL_BLOCK ? "Global" : "Static",
slot->state == SYMBOL_SLOT_NOT_FOUND slot->state == SYMBOL_SLOT_NOT_FOUND
? " (not found)" : "", name, ? " (not found)" : "", name,
domain_name (domain)); domain_name (domain).c_str ());
++bsc->hits; ++bsc->hits;
if (slot->state == SYMBOL_SLOT_NOT_FOUND) if (slot->state == SYMBOL_SLOT_NOT_FOUND)
return SYMBOL_LOOKUP_FAILED; return SYMBOL_LOOKUP_FAILED;
@@ -1485,7 +1472,7 @@ symbol_cache_lookup (struct symbol_cache *cache,
symbol_lookup_debug_printf ("%s block symbol cache miss for %s, %s", symbol_lookup_debug_printf ("%s block symbol cache miss for %s, %s",
block == GLOBAL_BLOCK ? "Global" : "Static", block == GLOBAL_BLOCK ? "Global" : "Static",
name, domain_name (domain)); name, domain_name (domain).c_str ());
++bsc->misses; ++bsc->misses;
return {}; return {};
} }
@@ -1500,7 +1487,8 @@ symbol_cache_mark_found (struct block_symbol_cache *bsc,
struct symbol_cache_slot *slot, struct symbol_cache_slot *slot,
struct objfile *objfile_context, struct objfile *objfile_context,
struct symbol *symbol, struct symbol *symbol,
const struct block *block) const struct block *block,
domain_search_flags domain)
{ {
if (bsc == NULL) if (bsc == NULL)
return; return;
@@ -1513,6 +1501,7 @@ symbol_cache_mark_found (struct block_symbol_cache *bsc,
slot->objfile_context = objfile_context; slot->objfile_context = objfile_context;
slot->value.found.symbol = symbol; slot->value.found.symbol = symbol;
slot->value.found.block = block; slot->value.found.block = block;
slot->domain = domain;
} }
/* Mark symbol NAME, DOMAIN as not found in SLOT. /* Mark symbol NAME, DOMAIN as not found in SLOT.
@@ -1523,7 +1512,7 @@ static void
symbol_cache_mark_not_found (struct block_symbol_cache *bsc, symbol_cache_mark_not_found (struct block_symbol_cache *bsc,
struct symbol_cache_slot *slot, struct symbol_cache_slot *slot,
struct objfile *objfile_context, struct objfile *objfile_context,
const char *name, domain_enum domain) const char *name, domain_search_flags domain)
{ {
if (bsc == NULL) if (bsc == NULL)
return; return;
@@ -1534,8 +1523,8 @@ symbol_cache_mark_not_found (struct block_symbol_cache *bsc,
} }
slot->state = SYMBOL_SLOT_NOT_FOUND; slot->state = SYMBOL_SLOT_NOT_FOUND;
slot->objfile_context = objfile_context; slot->objfile_context = objfile_context;
slot->value.not_found.name = xstrdup (name); slot->value.name = xstrdup (name);
slot->value.not_found.domain = domain; slot->domain = domain;
} }
/* Flush the symbol cache of PSPACE. */ /* Flush the symbol cache of PSPACE. */
@@ -1620,8 +1609,8 @@ symbol_cache_dump (const struct symbol_cache *cache)
case SYMBOL_SLOT_NOT_FOUND: case SYMBOL_SLOT_NOT_FOUND:
gdb_printf (" [%4u] = %s, %s %s (not found)\n", i, gdb_printf (" [%4u] = %s, %s %s (not found)\n", i,
host_address_to_string (slot->objfile_context), host_address_to_string (slot->objfile_context),
slot->value.not_found.name, slot->value.name,
domain_name (slot->value.not_found.domain)); domain_name (slot->domain).c_str ());
break; break;
case SYMBOL_SLOT_FOUND: case SYMBOL_SLOT_FOUND:
{ {
@@ -1984,7 +1973,8 @@ search_name_hash (enum language language, const char *search_name)
struct block_symbol struct block_symbol
lookup_symbol_in_language (const char *name, const struct block *block, lookup_symbol_in_language (const char *name, const struct block *block,
const domain_enum domain, enum language lang, const domain_search_flags domain,
enum language lang,
struct field_of_this_result *is_a_field_of_this) struct field_of_this_result *is_a_field_of_this)
{ {
SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT; SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT;
@@ -2002,7 +1992,7 @@ lookup_symbol_in_language (const char *name, const struct block *block,
struct block_symbol struct block_symbol
lookup_symbol (const char *name, const struct block *block, lookup_symbol (const char *name, const struct block *block,
domain_enum domain, domain_search_flags domain,
struct field_of_this_result *is_a_field_of_this) struct field_of_this_result *is_a_field_of_this)
{ {
return lookup_symbol_in_language (name, block, domain, return lookup_symbol_in_language (name, block, domain,
@@ -2014,7 +2004,7 @@ lookup_symbol (const char *name, const struct block *block,
struct block_symbol struct block_symbol
lookup_symbol_search_name (const char *search_name, const struct block *block, lookup_symbol_search_name (const char *search_name, const struct block *block,
domain_enum domain) domain_search_flags domain)
{ {
return lookup_symbol_aux (search_name, symbol_name_match_type::SEARCH_NAME, return lookup_symbol_aux (search_name, symbol_name_match_type::SEARCH_NAME,
block, domain, language_asm, NULL); block, domain, language_asm, NULL);
@@ -2039,7 +2029,7 @@ lookup_language_this (const struct language_defn *lang,
sym = block_lookup_symbol (block, lang->name_of_this (), sym = block_lookup_symbol (block, lang->name_of_this (),
symbol_name_match_type::SEARCH_NAME, symbol_name_match_type::SEARCH_NAME,
VAR_DOMAIN); SEARCH_VFT);
if (sym != NULL) if (sym != NULL)
{ {
symbol_lookup_debug_printf_v symbol_lookup_debug_printf_v
@@ -2108,7 +2098,7 @@ check_field (struct type *type, const char *name,
static struct block_symbol static struct block_symbol
lookup_symbol_aux (const char *name, symbol_name_match_type match_type, lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
const struct block *block, const struct block *block,
const domain_enum domain, enum language language, const domain_search_flags domain, enum language language,
struct field_of_this_result *is_a_field_of_this) struct field_of_this_result *is_a_field_of_this)
{ {
SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT; SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT;
@@ -2127,7 +2117,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
objfile != NULL ? objfile_debug_name (objfile) : "NULL"); objfile != NULL ? objfile_debug_name (objfile) : "NULL");
symbol_lookup_debug_printf symbol_lookup_debug_printf
("domain name = \"%s\", language = \"%s\")", ("domain name = \"%s\", language = \"%s\")",
domain_name (domain), language_str (language)); domain_name (domain).c_str (), language_str (language));
} }
/* Make sure we do something sensible with is_a_field_of_this, since /* Make sure we do something sensible with is_a_field_of_this, since
@@ -2157,7 +2147,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
/* Don't do this check if we are searching for a struct. It will /* Don't do this check if we are searching for a struct. It will
not be found by check_field, but will be found by other not be found by check_field, but will be found by other
means. */ means. */
if (is_a_field_of_this != NULL && domain != STRUCT_DOMAIN) if (is_a_field_of_this != NULL && (domain & SEARCH_STRUCT_DOMAIN) == 0)
{ {
result = lookup_language_this (langdef, block); result = lookup_language_this (langdef, block);
@@ -2213,7 +2203,7 @@ static struct block_symbol
lookup_local_symbol (const char *name, lookup_local_symbol (const char *name,
symbol_name_match_type match_type, symbol_name_match_type match_type,
const struct block *block, const struct block *block,
const domain_enum domain, const domain_search_flags domain,
enum language language) enum language language)
{ {
if (block == nullptr) if (block == nullptr)
@@ -2258,7 +2248,7 @@ lookup_local_symbol (const char *name,
struct symbol * struct symbol *
lookup_symbol_in_block (const char *name, symbol_name_match_type match_type, lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
struct symbol *sym; struct symbol *sym;
@@ -2271,7 +2261,7 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
("lookup_symbol_in_block (%s, %s (objfile %s), %s)", ("lookup_symbol_in_block (%s, %s (objfile %s), %s)",
name, host_address_to_string (block), name, host_address_to_string (block),
objfile != nullptr ? objfile_debug_name (objfile) : "NULL", objfile != nullptr ? objfile_debug_name (objfile) : "NULL",
domain_name (domain)); domain_name (domain).c_str ());
} }
sym = block_lookup_symbol (block, name, match_type, domain); sym = block_lookup_symbol (block, name, match_type, domain);
@@ -2292,7 +2282,7 @@ struct block_symbol
lookup_global_symbol_from_objfile (struct objfile *main_objfile, lookup_global_symbol_from_objfile (struct objfile *main_objfile,
enum block_enum block_index, enum block_enum block_index,
const char *name, const char *name,
const domain_enum domain) const domain_search_flags domain)
{ {
gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK); gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
@@ -2316,7 +2306,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
static struct block_symbol static struct block_symbol
lookup_symbol_in_objfile_symtabs (struct objfile *objfile, lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
enum block_enum block_index, const char *name, enum block_enum block_index, const char *name,
const domain_enum domain) const domain_search_flags domain)
{ {
gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK); gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
@@ -2324,7 +2314,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
("lookup_symbol_in_objfile_symtabs (%s, %s, %s, %s)", ("lookup_symbol_in_objfile_symtabs (%s, %s, %s, %s)",
objfile_debug_name (objfile), objfile_debug_name (objfile),
block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK", block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
name, domain_name (domain)); name, domain_name (domain).c_str ());
struct block_symbol other; struct block_symbol other;
other.symbol = NULL; other.symbol = NULL;
@@ -2383,7 +2373,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
static struct block_symbol static struct block_symbol
lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile, lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
const char *linkage_name, const char *linkage_name,
domain_enum domain) domain_search_flags domain)
{ {
enum language lang = current_language->la_language; enum language lang = current_language->la_language;
struct objfile *main_objfile; struct objfile *main_objfile;
@@ -2435,7 +2425,7 @@ Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n\
static struct block_symbol static struct block_symbol
lookup_symbol_via_quick_fns (struct objfile *objfile, lookup_symbol_via_quick_fns (struct objfile *objfile,
enum block_enum block_index, const char *name, enum block_enum block_index, const char *name,
const domain_enum domain) const domain_search_flags domain)
{ {
struct compunit_symtab *cust; struct compunit_symtab *cust;
const struct blockvector *bv; const struct blockvector *bv;
@@ -2446,7 +2436,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
("lookup_symbol_via_quick_fns (%s, %s, %s, %s)", ("lookup_symbol_via_quick_fns (%s, %s, %s, %s)",
objfile_debug_name (objfile), objfile_debug_name (objfile),
block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK", block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
name, domain_name (domain)); name, domain_name (domain).c_str ());
cust = objfile->lookup_symbol (block_index, name, domain); cust = objfile->lookup_symbol (block_index, name, domain);
if (cust == NULL) if (cust == NULL)
@@ -2477,7 +2467,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
struct block_symbol struct block_symbol
language_defn::lookup_symbol_nonlocal (const char *name, language_defn::lookup_symbol_nonlocal (const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const const domain_search_flags domain) const
{ {
struct block_symbol result; struct block_symbol result;
@@ -2495,7 +2485,7 @@ language_defn::lookup_symbol_nonlocal (const char *name,
shared libraries we could search all of them only to find out the shared libraries we could search all of them only to find out the
builtin type isn't defined in any of them. This is common for types builtin type isn't defined in any of them. This is common for types
like "void". */ like "void". */
if (domain == VAR_DOMAIN) if ((domain & SEARCH_TYPE_DOMAIN) != 0)
{ {
struct gdbarch *gdbarch; struct gdbarch *gdbarch;
@@ -2518,7 +2508,7 @@ language_defn::lookup_symbol_nonlocal (const char *name,
struct block_symbol struct block_symbol
lookup_symbol_in_static_block (const char *name, lookup_symbol_in_static_block (const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
if (block == nullptr) if (block == nullptr)
return {}; return {};
@@ -2538,7 +2528,7 @@ lookup_symbol_in_static_block (const char *name,
("lookup_symbol_in_static_block (%s, %s (objfile %s), %s)", ("lookup_symbol_in_static_block (%s, %s (objfile %s), %s)",
name, host_address_to_string (block), name, host_address_to_string (block),
objfile != nullptr ? objfile_debug_name (objfile) : "NULL", objfile != nullptr ? objfile_debug_name (objfile) : "NULL",
domain_name (domain)); domain_name (domain).c_str ());
} }
sym = lookup_symbol_in_block (name, sym = lookup_symbol_in_block (name,
@@ -2557,7 +2547,7 @@ lookup_symbol_in_static_block (const char *name,
static struct block_symbol static struct block_symbol
lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index, lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index,
const char *name, const domain_enum domain) const char *name, const domain_search_flags domain)
{ {
struct block_symbol result; struct block_symbol result;
@@ -2567,7 +2557,7 @@ lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index,
objfile_debug_name (objfile), objfile_debug_name (objfile),
block_index == GLOBAL_BLOCK block_index == GLOBAL_BLOCK
? "GLOBAL_BLOCK" : "STATIC_BLOCK", ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
name, domain_name (domain)); name, domain_name (domain).c_str ());
result = lookup_symbol_in_objfile_symtabs (objfile, block_index, result = lookup_symbol_in_objfile_symtabs (objfile, block_index,
name, domain); name, domain);
@@ -2598,7 +2588,7 @@ static struct block_symbol
lookup_global_or_static_symbol (const char *name, lookup_global_or_static_symbol (const char *name,
enum block_enum block_index, enum block_enum block_index,
struct objfile *objfile, struct objfile *objfile,
const domain_enum domain) const domain_search_flags domain)
{ {
struct symbol_cache *cache = get_symbol_cache (current_program_space); struct symbol_cache *cache = get_symbol_cache (current_program_space);
struct block_symbol result; struct block_symbol result;
@@ -2632,7 +2622,8 @@ lookup_global_or_static_symbol (const char *name,
objfile); objfile);
if (result.symbol != NULL) if (result.symbol != NULL)
symbol_cache_mark_found (bsc, slot, objfile, result.symbol, result.block); symbol_cache_mark_found (bsc, slot, objfile, result.symbol, result.block,
domain);
else else
symbol_cache_mark_not_found (bsc, slot, objfile, name, domain); symbol_cache_mark_not_found (bsc, slot, objfile, name, domain);
@@ -2642,7 +2633,7 @@ lookup_global_or_static_symbol (const char *name,
/* See symtab.h. */ /* See symtab.h. */
struct block_symbol struct block_symbol
lookup_static_symbol (const char *name, const domain_enum domain) lookup_static_symbol (const char *name, const domain_search_flags domain)
{ {
return lookup_global_or_static_symbol (name, STATIC_BLOCK, nullptr, domain); return lookup_global_or_static_symbol (name, STATIC_BLOCK, nullptr, domain);
} }
@@ -2652,7 +2643,7 @@ lookup_static_symbol (const char *name, const domain_enum domain)
struct block_symbol struct block_symbol
lookup_global_symbol (const char *name, lookup_global_symbol (const char *name,
const struct block *block, const struct block *block,
const domain_enum domain) const domain_search_flags domain)
{ {
/* If a block was passed in, we want to search the corresponding /* If a block was passed in, we want to search the corresponding
global block first. This yields "more expected" behavior, and is global block first. This yields "more expected" behavior, and is
@@ -2761,7 +2752,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
const struct block *block; const struct block *block;
struct symbol *sym; struct symbol *sym;
cust = objfile->lookup_symbol (block_index, name, STRUCT_DOMAIN); cust = objfile->lookup_symbol (block_index, name, SEARCH_STRUCT_DOMAIN);
if (cust == NULL) if (cust == NULL)
return NULL; return NULL;
@@ -2769,7 +2760,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
block = bv->block (block_index); block = bv->block (block_index);
lookup_name_info lookup_name (name, symbol_name_match_type::FULL); lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
sym = block_find_symbol (block, lookup_name, STRUCT_DOMAIN, nullptr); sym = block_find_symbol (block, lookup_name, SEARCH_STRUCT_DOMAIN, nullptr);
if (sym == nullptr) if (sym == nullptr)
error_in_psymtab_expansion (block_index, name, cust); error_in_psymtab_expansion (block_index, name, cust);
gdb_assert (!TYPE_IS_OPAQUE (sym->type ())); gdb_assert (!TYPE_IS_OPAQUE (sym->type ()));
@@ -2794,7 +2785,8 @@ basic_lookup_transparent_type_1 (struct objfile *objfile,
{ {
bv = cust->blockvector (); bv = cust->blockvector ();
block = bv->block (block_index); block = bv->block (block_index);
sym = block_find_symbol (block, lookup_name, STRUCT_DOMAIN, nullptr); sym = block_find_symbol (block, lookup_name, SEARCH_STRUCT_DOMAIN,
nullptr);
if (sym != nullptr) if (sym != nullptr)
{ {
gdb_assert (!TYPE_IS_OPAQUE (sym->type ())); gdb_assert (!TYPE_IS_OPAQUE (sym->type ()));
@@ -4888,7 +4880,7 @@ global_symbol_searcher::expand_symtabs
(msymbol->value_address (objfile)) == NULL) (msymbol->value_address (objfile)) == NULL)
: (lookup_symbol_in_objfile_from_linkage_name : (lookup_symbol_in_objfile_from_linkage_name
(objfile, msymbol->linkage_name (), (objfile, msymbol->linkage_name (),
VAR_DOMAIN) SEARCH_VFT)
.symbol == NULL)) .symbol == NULL))
found_msymbol = true; found_msymbol = true;
} }
@@ -5026,7 +5018,7 @@ global_symbol_searcher::add_matching_msymbols
{ {
if (lookup_symbol_in_objfile_from_linkage_name if (lookup_symbol_in_objfile_from_linkage_name
(objfile, msymbol->linkage_name (), (objfile, msymbol->linkage_name (),
VAR_DOMAIN).symbol == NULL) SEARCH_VFT).symbol == NULL)
{ {
/* Matching msymbol, add it to the results list. */ /* Matching msymbol, add it to the results list. */
if (results->size () < m_max_search_results) if (results->size () < m_max_search_results)

View File

@@ -2112,7 +2112,7 @@ struct field_of_this_result
extern struct block_symbol extern struct block_symbol
lookup_symbol_in_language (const char *, lookup_symbol_in_language (const char *,
const struct block *, const struct block *,
const domain_enum, const domain_search_flags,
enum language, enum language,
struct field_of_this_result *); struct field_of_this_result *);
@@ -2120,7 +2120,7 @@ extern struct block_symbol
extern struct block_symbol lookup_symbol (const char *, extern struct block_symbol lookup_symbol (const char *,
const struct block *, const struct block *,
const domain_enum, const domain_search_flags,
struct field_of_this_result *); struct field_of_this_result *);
/* Find the definition for a specified symbol search name in domain /* Find the definition for a specified symbol search name in domain
@@ -2132,9 +2132,10 @@ extern struct block_symbol lookup_symbol (const char *,
pointer, or NULL if no symbol is found. The symbol's section is pointer, or NULL if no symbol is found. The symbol's section is
fixed up if necessary. */ fixed up if necessary. */
extern struct block_symbol lookup_symbol_search_name (const char *search_name, extern struct block_symbol lookup_symbol_search_name
(const char *search_name,
const struct block *block, const struct block *block,
domain_enum domain); domain_search_flags domain);
/* Some helper functions for languages that need to write their own /* Some helper functions for languages that need to write their own
lookup_symbol_nonlocal functions. */ lookup_symbol_nonlocal functions. */
@@ -2146,13 +2147,13 @@ extern struct block_symbol lookup_symbol_search_name (const char *search_name,
extern struct block_symbol extern struct block_symbol
lookup_symbol_in_static_block (const char *name, lookup_symbol_in_static_block (const char *name,
const struct block *block, const struct block *block,
const domain_enum domain); const domain_search_flags domain);
/* Search all static file-level symbols for NAME from DOMAIN. /* Search all static file-level symbols for NAME from DOMAIN.
Upon success fixes up the symbol's section if necessary. */ Upon success fixes up the symbol's section if necessary. */
extern struct block_symbol lookup_static_symbol (const char *name, extern struct block_symbol lookup_static_symbol
const domain_enum domain); (const char *name, const domain_search_flags domain);
/* Lookup a symbol in all files' global blocks. /* Lookup a symbol in all files' global blocks.
@@ -2168,7 +2169,7 @@ extern struct block_symbol lookup_static_symbol (const char *name,
extern struct block_symbol extern struct block_symbol
lookup_global_symbol (const char *name, lookup_global_symbol (const char *name,
const struct block *block, const struct block *block,
const domain_enum domain); const domain_search_flags domain);
/* Lookup a symbol in block BLOCK. /* Lookup a symbol in block BLOCK.
Upon success fixes up the symbol's section if necessary. */ Upon success fixes up the symbol's section if necessary. */
@@ -2177,7 +2178,7 @@ extern struct symbol *
lookup_symbol_in_block (const char *name, lookup_symbol_in_block (const char *name,
symbol_name_match_type match_type, symbol_name_match_type match_type,
const struct block *block, const struct block *block,
const domain_enum domain); const domain_search_flags domain);
/* Look up the `this' symbol for LANG in BLOCK. Return the symbol if /* Look up the `this' symbol for LANG in BLOCK. Return the symbol if
found, or NULL if not found. */ found, or NULL if not found. */
@@ -2724,7 +2725,7 @@ extern struct block_symbol
lookup_global_symbol_from_objfile (struct objfile *main_objfile, lookup_global_symbol_from_objfile (struct objfile *main_objfile,
enum block_enum block_index, enum block_enum block_index,
const char *name, const char *name,
const domain_enum domain); const domain_search_flags domain);
/* Return 1 if the supplied producer string matches the ARM RealView /* Return 1 if the supplied producer string matches the ARM RealView
compiler (armcc). */ compiler (armcc). */

View File

@@ -118,15 +118,9 @@ find_function_in_inferior (const char *name, struct objfile **objf_p)
{ {
struct block_symbol sym; struct block_symbol sym;
sym = lookup_symbol (name, 0, VAR_DOMAIN, 0); sym = lookup_symbol (name, nullptr, SEARCH_TYPE_DOMAIN, nullptr);
if (sym.symbol != NULL) if (sym.symbol != NULL)
{ {
if (sym.symbol->aclass () != LOC_BLOCK)
{
error (_("\"%s\" exists in this program but is not a function."),
name);
}
if (objf_p) if (objf_p)
*objf_p = sym.symbol->objfile (); *objf_p = sym.symbol->objfile ();
@@ -3708,7 +3702,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
{ {
struct symbol *s = struct symbol *s =
lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
0, VAR_DOMAIN, 0).symbol; 0, SEARCH_FUNCTION_DOMAIN, 0).symbol;
if (s == NULL) if (s == NULL)
return NULL; return NULL;
@@ -3739,7 +3733,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
{ {
struct symbol *s = struct symbol *s =
lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
0, VAR_DOMAIN, 0).symbol; 0, SEARCH_FUNCTION_DOMAIN, 0).symbol;
if (s == NULL) if (s == NULL)
return NULL; return NULL;
@@ -3819,7 +3813,7 @@ value_maybe_namespace_elt (const struct type *curtype,
struct value *result; struct value *result;
sym = cp_lookup_symbol_namespace (namespace_name, name, sym = cp_lookup_symbol_namespace (namespace_name, name,
get_selected_block (0), VAR_DOMAIN); get_selected_block (0), SEARCH_VFT);
if (sym.symbol == NULL) if (sym.symbol == NULL)
return NULL; return NULL;

View File

@@ -2922,7 +2922,8 @@ value_static_field (struct type *type, int fieldno)
{ {
const char *phys_name = type->field (fieldno).loc_physname (); const char *phys_name = type->field (fieldno).loc_physname ();
/* type->field (fieldno).name (); */ /* type->field (fieldno).name (); */
struct block_symbol sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0); struct block_symbol sym = lookup_symbol (phys_name, nullptr,
SEARCH_VAR_DOMAIN, nullptr);
if (sym.symbol == NULL) if (sym.symbol == NULL)
{ {
@@ -3113,7 +3114,8 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
struct symbol *sym; struct symbol *sym;
struct bound_minimal_symbol msym; struct bound_minimal_symbol msym;
sym = lookup_symbol (physname, 0, VAR_DOMAIN, 0).symbol; sym = lookup_symbol (physname, nullptr, SEARCH_FUNCTION_DOMAIN,
nullptr).symbol;
if (sym == nullptr) if (sym == nullptr)
{ {
msym = lookup_bound_minimal_symbol (physname); msym = lookup_bound_minimal_symbol (physname);

View File

@@ -423,7 +423,8 @@ xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
return plg_end; return plg_end;
/* Found a function. */ /* Found a function. */
sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol; sym = lookup_symbol (func_name, NULL, SEARCH_FUNCTION_DOMAIN,
nullptr).symbol;
/* Don't use line number debug info for assembly source files. */ /* Don't use line number debug info for assembly source files. */
if (sym && sym->language () != language_asm) if (sym && sym->language () != language_asm)
{ {