====
The name "sym" shadows "sym" defined at function entry.
Renaming the one at function entry to "bsym" would be ok.
> yylval.theclass.theclass = Class;
> sym = lookup_struct_typedef (copy, expression_context_block, 1);
> if (sym)
> @@ -2957,7 +2958,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
> /* Input names that aren't symbols but ARE valid hex numbers, when
> the input radix permits them, can be names or numbers depending
> on the parse. Note we support radixes > 16 here. */
> - if (!sym
> + if (!sym.symbol
> && ((copy[0] >= 'a' && copy[0] < 'a' + input_radix - 10)
> || (copy[0] >= 'A' && copy[0] < 'A' + input_radix - 10)))
> {
> @@ -2976,7 +2977,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
> yylval.ssym.sym = sym;
> yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
>
> - if (sym == NULL
> + if (sym.symbol == NULL
> && parse_language (par_state)->la_language == language_cplus
> && is_a_field_of_this.type == NULL
> && lookup_minimal_symbol (copy, NULL, NULL).minsym == NULL)
> @@ -3010,7 +3011,7 @@ classify_inner_name (struct parser_state *par_state,
> /* If no symbol was found, search for a matching base class named
> COPY. This will allow users to enter qualified names of class members
> relative to the `this' pointer. */
> - if (yylval.ssym.sym == NULL)
> + if (yylval.ssym.sym.symbol == NULL)
> {
> struct type *base_type = cp_find_type_baseclass_by_name (type, copy);
>
> @@ -3023,7 +3024,7 @@ classify_inner_name (struct parser_state *par_state,
> return ERROR;
> }
>
> - switch (SYMBOL_CLASS (yylval.ssym.sym))
> + switch (SYMBOL_CLASS (yylval.ssym.sym.symbol))
> {
> case LOC_BLOCK:
> case LOC_LABEL:
> @@ -3042,7 +3043,7 @@ classify_inner_name (struct parser_state *par_state,
> return ERROR;
>
> case LOC_TYPEDEF:
> - yylval.tsym.type = SYMBOL_TYPE (yylval.ssym.sym);
> + yylval.tsym.type = SYMBOL_TYPE (yylval.ssym.sym.symbol);
> return TYPENAME;
>
> default:
> @@ -3302,8 +3303,8 @@ c_print_token (FILE *file, int type, YYSTYPE value)
> case BLOCKNAME:
> fprintf (file, "ssym<name=%s, sym=%s, field_of_this=%d>",
> copy_name (value.ssym.stoken),
> - (value.ssym.sym == NULL
> - ? "(null)" : SYMBOL_PRINT_NAME (value.ssym.sym)),
> + (value.ssym.sym.symbol == NULL
> + ? "(null)" : SYMBOL_PRINT_NAME (value.ssym.sym.symbol)),
> value.ssym.is_a_field_of_this);
> break;
>
> diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
> index 2009e95..1ad25cc 100644
> --- a/gdb/c-valprint.c
> +++ b/gdb/c-valprint.c
> @@ -203,7 +203,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
>
> if (msymbol.minsym != NULL)
> wsym = lookup_symbol (MSYMBOL_LINKAGE_NAME(msymbol.minsym), block,
> - VAR_DOMAIN, &is_this_fld);
> + VAR_DOMAIN, &is_this_fld).symbol;
>
> if (wsym)
> {
> diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
> index 68d38ba..5f27583 100644
> --- a/gdb/compile/compile-c-symbols.c
> +++ b/gdb/compile/compile-c-symbols.c
> @@ -304,13 +304,12 @@ convert_one_symbol (struct compile_c_instance *context,
>
> static void
> convert_symbol_sym (struct compile_c_instance *context, const char *identifier,
> - struct symbol *sym, domain_enum domain)
> + struct symbol *sym, domain_enum domain,
> + const struct block *block)
> {
> - const struct block *static_block, *found_block;
> + const struct block *static_block;
> int is_local_symbol;
>
> - found_block = block_found;
> -
> /* 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
> symbol of the same name. This lets this unusual case work:
> @@ -323,24 +322,24 @@ convert_symbol_sym (struct compile_c_instance *context, const char *identifier,
> }
> */
>
> - static_block = block_static_block (found_block);
> + static_block = block_static_block (block);
> /* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block. */
> - is_local_symbol = (found_block != static_block && static_block != NULL);
> + is_local_symbol = (block != static_block && static_block != NULL);
> if (is_local_symbol)
> {
> - struct symbol *global_sym;
> + struct symbol_in_block global_sym;
>
> global_sym = lookup_symbol (identifier, NULL, domain, NULL);
> /* If the outer symbol is in the static block, we ignore it, as
> it cannot be referenced. */
> - if (global_sym != NULL
> - && block_found != block_static_block (block_found))
> + if (global_sym.symbol != NULL
> + && global_sym.block != block_static_block (global_sym.block))
> {
> if (compile_debug)
> fprintf_unfiltered (gdb_stdlog,
> "gcc_convert_symbol \"%s\": global symbol\n",
> identifier);
> - convert_one_symbol (context, global_sym, 1, 0);
> + convert_one_symbol (context, global_sym.symbol, 1, 0);
> }
> }
>
> @@ -444,12 +443,13 @@ gcc_convert_symbol (void *datum,
> is to simply emit a gcc error. */
> TRY
> {
> - struct symbol *sym;
> + struct symbol_in_block sym;
>
> sym = lookup_symbol (identifier, context->base.block, domain, NULL);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> {
> - convert_symbol_sym (context, identifier, sym, domain);
> + convert_symbol_sym (context, identifier, sym.symbol, domain,
> + sym.block);
====
Just pass sym here, instead of sym.symbol and sym.block.
> found = 1;
> }
> else if (domain == VAR_DOMAIN)
> @@ -495,7 +495,7 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
> struct symbol *sym;
>
> /* We only need global functions here. */
> - sym = lookup_symbol (identifier, NULL, VAR_DOMAIN, NULL);
> + sym = lookup_symbol (identifier, NULL, VAR_DOMAIN, NULL).symbol;
> if (sym != NULL && SYMBOL_CLASS (sym) == LOC_BLOCK)
> {
> if (compile_debug)
> diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
> index 162227a..16775ab 100644
> --- a/gdb/compile/compile-object-load.c
> +++ b/gdb/compile/compile-object-load.c
> @@ -676,7 +676,7 @@ compile_object_load (const char *object_file, const char *source_file,
>
> func_sym = lookup_global_symbol_from_objfile (objfile,
> GCC_FE_WRAPPER_FUNCTION,
> - VAR_DOMAIN);
> + VAR_DOMAIN).symbol;
> if (func_sym == NULL)
> error (_("Cannot find function \"%s\" in compiled module \"%s\"."),
> GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile));
> diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
> index 41f8d35..6efe05e 100644
> --- a/gdb/cp-namespace.c
> +++ b/gdb/cp-namespace.c
> @@ -32,7 +32,7 @@
> #include "buildsym.h"
> #include "language.h"
>
> -static struct symbol *
> +static struct symbol_in_block
> cp_lookup_nested_symbol_1 (struct type *container_type,
> const char *nested_name,
> const char *concatenated_name,
> @@ -213,14 +213,14 @@ cp_is_in_anonymous (const char *symbol_name)
> If IS_IN_ANONYMOUS is nonzero, the symbol in question is located
> within an anonymous namespace. */
>
> -static struct symbol *
> +static struct symbol_in_block
> cp_basic_lookup_symbol (const char *name, const struct block *block,
> const domain_enum domain, int is_in_anonymous)
> {
> - struct symbol *sym;
> + struct symbol_in_block sym;
>
> sym = lookup_symbol_in_static_block (name, block, domain);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
>
> if (is_in_anonymous)
> @@ -232,12 +232,13 @@ cp_basic_lookup_symbol (const char *name, const struct block *block,
> const struct block *global_block = block_global_block (block);
>
> if (global_block != NULL)
> - sym = lookup_symbol_in_block (name, global_block, domain);
> + {
> + sym.symbol = lookup_symbol_in_block (name, global_block, domain);
> + sym.block = global_block;
> + }
> }
> else
> - {
> - sym = lookup_global_symbol (name, block, domain);
> - }
> + sym = lookup_global_symbol (name, block, domain);
>
> return sym;
> }
> @@ -252,12 +253,12 @@ cp_basic_lookup_symbol (const char *name, const struct block *block,
> If SEARCH is non-zero then see if we can determine "this" from BLOCK, and
> if so then also search for NAME in that class. */
>
> -static struct symbol *
> +static struct symbol_in_block
> cp_lookup_bare_symbol (const struct language_defn *langdef,
> const char *name, const struct block *block,
> const domain_enum domain, int search)
> {
> - struct symbol *sym;
> + struct symbol_in_block sym;
>
> /* Note: We can't do a simple assert for ':' not being in NAME because
> ':' may be in the args of a template spec. This isn't intended to be
> @@ -266,7 +267,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
> gdb_assert (strchr (name, ':') == NULL);
>
> sym = lookup_symbol_in_static_block (name, block, domain);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
>
> /* If we didn't find a definition for a builtin type in the static block,
> @@ -283,30 +284,32 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
> gdbarch = target_gdbarch ();
> else
> gdbarch = block_gdbarch (block);
> - sym = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name);
> - if (sym != NULL)
> + sym.symbol
> + = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name);
> + sym.block = NULL;
> + if (sym.symbol != NULL)
> return sym;
> }
>
> sym = lookup_global_symbol (name, block, domain);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
>
> if (search)
> {
> - struct symbol *lang_this;
> + struct symbol_in_block lang_this;
> struct type *type;
>
> lang_this = lookup_language_this (language_def (language_cplus), block);
> - if (lang_this == NULL)
> - return NULL;
> + if (lang_this.symbol == NULL)
> + return (struct symbol_in_block) {NULL, NULL};
>
> - type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this)));
> + type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this.symbol)));
> /* If TYPE_NAME is NULL, abandon trying to find this symbol.
> This can happen for lambda functions compiled with clang++,
> which outputs no name for the container class. */
> if (TYPE_NAME (type) == NULL)
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
>
> /* Look for symbol NAME in this class. */
> sym = cp_lookup_nested_symbol (type, name, block, domain);
> @@ -324,17 +327,17 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
> Note: At least in the case of Fortran, which also uses this code, there
> may be no text after the last "::". */
>
> -static struct symbol *
> +static struct symbol_in_block
> cp_search_static_and_baseclasses (const char *name,
> const struct block *block,
> const domain_enum domain,
> unsigned int prefix_len,
> int is_in_anonymous)
> {
> - struct symbol *sym;
> + struct symbol_in_block sym;
> char *klass, *nested;
> struct cleanup *cleanup;
> - struct symbol *klass_sym;
> + struct symbol_in_block klass_sym;
> struct type *klass_type;
>
> /* The test here uses <= instead of < because Fortran also uses this,
> @@ -361,12 +364,12 @@ cp_search_static_and_baseclasses (const char *name,
> symbol_matches_domain (which should be replaced with something else,
> but it's what we have today). */
> klass_sym = lookup_global_symbol (klass, block, VAR_DOMAIN);
> - if (klass_sym == NULL)
> + if (klass_sym.symbol == NULL)
> {
> do_cleanups (cleanup);
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
> - klass_type = SYMBOL_TYPE (klass_sym);
> + klass_type = SYMBOL_TYPE (klass_sym.symbol);
>
> /* Look for a symbol named NESTED in this class.
> The caller is assumed to have already have done a basic lookup of NAME.
> @@ -387,7 +390,7 @@ cp_search_static_and_baseclasses (const char *name,
> there is no scoping in which case we also try looking in the class of
> "this" if we can compute it. */
>
> -static struct symbol *
> +static struct symbol_in_block
> cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name,
> const struct block *block,
> const domain_enum domain, int search)
> @@ -395,7 +398,7 @@ cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name,
> char *concatenated_name = NULL;
> int is_in_anonymous;
> unsigned int prefix_len;
> - struct symbol *sym;
> + struct symbol_in_block sym;
>
> if (the_namespace[0] != '\0')
> {
> @@ -419,7 +422,7 @@ cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name,
> is_in_anonymous
> = the_namespace[0] != '\0' && cp_is_in_anonymous (the_namespace);
> sym = cp_basic_lookup_symbol (name, block, domain, is_in_anonymous);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
>
> if (search)
> @@ -466,7 +469,7 @@ reset_directive_searched (void *data)
> SEARCH_SCOPE_FIRST is an internal implementation detail: Callers must
> pass 0 for it. Internally we pass 1 when recursing. */
>
> -static struct symbol *
> +static struct symbol_in_block
> cp_lookup_symbol_via_imports (const char *scope,
> const char *name,
> const struct block *block,
> @@ -476,17 +479,19 @@ cp_lookup_symbol_via_imports (const char *scope,
> const int search_parents)
> {
> struct using_direct *current;
> - struct symbol *sym = NULL;
> + struct symbol_in_block sym;
> int len;
> int directive_match;
> struct cleanup *searched_cleanup;
>
> + sym.symbol = NULL;
> +
> /* First, try to find the symbol in the given namespace if requested. */
> if (search_scope_first)
> sym = cp_lookup_symbol_in_namespace (scope, name,
> block, domain, 1);
>
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
>
> /* Go through the using directives. If any of them add new names to
> @@ -532,12 +537,12 @@ cp_lookup_symbol_via_imports (const char *scope,
> /* If this is a DECLARATION_ONLY search or a symbol was found
> or this import statement was an import declaration, the
> search of this import is complete. */
> - if (declaration_only || sym != NULL || current->declaration)
> + if (declaration_only || sym.symbol != NULL || current->declaration)
> {
> current->searched = 0;
> discard_cleanups (searched_cleanup);
>
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
>
> continue;
> @@ -575,12 +580,12 @@ cp_lookup_symbol_via_imports (const char *scope,
> current->searched = 0;
> discard_cleanups (searched_cleanup);
>
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
> }
> }
>
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* Helper function that searches an array of symbols for one named NAME. */
> @@ -604,14 +609,14 @@ search_symbol_list (const char *name, int num,
> searches through the template parameters of the function and the
> function's type. */
>
> -struct symbol *
> +struct symbol_in_block
> cp_lookup_symbol_imports_or_template (const char *scope,
> const char *name,
> const struct block *block,
> const domain_enum domain)
> {
> struct symbol *function = BLOCK_FUNCTION (block);
> - struct symbol *result;
> + struct symbol_in_block result;
>
> if (symbol_lookup_debug)
> {
> @@ -629,20 +634,19 @@ cp_lookup_symbol_imports_or_template (const char *scope,
> {
> struct template_symbol *templ
> = (struct template_symbol *) function;
> -
> - result = search_symbol_list (name,
> - templ->n_template_arguments,
> - templ->template_arguments);
> - if (result != NULL)
> + struct symbol *sym = search_symbol_list (name,
> + templ->n_template_arguments,
> + templ->template_arguments);
> + if (sym != NULL)
> {
> if (symbol_lookup_debug)
> {
> fprintf_unfiltered (gdb_stdlog,
> "cp_lookup_symbol_imports_or_template"
> " (...) = %s\n",
> - host_address_to_string (result));
> + host_address_to_string (sym));
> }
> - return result;
> + return (struct symbol_in_block) {sym, NULL};
====
Do we have to return NULL for block here?
I haven't dug into this, but it seems like we could just return
the "block" argument for the block here.
> }
> }
>
> @@ -656,6 +660,7 @@ cp_lookup_symbol_imports_or_template (const char *scope,
> const struct language_defn *lang = language_def (language_cplus);
> struct gdbarch *arch = symbol_arch (function);
> const struct block *parent = BLOCK_SUPERBLOCK (block);
> + struct symbol *sym;
>
> while (1)
> {
> @@ -674,21 +679,21 @@ cp_lookup_symbol_imports_or_template (const char *scope,
> if (context == NULL)
> break;
>
> - result
> + sym
> = search_symbol_list (name,
> TYPE_N_TEMPLATE_ARGUMENTS (context),
> TYPE_TEMPLATE_ARGUMENTS (context));
> - if (result != NULL)
> + if (sym != NULL)
> {
> do_cleanups (cleanups);
> if (symbol_lookup_debug)
> {
> - fprintf_unfiltered (gdb_stdlog,
> - "cp_lookup_symbol_imports_or_template"
> - " (...) = %s\n",
> - host_address_to_string (result));
> + fprintf_unfiltered
> + (gdb_stdlog,
> + "cp_lookup_symbol_imports_or_template (...) = %s\n",
> + host_address_to_string (sym));
> }
> - return result;
> + return (struct symbol_in_block) {sym, NULL};
====
Do we have to return NULL for block here?
I haven't dug into this, but it seems like we could just return
the "block" argument for the block here.
> }
> }
>
> @@ -701,8 +706,8 @@ cp_lookup_symbol_imports_or_template (const char *scope,
> {
> fprintf_unfiltered (gdb_stdlog,
> "cp_lookup_symbol_imports_or_template (...) = %s\n",
> - result != NULL
> - ? host_address_to_string (result) : "NULL");
> + result.symbol != NULL
> + ? host_address_to_string (result.symbol) : "NULL");
> }
> return result;
> }
> @@ -711,23 +716,23 @@ cp_lookup_symbol_imports_or_template (const char *scope,
> and its parents. SCOPE is the namespace scope of the context in which the
> search is being evaluated. */
>
> -static struct symbol *
> +static struct symbol_in_block
> cp_lookup_symbol_via_all_imports (const char *scope, const char *name,
> const struct block *block,
> const domain_enum domain)
> {
> - struct symbol *sym;
> + struct symbol_in_block sym;
>
> while (block != NULL)
> {
> sym = cp_lookup_symbol_via_imports (scope, name, block, domain, 0, 0, 1);
> - if (sym)
> + if (sym.symbol)
> return sym;
>
> block = BLOCK_SUPERBLOCK (block);
> }
>
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* Searches for NAME in the current namespace, and by applying
> @@ -735,13 +740,13 @@ cp_lookup_symbol_via_all_imports (const char *scope, const char *name,
> SCOPE is the namespace scope of the context in which the search is
> being evaluated. */
>
> -struct symbol *
> +struct symbol_in_block
> cp_lookup_symbol_namespace (const char *scope,
> const char *name,
> const struct block *block,
> const domain_enum domain)
> {
> - struct symbol *sym;
> + struct symbol_in_block sym;
>
> if (symbol_lookup_debug)
> {
> @@ -755,14 +760,15 @@ cp_lookup_symbol_namespace (const char *scope,
> sym = cp_lookup_symbol_in_namespace (scope, name, block, domain, 1);
>
> /* Search for name in namespaces imported to this and parent blocks. */
> - if (sym == NULL)
> + if (sym.symbol == NULL)
> sym = cp_lookup_symbol_via_all_imports (scope, name, block, domain);
>
> if (symbol_lookup_debug)
> {
> fprintf_unfiltered (gdb_stdlog,
> "cp_lookup_symbol_namespace (...) = %s\n",
> - sym != NULL ? host_address_to_string (sym) : "NULL");
> + sym.symbol != NULL
> + ? host_address_to_string (sym.symbol) : "NULL");
> }
> return sym;
> }
> @@ -782,7 +788,7 @@ cp_lookup_symbol_namespace (const char *scope,
> "A::x", and if that call fails, then the first call looks for
> "x". */
>
> -static struct symbol *
> +static struct symbol_in_block
> lookup_namespace_scope (const struct language_defn *langdef,
> const char *name,
> const struct block *block,
> @@ -796,7 +802,7 @@ lookup_namespace_scope (const struct language_defn *langdef,
> {
> /* Recursively search for names in child namespaces first. */
>
> - struct symbol *sym;
> + struct symbol_in_block sym;
> int new_scope_len = scope_len;
>
> /* If the current scope is followed by "::", skip past that. */
> @@ -808,7 +814,7 @@ lookup_namespace_scope (const struct language_defn *langdef,
> new_scope_len += cp_find_first_component (scope + new_scope_len);
> sym = lookup_namespace_scope (langdef, name, block, domain,
> scope, new_scope_len);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
> }
>
> @@ -839,13 +845,13 @@ lookup_namespace_scope (const struct language_defn *langdef,
> we're looking for, BLOCK is the block that we're searching within,
> DOMAIN says what kind of symbols we're looking for. */
>
> -struct symbol *
> +struct symbol_in_block
> cp_lookup_symbol_nonlocal (const struct language_defn *langdef,
> const char *name,
> const struct block *block,
> const domain_enum domain)
> {
> - struct symbol *sym;
> + struct symbol_in_block sym;
> const char *scope = block_scope (block);
>
> if (symbol_lookup_debug)
> @@ -862,14 +868,15 @@ cp_lookup_symbol_nonlocal (const struct language_defn *langdef,
> sym = lookup_namespace_scope (langdef, name, block, domain, scope, 0);
>
> /* Search for name in namespaces imported to this and parent blocks. */
> - if (sym == NULL)
> + if (sym.symbol == NULL)
> sym = cp_lookup_symbol_via_all_imports (scope, name, block, domain);
>
> if (symbol_lookup_debug)
> {
> fprintf_unfiltered (gdb_stdlog,
> "cp_lookup_symbol_nonlocal (...) = %s\n",
> - sym != NULL ? host_address_to_string (sym) : "NULL");
> + sym.symbol != NULL
> + ? host_address_to_string (sym.symbol) : "NULL");
> }
> return sym;
> }
> @@ -905,17 +912,18 @@ cp_find_type_baseclass_by_name (struct type *parent_type, const char *name)
> /* Search through the base classes of PARENT_TYPE for a symbol named
> NAME in block BLOCK. */
>
> -static struct symbol *
> +static struct symbol_in_block
> find_symbol_in_baseclass (struct type *parent_type, const char *name,
> const struct block *block, const domain_enum domain,
> int is_in_anonymous)
> {
> int i;
> - struct symbol *sym;
> + struct symbol_in_block sym;
> struct cleanup *cleanup;
> char *concatenated_name;
>
> - sym = NULL;
> + sym.symbol = NULL;
> + sym.block = NULL;
> concatenated_name = NULL;
> cleanup = make_cleanup (free_current_contents, &concatenated_name);
>
> @@ -934,7 +942,7 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name,
>
> sym = cp_lookup_nested_symbol_1 (base_type, name, concatenated_name,
> block, domain, 1, is_in_anonymous);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> break;
> }
>
> @@ -954,7 +962,7 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name,
> If IS_IN_ANONYMOUS is non-zero then CONCATENATED_NAME is in an anonymous
> namespace. */
>
> -static struct symbol *
> +static struct symbol_in_block
> cp_lookup_nested_symbol_1 (struct type *container_type,
> const char *nested_name,
> const char *concatenated_name,
> @@ -962,7 +970,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type,
> const domain_enum domain,
> int basic_lookup, int is_in_anonymous)
> {
> - struct symbol *sym;
> + struct symbol_in_block sym;
>
> /* NOTE: carlton/2003-11-10: We don't treat C++ class members
> of classes like, say, data or function members. Instead,
> @@ -975,7 +983,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type,
> {
> sym = cp_basic_lookup_symbol (concatenated_name, block, domain,
> is_in_anonymous);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
> }
>
> @@ -986,7 +994,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type,
>
> /* First search in this symtab, what we want is possibly there. */
> sym = lookup_symbol_in_static_block (concatenated_name, block, domain);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
>
> /* Nope. We now have to search all static blocks in all objfiles,
> @@ -997,7 +1005,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type,
> if (!is_in_anonymous)
> {
> sym = lookup_static_symbol (concatenated_name, domain);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
> }
>
> @@ -1007,11 +1015,11 @@ cp_lookup_nested_symbol_1 (struct type *container_type,
> {
> sym = find_symbol_in_baseclass (container_type, nested_name, block,
> domain, is_in_anonymous);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> return sym;
> }
>
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* Look up a symbol named NESTED_NAME that is nested inside the C++
> @@ -1019,7 +1027,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type,
> given by BLOCK, and in DOMAIN.
> Return NULL if there is no such nested symbol. */
>
> -struct symbol *
> +struct symbol_in_block
> cp_lookup_nested_symbol (struct type *parent_type,
> const char *nested_name,
> const struct block *block,
> @@ -1055,7 +1063,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
> {
> int size;
> const char *parent_name = type_name_no_tag_or_error (saved_parent_type);
> - struct symbol *sym;
> + struct symbol_in_block sym;
> char *concatenated_name;
> int is_in_anonymous;
>
> @@ -1073,8 +1081,9 @@ cp_lookup_nested_symbol (struct type *parent_type,
> {
> fprintf_unfiltered (gdb_stdlog,
> "cp_lookup_nested_symbol (...) = %s\n",
> - sym != NULL
> - ? host_address_to_string (sym) : "NULL");
> + sym.symbol != NULL
> + ? host_address_to_string (sym.symbol)
> + : "NULL");
> }
> return sym;
> }
> @@ -1087,7 +1096,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
> "cp_lookup_nested_symbol (...) = NULL"
> " (func/method)\n");
> }
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
>
> default:
> internal_error (__FILE__, __LINE__,
> diff --git a/gdb/cp-support.c b/gdb/cp-support.c
> index 3db9751..1625d72 100644
> --- a/gdb/cp-support.c
> +++ b/gdb/cp-support.c
> @@ -175,7 +175,7 @@ inspect_type (struct demangle_parse_info *info,
>
> TRY
> {
> - sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
> + sym = lookup_symbol (name, 0, VAR_DOMAIN, 0).symbol;
> }
> CATCH (except, RETURN_MASK_ALL)
> {
> @@ -457,7 +457,7 @@ replace_typedefs (struct demangle_parse_info *info,
> sym = NULL;
> TRY
> {
> - sym = lookup_symbol (local_name, 0, VAR_DOMAIN, 0);
> + sym = lookup_symbol (local_name, 0, VAR_DOMAIN, 0).symbol;
> }
> CATCH (except, RETURN_MASK_ALL)
> {
> @@ -1455,7 +1455,7 @@ cp_lookup_rtti_type (const char *name, struct block *block)
>
> /* Use VAR_DOMAIN here as NAME may be a typedef. PR 18141, 18417.
> Classes "live" in both STRUCT_DOMAIN and VAR_DOMAIN. */
> - rtti_sym = lookup_symbol (name, block, VAR_DOMAIN, NULL);
> + rtti_sym = lookup_symbol (name, block, VAR_DOMAIN, NULL).symbol;
>
> if (rtti_sym == NULL)
> {
> diff --git a/gdb/cp-support.h b/gdb/cp-support.h
> index e92d6e7..4b93f04 100644
> --- a/gdb/cp-support.h
> +++ b/gdb/cp-support.h
> @@ -192,27 +192,29 @@ extern void cp_add_using_directive (const char *dest,
> extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
> struct objfile *objfile);
>
> -extern struct symbol *cp_lookup_symbol_nonlocal
> +extern struct symbol_in_block cp_lookup_symbol_nonlocal
> (const struct language_defn *langdef,
> const char *name,
> const struct block *block,
> const domain_enum domain);
>
> -extern struct symbol *cp_lookup_symbol_namespace (const char *the_namespace,
> - const char *name,
> - const struct block *block,
> - const domain_enum domain);
> +extern struct symbol_in_block
> + cp_lookup_symbol_namespace (const char *the_namespace,
> + const char *name,
> + const struct block *block,
> + const domain_enum domain);
>
> -extern struct symbol *cp_lookup_symbol_imports_or_template
> +extern struct symbol_in_block cp_lookup_symbol_imports_or_template
> (const char *scope,
> const char *name,
> const struct block *block,
> const domain_enum domain);
>
> -extern struct symbol *cp_lookup_nested_symbol (struct type *parent_type,
> - const char *nested_name,
> - const struct block *block,
> - const domain_enum domain);
> +extern struct symbol_in_block
> + cp_lookup_nested_symbol (struct type *parent_type,
> + const char *nested_name,
> + const struct block *block,
> + const domain_enum domain);
>
> struct type *cp_lookup_transparent_type (const char *name);
>
> diff --git a/gdb/d-exp.y b/gdb/d-exp.y
> index 9936b6b..c95222b 100644
> --- a/gdb/d-exp.y
> +++ b/gdb/d-exp.y
> @@ -1022,7 +1022,7 @@ d_type_from_name (struct stoken name)
> char *copy = copy_name (name);
>
> sym = lookup_symbol (copy, expression_context_block,
> - STRUCT_DOMAIN, NULL);
> + STRUCT_DOMAIN, NULL).symbol;
> if (sym != NULL)
> return SYMBOL_TYPE (sym);
>
> @@ -1038,7 +1038,7 @@ d_module_from_name (struct stoken name)
> char *copy = copy_name (name);
>
> sym = lookup_symbol (copy, expression_context_block,
> - MODULE_DOMAIN, NULL);
> + MODULE_DOMAIN, NULL).symbol;
> if (sym != NULL)
> return SYMBOL_TYPE (sym);
>
> @@ -1053,23 +1053,23 @@ push_variable (struct parser_state *ps, struct stoken name)
> {
> char *copy = copy_name (name);
> struct field_of_this_result is_a_field_of_this;
> - struct symbol *sym;
> - sym = lookup_symbol (copy, expression_context_block, VAR_DOMAIN,
> - &is_a_field_of_this);
> - if (sym && SYMBOL_CLASS (sym) != LOC_TYPEDEF)
> + struct symbol_in_block sym
> + = lookup_symbol (copy, expression_context_block, VAR_DOMAIN,
> + &is_a_field_of_this);
> + if (sym.symbol && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
> {
> - if (symbol_read_needs_frame (sym))
> + if (symbol_read_needs_frame (sym.symbol))
> {
> if (innermost_block == 0 ||
> - contained_in (block_found, innermost_block))
> - innermost_block = block_found;
> + contained_in (sym.block, innermost_block))
> + innermost_block = sym.block;
> }
>
> write_exp_elt_opcode (ps, OP_VAR_VALUE);
> /* We want to use the selected frame, not another more inner frame
> which happens to be in the same block. */
> write_exp_elt_block (ps, NULL);
> - write_exp_elt_sym (ps, sym);
> + write_exp_elt_sym (ps, sym.symbol);
> write_exp_elt_opcode (ps, OP_VAR_VALUE);
> return 1;
> }
> @@ -1078,8 +1078,8 @@ push_variable (struct parser_state *ps, struct stoken name)
> /* It hangs off of `this'. Must not inadvertently convert from a
> method call to data ref. */
> if (innermost_block == 0 ||
> - contained_in (block_found, innermost_block))
> - innermost_block = block_found;
> + contained_in (sym.block, innermost_block))
> + innermost_block = sym.block;
> write_exp_elt_opcode (ps, OP_THIS);
> write_exp_elt_opcode (ps, OP_THIS);
> write_exp_elt_opcode (ps, STRUCTOP_PTR);
> @@ -1180,10 +1180,10 @@ push_module_name (struct parser_state *ps, struct type *module,
>
> copy = copy_name (name);
> sym = lookup_symbol_in_static_block (copy, expression_context_block,
> - VAR_DOMAIN);
> + VAR_DOMAIN).symbol;
> if (sym != NULL)
> sym = lookup_global_symbol (copy, expression_context_block,
> - VAR_DOMAIN);
> + VAR_DOMAIN).symbol;
>
> if (sym != NULL)
> {
> diff --git a/gdb/eval.c b/gdb/eval.c
> index 5699aea..f981599 100644
> --- a/gdb/eval.c
> +++ b/gdb/eval.c
> @@ -1492,7 +1492,7 @@ evaluate_subexp_standard (struct type *expect_type,
> function = cp_lookup_symbol_namespace (TYPE_TAG_NAME (type),
> name,
> get_selected_block (0),
> - VAR_DOMAIN);
> + VAR_DOMAIN).symbol;
> if (function == NULL)
> error (_("No symbol \"%s\" in namespace \"%s\"."),
> name, TYPE_TAG_NAME (type));
> diff --git a/gdb/f-exp.y b/gdb/f-exp.y
> index 94494f0..c57f919 100644
> --- a/gdb/f-exp.y
> +++ b/gdb/f-exp.y
> @@ -509,23 +509,23 @@ exp : STRING_LITERAL
> ;
>
> variable: name_not_typename
> - { struct symbol *sym = $1.sym;
> + { struct symbol_in_block sym = $1.sym;
>
> - if (sym)
> + if (sym.symbol)
> {
> - if (symbol_read_needs_frame (sym))
> + if (symbol_read_needs_frame (sym.symbol))
> {
> if (innermost_block == 0
> - || contained_in (block_found,
> + || contained_in (sym.block,
> innermost_block))
> - innermost_block = block_found;
> + innermost_block = sym.block;
> }
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> /* We want to use the selected frame, not
> another more inner frame which happens to
> be in the same block. */
> write_exp_elt_block (pstate, NULL);
> - write_exp_elt_sym (pstate, sym);
> + write_exp_elt_sym (pstate, sym.symbol);
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> break;
> }
> @@ -1198,7 +1198,7 @@ yylex (void)
> The caller is not constrained to care about the distinction. */
> {
> char *tmp = copy_name (yylval.sval);
> - struct symbol *sym;
> + struct symbol_in_block result;
> struct field_of_this_result is_a_field_of_this;
> enum domain_enum_tag lookup_domains[] =
> {
> @@ -1215,17 +1215,18 @@ yylex (void)
> way we can refer to it unconditionally below. */
> memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
>
> - sym = lookup_symbol (tmp, expression_context_block,
> - lookup_domains[i],
> - parse_language (pstate)->la_language
> - == language_cplus ? &is_a_field_of_this : NULL);
> - if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
> + result = lookup_symbol (tmp, expression_context_block,
> + lookup_domains[i],
> + parse_language (pstate)->la_language
> + == language_cplus
> + ? &is_a_field_of_this : NULL);
> + if (result.symbol && SYMBOL_CLASS (result.symbol) == LOC_TYPEDEF)
> {
> - yylval.tsym.type = SYMBOL_TYPE (sym);
> + yylval.tsym.type = SYMBOL_TYPE (result.symbol);
> return TYPENAME;
> }
>
> - if (sym)
> + if (result.symbol)
> break;
> }
>
> @@ -1238,7 +1239,7 @@ yylex (void)
> /* Input names that aren't symbols but ARE valid hex numbers,
> when the input radix permits them, can be names or numbers
> depending on the parse. Note we support radixes > 16 here. */
> - if (!sym
> + if (!result.symbol
> && ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10)
> || (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
> {
> @@ -1246,14 +1247,14 @@ yylex (void)
> hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
> if (hextype == INT)
> {
> - yylval.ssym.sym = sym;
> + yylval.ssym.sym = result;
> yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
> return NAME_OR_INT;
> }
> }
>
> /* Any other kind of symbol */
> - yylval.ssym.sym = sym;
> + yylval.ssym.sym = result;
> yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
> return NAME;
> }
> diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
> index e44fd4f..be761e6 100644
> --- a/gdb/gdbtypes.c
> +++ b/gdb/gdbtypes.c
> @@ -1409,7 +1409,7 @@ lookup_typename (const struct language_defn *language,
> struct type *type;
>
> sym = lookup_symbol_in_language (name, block, VAR_DOMAIN,
> - language->la_language, NULL);
> + language->la_language, NULL).symbol;
> if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
> return SYMBOL_TYPE (sym);
>
> @@ -1453,7 +1453,7 @@ lookup_struct (const char *name, const struct block *block)
> {
> struct symbol *sym;
>
> - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0);
> + sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
>
> if (sym == NULL)
> {
> @@ -1476,7 +1476,7 @@ lookup_union (const char *name, const struct block *block)
> struct symbol *sym;
> struct type *t;
>
> - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0);
> + sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
>
> if (sym == NULL)
> error (_("No union type named %s."), name);
> @@ -1499,7 +1499,7 @@ lookup_enum (const char *name, const struct block *block)
> {
> struct symbol *sym;
>
> - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0);
> + sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
> if (sym == NULL)
> {
> error (_("No enum type named %s."), name);
> @@ -1528,7 +1528,7 @@ lookup_template_type (char *name, struct type *type,
> strcat (nam, TYPE_NAME (type));
> strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */
>
> - sym = lookup_symbol (nam, block, VAR_DOMAIN, 0);
> + sym = lookup_symbol (nam, block, VAR_DOMAIN, 0).symbol;
>
> if (sym == NULL)
> {
> @@ -2245,7 +2245,7 @@ check_typedef (struct type *type)
> stub_noname_complaint ();
> return make_qualified_type (type, instance_flags, NULL);
> }
> - sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0);
> + sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol;
> if (sym)
> TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym);
> else /* TYPE_CODE_UNDEF */
> @@ -2336,7 +2336,7 @@ check_typedef (struct type *type)
> stub_noname_complaint ();
> return make_qualified_type (type, instance_flags, NULL);
> }
> - sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0);
> + sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol;
> if (sym)
> {
> /* Same as above for opaque types, we can replace the stub
> diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
> index e233fe6..85eed70 100644
> --- a/gdb/gnu-v3-abi.c
> +++ b/gdb/gnu-v3-abi.c
> @@ -1063,7 +1063,8 @@ gnuv3_get_typeid_type (struct gdbarch *gdbarch)
> struct symbol *typeinfo;
> struct type *typeinfo_type;
>
> - typeinfo = lookup_symbol ("std::type_info", NULL, STRUCT_DOMAIN, NULL);
> + typeinfo = lookup_symbol ("std::type_info", NULL, STRUCT_DOMAIN,
> + NULL).symbol;
> if (typeinfo == NULL)
> typeinfo_type = gdbarch_data (gdbarch, std_type_info_gdbarch_data);
> else
> diff --git a/gdb/go-exp.y b/gdb/go-exp.y
> index a719d2f..1f43306 100644
> --- a/gdb/go-exp.y
> +++ b/gdb/go-exp.y
> @@ -582,7 +582,7 @@ exp : FALSE_KEYWORD
> ;
>
> variable: name_not_typename ENTRY
> - { struct symbol *sym = $1.sym;
> + { struct symbol *sym = $1.sym.symbol;
>
> if (sym == NULL
> || !SYMBOL_IS_ARGUMENT (sym)
> @@ -598,16 +598,16 @@ variable: name_not_typename ENTRY
> ;
>
> variable: name_not_typename
> - { struct symbol *sym = $1.sym;
> + { struct symbol_in_block sym = $1.sym;
>
> - if (sym)
> + if (sym.symbol)
> {
> - if (symbol_read_needs_frame (sym))
> + if (symbol_read_needs_frame (sym.symbol))
> {
> if (innermost_block == 0
> - || contained_in (block_found,
> + || contained_in (sym.block,
> innermost_block))
> - innermost_block = block_found;
> + innermost_block = sym.block;
> }
>
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> @@ -615,7 +615,7 @@ variable: name_not_typename
> another more inner frame which happens to
> be in the same block. */
> write_exp_elt_block (pstate, NULL);
> - write_exp_elt_sym (pstate, sym);
> + write_exp_elt_sym (pstate, sym.symbol);
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> }
> else if ($1.is_a_field_of_this)
> @@ -1382,7 +1382,7 @@ package_name_p (const char *name, const struct block *block)
> struct symbol *sym;
> struct field_of_this_result is_a_field_of_this;
>
> - sym = lookup_symbol (name, block, STRUCT_DOMAIN, &is_a_field_of_this);
> + sym = lookup_symbol (name, block, STRUCT_DOMAIN, &is_a_field_of_this).symbol;
>
> if (sym
> && SYMBOL_CLASS (sym) == LOC_TYPEDEF
> @@ -1420,14 +1420,14 @@ static int
> classify_packaged_name (const struct block *block)
> {
> char *copy;
> - struct symbol *sym;
> + struct symbol_in_block sym;
> struct field_of_this_result is_a_field_of_this;
>
> copy = copy_name (yylval.sval);
>
> sym = lookup_symbol (copy, block, VAR_DOMAIN, &is_a_field_of_this);
>
> - if (sym)
> + if (sym.symbol)
> {
> yylval.ssym.sym = sym;
> yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
> @@ -1448,7 +1448,7 @@ static int
> classify_name (struct parser_state *par_state, const struct block *block)
> {
> struct type *type;
> - struct symbol *sym;
> + struct symbol_in_block sym;
> char *copy;
> struct field_of_this_result is_a_field_of_this;
>
> @@ -1471,7 +1471,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
>
> sym = lookup_symbol (copy, block, VAR_DOMAIN, &is_a_field_of_this);
>
> - if (sym)
> + if (sym.symbol)
> {
> yylval.ssym.sym = sym;
> yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
> @@ -1496,7 +1496,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
> xfree (current_package_name);
> sym = lookup_symbol (sval.ptr, block, VAR_DOMAIN,
> &is_a_field_of_this);
> - if (sym)
> + if (sym.symbol)
> {
> yylval.ssym.stoken = sval;
> yylval.ssym.sym = sym;
> @@ -1517,13 +1517,15 @@ classify_name (struct parser_state *par_state, const struct block *block)
> 0, &newlval);
> if (hextype == INT)
> {
> - yylval.ssym.sym = NULL;
> + yylval.ssym.sym.symbol = NULL;
> + yylval.ssym.sym.block = NULL;
> yylval.ssym.is_a_field_of_this = 0;
> return NAME_OR_INT;
> }
> }
>
> - yylval.ssym.sym = NULL;
> + yylval.ssym.sym.symbol = NULL;
> + yylval.ssym.sym.block = NULL;
> yylval.ssym.is_a_field_of_this = 0;
> return NAME;
> }
> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index 445a612..9a46242 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -6087,7 +6087,8 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
> CORE_ADDR handler;
> struct breakpoint *bp;
>
> - vsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), b, VAR_DOMAIN, NULL);
> + vsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), b, VAR_DOMAIN,
> + NULL).symbol;
> value = read_var_value (vsym, frame);
> /* If the value was optimized out, revert to the old behavior. */
> if (! value_optimized_out (value))
> diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y
> index 2ed1c17..2e6de6f 100644
> --- a/gdb/jv-exp.y
> +++ b/gdb/jv-exp.y
> @@ -1270,24 +1270,24 @@ push_variable (struct parser_state *par_state, struct stoken name)
> {
> char *tmp = copy_name (name);
> struct field_of_this_result is_a_field_of_this;
> - struct symbol *sym;
> + struct symbol_in_block sym;
>
> sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN,
> &is_a_field_of_this);
> - if (sym && SYMBOL_CLASS (sym) != LOC_TYPEDEF)
> + if (sym.symbol && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
> {
> - if (symbol_read_needs_frame (sym))
> + if (symbol_read_needs_frame (sym.symbol))
> {
> if (innermost_block == 0 ||
> - contained_in (block_found, innermost_block))
> - innermost_block = block_found;
> + contained_in (sym.block, innermost_block))
> + innermost_block = sym.block;
> }
>
> write_exp_elt_opcode (par_state, OP_VAR_VALUE);
> /* We want to use the selected frame, not another more inner frame
> which happens to be in the same block. */
> write_exp_elt_block (par_state, NULL);
> - write_exp_elt_sym (par_state, sym);
> + write_exp_elt_sym (par_state, sym.symbol);
> write_exp_elt_opcode (par_state, OP_VAR_VALUE);
> return 1;
> }
> @@ -1296,8 +1296,8 @@ push_variable (struct parser_state *par_state, struct stoken name)
> /* it hangs off of `this'. Must not inadvertently convert from a
> method call to data ref. */
> if (innermost_block == 0 ||
> - contained_in (block_found, innermost_block))
> - innermost_block = block_found;
> + contained_in (sym.block, innermost_block))
> + innermost_block = sym.block;
> write_exp_elt_opcode (par_state, OP_THIS);
> write_exp_elt_opcode (par_state, OP_THIS);
> write_exp_elt_opcode (par_state, STRUCTOP_PTR);
> diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
> index fee816c..4598942 100644
> --- a/gdb/jv-lang.c
> +++ b/gdb/jv-lang.c
> @@ -202,7 +202,8 @@ java_lookup_class (char *name)
> {
> struct symbol *sym;
>
> - sym = lookup_symbol (name, expression_context_block, STRUCT_DOMAIN, NULL);
> + sym = lookup_symbol (name, expression_context_block, STRUCT_DOMAIN,
> + NULL).symbol;
> if (sym != NULL)
> return SYMBOL_TYPE (sym);
> /* FIXME - should search inferior's symbol table. */
> @@ -590,7 +591,7 @@ get_java_object_type (void)
> {
> struct symbol *sym;
>
> - sym = lookup_symbol ("java.lang.Object", NULL, STRUCT_DOMAIN, NULL);
> + sym = lookup_symbol ("java.lang.Object", NULL, STRUCT_DOMAIN, NULL).symbol;
> if (sym == NULL)
> error (_("cannot find java.lang.Object"));
> return SYMBOL_TYPE (sym);
> diff --git a/gdb/language.c b/gdb/language.c
> index 1e6b983..a8b432e 100644
> --- a/gdb/language.c
> +++ b/gdb/language.c
> @@ -974,7 +974,7 @@ language_bool_type (const struct language_defn *la,
> struct symbol *sym;
>
> sym = lookup_symbol (ld->arch_info[la->la_language].bool_type_symbol,
> - NULL, VAR_DOMAIN, NULL);
> + NULL, VAR_DOMAIN, NULL).symbol;
> if (sym)
> {
> struct type *type = SYMBOL_TYPE (sym);
> @@ -1075,10 +1075,9 @@ language_init_primitive_type_symbols (struct language_arch_info *lai,
> }
>
> /* Note: The result of symbol lookup is normally a symbol *and* the block
> - it was found in (returned in global block_found). Builtin types don't
> - live in blocks. We *could* give them one, but there is no current need
> - so to keep things simple symbol lookup is extended to allow for
> - BLOCK_FOUND to be NULL. */
> + it was found in. Builtin types don't live in blocks. We *could* give
> + them one, but there is no current need so to keep things simple symbol
> + lookup is extended to allow for BLOCK_FOUND to be NULL. */
> }
>
> /* See language.h. */
> diff --git a/gdb/language.h b/gdb/language.h
> index 436fd6e..2675b82 100644
> --- a/gdb/language.h
> +++ b/gdb/language.h
> @@ -267,10 +267,11 @@ struct language_defn
> the part of symbol lookup where C looks up static and global
> variables. */
>
> - struct symbol *(*la_lookup_symbol_nonlocal) (const struct language_defn *,
> - const char *,
> - const struct block *,
> - const domain_enum);
> + struct symbol_in_block (*la_lookup_symbol_nonlocal)
> + (const struct language_defn *,
> + const char *,
> + const struct block *,
> + const domain_enum);
>
> /* Find the definition of the type with the given name. */
> struct type *(*la_lookup_transparent_type) (const char *);
> diff --git a/gdb/linespec.c b/gdb/linespec.c
> index 81f526d..2fe845f 100644
> --- a/gdb/linespec.c
> +++ b/gdb/linespec.c
> @@ -3254,7 +3254,7 @@ find_label_symbols (struct linespec_state *self,
> return NULL;
> fn_sym = BLOCK_FUNCTION (block);
>
> - sym = lookup_symbol (name, block, LABEL_DOMAIN, 0);
> + sym = lookup_symbol (name, block, LABEL_DOMAIN, 0).symbol;
>
> if (sym != NULL)
> {
> @@ -3269,7 +3269,7 @@ find_label_symbols (struct linespec_state *self,
> {
> set_current_program_space (SYMTAB_PSPACE (symbol_symtab (fn_sym)));
> block = SYMBOL_BLOCK_VALUE (fn_sym);
> - sym = lookup_symbol (name, block, LABEL_DOMAIN, 0);
> + sym = lookup_symbol (name, block, LABEL_DOMAIN, 0).symbol;
>
> if (sym != NULL)
> {
> diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
> index 933fa7d..a203218 100644
> --- a/gdb/m2-exp.y
> +++ b/gdb/m2-exp.y
> @@ -564,7 +564,7 @@ fblock : BLOCKNAME
> { struct symbol *sym
> = lookup_symbol (copy_name ($1),
> expression_context_block,
> - VAR_DOMAIN, 0);
> + VAR_DOMAIN, 0).symbol;
> $$ = sym;}
> ;
>
> @@ -573,7 +573,7 @@ fblock : BLOCKNAME
> fblock : block COLONCOLON BLOCKNAME
> { struct symbol *tem
> = lookup_symbol (copy_name ($3), $1,
> - VAR_DOMAIN, 0);
> + VAR_DOMAIN, 0).symbol;
> if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
> error (_("No function \"%s\" in specified context."),
> copy_name ($3));
> @@ -595,44 +595,44 @@ variable: INTERNAL_VAR
>
> /* GDB scope operator */
> variable: block COLONCOLON NAME
> - { struct symbol *sym;
> - sym = lookup_symbol (copy_name ($3), $1,
> - VAR_DOMAIN, 0);
> - if (sym == 0)
> + { struct symbol_in_block sym
> + = lookup_symbol (copy_name ($3), $1,
> + VAR_DOMAIN, 0);
> + if (sym.symbol == 0)
> error (_("No symbol \"%s\" in specified context."),
> copy_name ($3));
> - if (symbol_read_needs_frame (sym))
> + if (symbol_read_needs_frame (sym.symbol))
> {
> if (innermost_block == 0
> - || contained_in (block_found,
> + || contained_in (sym.block,
> innermost_block))
> - innermost_block = block_found;
> + innermost_block = sym.block;
> }
>
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> - /* block_found is set by lookup_symbol. */
> - write_exp_elt_block (pstate, block_found);
> - write_exp_elt_sym (pstate, sym);
> + write_exp_elt_block (pstate, sym.block);
> + write_exp_elt_sym (pstate, sym.symbol);
> write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
> ;
>
> /* Base case for variables. */
> variable: NAME
> - { struct symbol *sym;
> + { struct symbol_in_block sym;
> struct field_of_this_result is_a_field_of_this;
>
> - sym = lookup_symbol (copy_name ($1),
> + sym = lookup_symbol (copy_name ($1),
> expression_context_block,
> VAR_DOMAIN,
> &is_a_field_of_this);
> - if (sym)
> +
> + if (sym.symbol)
> {
> - if (symbol_read_needs_frame (sym))
> + if (symbol_read_needs_frame (sym.symbol))
> {
> if (innermost_block == 0 ||
> - contained_in (block_found,
> + contained_in (sym.block,
> innermost_block))
> - innermost_block = block_found;
> + innermost_block = sym.block;
> }
>
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> @@ -640,7 +640,7 @@ variable: NAME
> another more inner frame which happens to
> be in the same block. */
> write_exp_elt_block (pstate, NULL);
> - write_exp_elt_sym (pstate, sym);
> + write_exp_elt_sym (pstate, sym.symbol);
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> }
> else
> @@ -1028,7 +1028,7 @@ yylex (void)
>
> if (lookup_symtab (tmp))
> return BLOCKNAME;
> - sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, 0);
> + sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, 0).symbol;
> if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
> return BLOCKNAME;
> if (lookup_typename (parse_language (pstate), parse_gdbarch (pstate),
> diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
> index 1b863eb..51a8ae6 100644
> --- a/gdb/mi/mi-cmd-stack.c
> +++ b/gdb/mi/mi-cmd-stack.c
> @@ -648,7 +648,7 @@ list_args_or_locals (enum what_to_list what, enum print_values values,
> if (SYMBOL_IS_ARGUMENT (sym))
> sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
> block, VAR_DOMAIN,
> - NULL);
> + NULL).symbol;
> else
> sym2 = sym;
> gdb_assert (sym2 != NULL);
> diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
> index 0d1d96b..661d22f 100644
> --- a/gdb/objc-lang.c
> +++ b/gdb/objc-lang.c
> @@ -85,7 +85,7 @@ lookup_struct_typedef (char *name, const struct block *block, int noerr)
> {
> struct symbol *sym;
>
> - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0);
> + sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
>
> if (sym == NULL)
> {
> @@ -1144,7 +1144,8 @@ find_imps (const char *method, VEC (const_char_ptr) **symbol_names)
> add the selector itself as a symbol, if it exists. */
> if (selector_case && !VEC_empty (const_char_ptr, *symbol_names))
> {
> - struct symbol *sym = lookup_symbol (selector, NULL, VAR_DOMAIN, 0);
> + struct symbol *sym = lookup_symbol (selector, NULL, VAR_DOMAIN,
> + 0).symbol;
>
> if (sym != NULL)
> VEC_safe_push (const_char_ptr, *symbol_names,
> diff --git a/gdb/p-exp.y b/gdb/p-exp.y
> index 5d5c22b..a2f86d6 100644
> --- a/gdb/p-exp.y
> +++ b/gdb/p-exp.y
> @@ -668,8 +668,8 @@ exp : THIS
>
> block : BLOCKNAME
> {
> - if ($1.sym != 0)
> - $$ = SYMBOL_BLOCK_VALUE ($1.sym);
> + if ($1.sym.symbol != 0)
> + $$ = SYMBOL_BLOCK_VALUE ($1.sym.symbol);
> else
> {
> struct symtab *tem =
> @@ -687,7 +687,7 @@ block : BLOCKNAME
> block : block COLONCOLON name
> { struct symbol *tem
> = lookup_symbol (copy_name ($3), $1,
> - VAR_DOMAIN, NULL);
> + VAR_DOMAIN, NULL).symbol;
> if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
> error (_("No function \"%s\" in specified context."),
> copy_name ($3));
> @@ -695,17 +695,16 @@ block : block COLONCOLON name
> ;
>
> variable: block COLONCOLON name
> - { struct symbol *sym;
> + { struct symbol_in_block sym;
> sym = lookup_symbol (copy_name ($3), $1,
> VAR_DOMAIN, NULL);
> - if (sym == 0)
> + if (sym.symbol == 0)
> error (_("No symbol \"%s\" in specified context."),
> copy_name ($3));
>
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> - /* block_found is set by lookup_symbol. */
> - write_exp_elt_block (pstate, block_found);
> - write_exp_elt_sym (pstate, sym);
> + write_exp_elt_block (pstate, sym.block);
> + write_exp_elt_sym (pstate, sym.symbol);
> write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
> ;
>
> @@ -733,7 +732,7 @@ variable: qualified_name
>
> sym =
> lookup_symbol (name, (const struct block *) NULL,
> - VAR_DOMAIN, NULL);
> + VAR_DOMAIN, NULL).symbol;
> if (sym)
> {
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> @@ -757,16 +756,16 @@ variable: qualified_name
> ;
>
> variable: name_not_typename
> - { struct symbol *sym = $1.sym;
> + { struct symbol_in_block sym = $1.sym;
>
> - if (sym)
> + if (sym.symbol)
> {
> - if (symbol_read_needs_frame (sym))
> + if (symbol_read_needs_frame (sym.symbol))
> {
> if (innermost_block == 0
> - || contained_in (block_found,
> + || contained_in (sym.block,
> innermost_block))
> - innermost_block = block_found;
> + innermost_block = sym.block;
> }
>
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> @@ -774,9 +773,9 @@ variable: name_not_typename
> another more inner frame which happens to
> be in the same block. */
> write_exp_elt_block (pstate, NULL);
> - write_exp_elt_sym (pstate, sym);
> + write_exp_elt_sym (pstate, sym.symbol);
> write_exp_elt_opcode (pstate, OP_VAR_VALUE);
> - current_type = sym->type; }
> + current_type = sym.symbol->type; }
> else if ($1.is_a_field_of_this)
> {
> struct value * this_val;
> @@ -785,9 +784,9 @@ variable: name_not_typename
> not inadvertently convert from a method call
> to data ref. */
> if (innermost_block == 0
> - || contained_in (block_found,
> + || contained_in (sym.block,
> innermost_block))
> - innermost_block = block_found;
> + innermost_block = sym.block;
> write_exp_elt_opcode (pstate, OP_THIS);
> write_exp_elt_opcode (pstate, OP_THIS);
> write_exp_elt_opcode (pstate, STRUCTOP_PTR);
> @@ -1508,7 +1507,7 @@ yylex (void)
> static const char this_name[] = "this";
>
> if (lookup_symbol (this_name, expression_context_block,
> - VAR_DOMAIN, NULL))
> + VAR_DOMAIN, NULL).symbol)
> {
> free (uptokstart);
> return THIS;
> @@ -1558,7 +1557,7 @@ yylex (void)
> sym = NULL;
> else
> sym = lookup_symbol (tmp, expression_context_block,
> - VAR_DOMAIN, &is_a_field_of_this);
> + VAR_DOMAIN, &is_a_field_of_this).symbol;
> /* second chance uppercased (as Free Pascal does). */
> if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
> {
> @@ -1573,7 +1572,7 @@ yylex (void)
> sym = NULL;
> else
> sym = lookup_symbol (tmp, expression_context_block,
> - VAR_DOMAIN, &is_a_field_of_this);
> + VAR_DOMAIN, &is_a_field_of_this).symbol;
> }
> /* Third chance Capitalized (as GPC does). */
> if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
> @@ -1595,7 +1594,7 @@ yylex (void)
> sym = NULL;
> else
> sym = lookup_symbol (tmp, expression_context_block,
> - VAR_DOMAIN, &is_a_field_of_this);
> + VAR_DOMAIN, &is_a_field_of_this).symbol;
> }
>
> if (is_a_field || (is_a_field_of_this.type != NULL))
> @@ -1605,7 +1604,8 @@ yylex (void)
> tempbuf [namelen] = 0;
> yylval.sval.ptr = tempbuf;
> yylval.sval.length = namelen;
> - yylval.ssym.sym = NULL;
> + yylval.ssym.sym.symbol = NULL;
> + yylval.ssym.sym.block = NULL;
> free (uptokstart);
> yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
> if (is_a_field)
> @@ -1619,7 +1619,8 @@ yylex (void)
> if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
> || lookup_symtab (tmp))
> {
> - yylval.ssym.sym = sym;
> + yylval.ssym.sym.symbol = sym;
> + yylval.ssym.sym.block = NULL;
> yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
> free (uptokstart);
> return BLOCKNAME;
> @@ -1686,7 +1687,7 @@ yylex (void)
> memcpy (tmp1, namestart, p - namestart);
> tmp1[p - namestart] = '\0';
> cur_sym = lookup_symbol (ncopy, expression_context_block,
> - VAR_DOMAIN, NULL);
> + VAR_DOMAIN, NULL).symbol;
> if (cur_sym)
> {
> if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
> @@ -1734,7 +1735,8 @@ yylex (void)
> hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
> if (hextype == INT)
> {
> - yylval.ssym.sym = sym;
> + yylval.ssym.sym.symbol = sym;
> + yylval.ssym.sym.block = NULL;
> yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
> free (uptokstart);
> return NAME_OR_INT;
> @@ -1743,7 +1745,8 @@ yylex (void)
>
> free(uptokstart);
> /* Any other kind of symbol. */
> - yylval.ssym.sym = sym;
> + yylval.ssym.sym.symbol = sym;
> + yylval.ssym.sym.block = NULL;
> return NAME;
> }
> }
> diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
> index f736a79..a0b99f8 100644
> --- a/gdb/p-valprint.c
> +++ b/gdb/p-valprint.c
> @@ -250,7 +250,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
> if (msymbol.minsym != NULL)
> wsym = lookup_symbol (MSYMBOL_LINKAGE_NAME (msymbol.minsym),
> block,
> - VAR_DOMAIN, &is_this_fld);
> + VAR_DOMAIN, &is_this_fld).symbol;
>
> if (wsym)
> {
> diff --git a/gdb/parse.c b/gdb/parse.c
> index 6b59c4f..7bcf6c0 100644
> --- a/gdb/parse.c
> +++ b/gdb/parse.c
> @@ -615,7 +615,7 @@ mark_completion_tag (enum type_code tag, const char *ptr, int length)
> void
> write_dollar_variable (struct parser_state *ps, struct stoken str)
> {
> - struct symbol *sym = NULL;
> + struct symbol_in_block sym;
> struct bound_minimal_symbol msym;
> struct internalvar *isym = NULL;
>
> @@ -672,11 +672,11 @@ write_dollar_variable (struct parser_state *ps, struct stoken str)
>
> sym = lookup_symbol (copy_name (str), (struct block *) NULL,
> VAR_DOMAIN, NULL);
> - if (sym)
> + if (sym.symbol)
> {
> write_exp_elt_opcode (ps, OP_VAR_VALUE);
> - write_exp_elt_block (ps, block_found); /* set by lookup_symbol */
> - write_exp_elt_sym (ps, sym);
> + write_exp_elt_block (ps, sym.block);
> + write_exp_elt_sym (ps, sym.symbol);
> write_exp_elt_opcode (ps, OP_VAR_VALUE);
> return;
> }
> diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
> index a377ec3..d7babe0 100644
> --- a/gdb/parser-defs.h
> +++ b/gdb/parser-defs.h
> @@ -106,7 +106,7 @@ struct ttype
> struct symtoken
> {
> struct stoken stoken;
> - struct symbol *sym;
> + struct symbol_in_block sym;
> int is_a_field_of_this;
> };
>
> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
> index a739a89..f51e25c 100644
> --- a/gdb/printcmd.c
> +++ b/gdb/printcmd.c
> @@ -1208,7 +1208,7 @@ address_info (char *exp, int from_tty)
> error (_("Argument required."));
>
> sym = lookup_symbol (exp, get_selected_block (&context_pc), VAR_DOMAIN,
> - &is_a_field_of_this);
> + &is_a_field_of_this).symbol;
> if (sym == NULL)
> {
> if (is_a_field_of_this.type != NULL)
> diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
> index cd6e859..7290056 100644
> --- a/gdb/python/py-frame.c
> +++ b/gdb/python/py-frame.c
> @@ -540,7 +540,7 @@ frapy_read_var (PyObject *self, PyObject *args)
>
> if (!block)
> block = get_frame_block (frame, NULL);
> - var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL);
> + var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL).symbol;
> }
> CATCH (except, RETURN_MASK_ALL)
> {
> diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
> index 4306f61..401e7e9 100644
> --- a/gdb/python/py-symbol.c
> +++ b/gdb/python/py-symbol.c
> @@ -396,7 +396,7 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
>
> TRY
> {
> - symbol = lookup_symbol (name, block, domain, &is_a_field_of_this);
> + symbol = lookup_symbol (name, block, domain, &is_a_field_of_this).symbol;
> }
> CATCH (except, RETURN_MASK_ALL)
> {
> @@ -449,7 +449,7 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
>
> TRY
> {
> - symbol = lookup_global_symbol (name, NULL, domain);
> + symbol = lookup_global_symbol (name, NULL, domain).symbol;
> }
> CATCH (except, RETURN_MASK_ALL)
> {
> diff --git a/gdb/skip.c b/gdb/skip.c
> index ba38194..a1cdd72 100644
> --- a/gdb/skip.c
> +++ b/gdb/skip.c
> @@ -131,7 +131,7 @@ skip_function_command (char *arg, int from_tty)
> }
> else
> {
> - if (lookup_symbol (arg, NULL, VAR_DOMAIN, NULL) == NULL)
> + if (lookup_symbol (arg, NULL, VAR_DOMAIN, NULL).symbol == NULL)
> {
> fprintf_filtered (gdb_stderr,
> _("No function found named %s.\n"), arg);
> diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
> index f96841f..0249049 100644
> --- a/gdb/solib-darwin.c
> +++ b/gdb/solib-darwin.c
> @@ -569,12 +569,12 @@ darwin_relocate_section_addresses (struct so_list *so,
> so->addr_low = sec->addr;
> }
>
> -static struct symbol *
> +static struct symbol_in_block
> darwin_lookup_lib_symbol (struct objfile *objfile,
> const char *name,
> const domain_enum domain)
> {
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> static bfd *
> diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c
> index 44fbf91..d0d2a3b 100644
> --- a/gdb/solib-spu.c
> +++ b/gdb/solib-spu.c
> @@ -389,7 +389,7 @@ spu_bfd_open (char *pathname)
> }
>
> /* Lookup global symbol in a SPE executable. */
> -static struct symbol *
> +static struct symbol_in_block
> spu_lookup_lib_symbol (struct objfile *objfile,
> const char *name,
> const domain_enum domain)
> @@ -399,7 +399,7 @@ spu_lookup_lib_symbol (struct objfile *objfile,
>
> if (svr4_so_ops.lookup_lib_global_symbol != NULL)
> return svr4_so_ops.lookup_lib_global_symbol (objfile, name, domain);
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* Enable shared library breakpoint. */
> diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
> index 909dfb7..a5c84e8 100644
> --- a/gdb/solib-svr4.c
> +++ b/gdb/solib-svr4.c
> @@ -3211,7 +3211,7 @@ struct target_so_ops svr4_so_ops;
> different rule for symbol lookup. The lookup begins here in the DSO, not in
> the main executable. */
>
> -static struct symbol *
> +static struct symbol_in_block
> elf_lookup_lib_symbol (struct objfile *objfile,
> const char *name,
> const domain_enum domain)
> @@ -3229,7 +3229,7 @@ elf_lookup_lib_symbol (struct objfile *objfile,
> }
>
> if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL) != 1)
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
>
> return lookup_global_symbol_from_objfile (objfile, name, domain);
> }
> diff --git a/gdb/solib.c b/gdb/solib.c
> index eb933c0..9b313fd 100644
> --- a/gdb/solib.c
> +++ b/gdb/solib.c
> @@ -1511,7 +1511,7 @@ show_auto_solib_add (struct ui_file *file, int from_tty,
> /* Handler for library-specific lookup of global symbol NAME in OBJFILE. Call
> the library-specific handler if it is installed for the current target. */
>
> -struct symbol *
> +struct symbol_in_block
> solib_global_lookup (struct objfile *objfile,
> const char *name,
> const domain_enum domain)
> @@ -1520,7 +1520,7 @@ solib_global_lookup (struct objfile *objfile,
>
> if (ops->lookup_lib_global_symbol != NULL)
> return ops->lookup_lib_global_symbol (objfile, name, domain);
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* Lookup the value for a specific symbol from dynamic symbol table. Look
> diff --git a/gdb/solist.h b/gdb/solist.h
> index 7021f5c..3031831 100644
> --- a/gdb/solist.h
> +++ b/gdb/solist.h
> @@ -137,9 +137,10 @@ struct target_so_ops
> unsigned o_flags, char **temp_pathname);
>
> /* Hook for looking up global symbols in a library-specific way. */
> - struct symbol * (*lookup_lib_global_symbol) (struct objfile *objfile,
> - const char *name,
> - const domain_enum domain);
> + struct symbol_in_block (*lookup_lib_global_symbol)
> + (struct objfile *objfile,
> + const char *name,
> + const domain_enum domain);
>
> /* Given two so_list objects, one from the GDB thread list
> and another from the list returned by current_sos, return 1
> @@ -192,8 +193,8 @@ extern bfd *solib_bfd_open (char *in_pathname);
> extern struct target_so_ops *current_target_so_ops;
>
> /* Handler for library-specific global symbol lookup in solib.c. */
> -struct symbol *solib_global_lookup (struct objfile *objfile,
> - const char *name,
> - const domain_enum domain);
> +struct symbol_in_block solib_global_lookup (struct objfile *objfile,
> + const char *name,
> + const domain_enum domain);
>
> #endif
> diff --git a/gdb/source.c b/gdb/source.c
> index fbec0f1..0c23b7e 100644
> --- a/gdb/source.c
> +++ b/gdb/source.c
> @@ -274,7 +274,7 @@ select_source_symtab (struct symtab *s)
>
> /* Make the default place to list be the function `main'
> if one exists. */
> - if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0))
> + if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0).symbol)
> {
> sals = decode_line_with_current_source (main_name (),
> DECODE_LINE_FUNFIRSTLINE);
> diff --git a/gdb/stack.c b/gdb/stack.c
> index 4878825..b4cfdbd 100644
> --- a/gdb/stack.c
> +++ b/gdb/stack.c
> @@ -621,7 +621,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
> struct symbol *nsym;
>
> nsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
> - b, VAR_DOMAIN, NULL);
> + b, VAR_DOMAIN, NULL).symbol;
> gdb_assert (nsym != NULL);
> if (SYMBOL_CLASS (nsym) == LOC_REGISTER
> && !SYMBOL_IS_ARGUMENT (nsym))
> @@ -2156,7 +2156,7 @@ iterate_over_block_arg_vars (const struct block *b,
> are not combined in symbol-reading. */
>
> sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
> - b, VAR_DOMAIN, NULL);
> + b, VAR_DOMAIN, NULL).symbol;
> (*cb) (SYMBOL_PRINT_NAME (sym), sym2, cb_data);
> }
> }
> diff --git a/gdb/symfile.c b/gdb/symfile.c
> index 0c35ffa..856572a 100644
> --- a/gdb/symfile.c
> +++ b/gdb/symfile.c
> @@ -1696,7 +1696,7 @@ set_initial_language (void)
> if (lang == language_unknown)
> {
> char *name = main_name ();
> - struct symbol *sym = lookup_symbol (name, NULL, VAR_DOMAIN, NULL);
> + struct symbol *sym = lookup_symbol (name, NULL, VAR_DOMAIN, NULL).symbol;
>
> if (sym != NULL)
> lang = SYMBOL_LANGUAGE (sym);
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index decc5a9..e66ef14 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -68,19 +68,20 @@ static void rbreak_command (char *, int);
>
> static int find_line_common (struct linetable *, int, int *, int);
>
> -static struct symbol *lookup_symbol_aux (const char *name,
> - const struct block *block,
> - const domain_enum domain,
> - enum language language,
> - struct field_of_this_result *);
> +static struct symbol_in_block
> + lookup_symbol_aux (const char *name,
> + const struct block *block,
> + const domain_enum domain,
> + enum language language,
> + struct field_of_this_result *);
>
> static
> -struct symbol *lookup_local_symbol (const char *name,
> - const struct block *block,
> - const domain_enum domain,
> - enum language language);
> +struct symbol_in_block lookup_local_symbol (const char *name,
> + const struct block *block,
> + const domain_enum domain,
> + enum language language);
>
> -static struct symbol *
> +static struct symbol_in_block
> lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
> const char *name, const domain_enum domain);
>
> @@ -121,7 +122,9 @@ static const struct program_space_data *symbol_cache_key;
>
> /* symbol_cache_lookup returns this if a previous lookup failed to find the
> symbol in any objfile. */
> -#define SYMBOL_LOOKUP_FAILED ((struct symbol *) 1)
> +#define SYMBOL_LOOKUP_FAILED \
> + ((struct symbol_in_block) {(struct symbol *) 1, NULL})
> +#define SYMBOL_LOOKUP_FAILED_P(SIB) (SIB.symbol == (struct symbol *) 1)
>
> /* Recording lookups that don't find the symbol is just as important, if not
> more so, than recording found symbols. */
> @@ -157,7 +160,7 @@ struct symbol_cache_slot
>
> union
> {
> - struct symbol *found;
> + struct symbol_in_block found;
> struct
> {
> char *name;
> @@ -243,12 +246,6 @@ multiple_symbols_select_mode (void)
> return multiple_symbols_mode;
> }
>
> -/* Block in which the most recently searched-for symbol was found.
> - Might be better to make this a parameter to lookup_symbol and
> - value_of_this. */
> -
> -const struct block *block_found;
> -
> /* Return the name of a domain_enum. */
>
> const char *
> @@ -1208,8 +1205,8 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
> }
> else
> {
> - slot_name = SYMBOL_SEARCH_NAME (slot->value.found);
> - slot_domain = SYMBOL_DOMAIN (slot->value.found);
> + slot_name = SYMBOL_SEARCH_NAME (slot->value.found.symbol);
> + slot_domain = SYMBOL_DOMAIN (slot->value.found.symbol);
> }
>
> /* NULL names match. */
> @@ -1240,7 +1237,7 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
> }
> else
> {
> - struct symbol *sym = slot->value.found;
> + struct symbol *sym = slot->value.found.symbol;
>
> if (strcmp_iw (slot_name, name) != 0)
> return 0;
> @@ -1398,7 +1395,7 @@ set_symbol_cache_size_handler (char *args, int from_tty,
> set to the cache and slot of the symbol to save the result of a full lookup
> attempt. */
>
> -static struct symbol *
> +static struct symbol_in_block
> symbol_cache_lookup (struct symbol_cache *cache,
> struct objfile *objfile_context, int block,
> const char *name, domain_enum domain,
> @@ -1417,7 +1414,7 @@ symbol_cache_lookup (struct symbol_cache *cache,
> {
> *bsc_ptr = NULL;
> *slot_ptr = NULL;
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> hash = hash_symbol_entry (objfile_context, name, domain);
> @@ -1451,7 +1448,7 @@ symbol_cache_lookup (struct symbol_cache *cache,
> name, domain_name (domain));
> }
> ++bsc->misses;
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* Clear out SLOT. */
> @@ -1473,7 +1470,8 @@ static void
> symbol_cache_mark_found (struct block_symbol_cache *bsc,
> struct symbol_cache_slot *slot,
> struct objfile *objfile_context,
> - struct symbol *symbol)
> + struct symbol *symbol,
> + const struct block *block)
> {
> if (bsc == NULL)
> return;
> @@ -1484,7 +1482,8 @@ symbol_cache_mark_found (struct block_symbol_cache *bsc,
> }
> slot->state = SYMBOL_SLOT_FOUND;
> slot->objfile_context = objfile_context;
> - slot->value.found = symbol;
> + slot->value.found.symbol = symbol;
> + slot->value.found.block = block;
> }
>
> /* Mark symbol NAME, DOMAIN as not found in SLOT.
> @@ -1597,11 +1596,16 @@ symbol_cache_dump (const struct symbol_cache *cache)
> domain_name (slot->value.not_found.domain));
> break;
> case SYMBOL_SLOT_FOUND:
> - printf_filtered (" [%4u] = %s, %s %s\n", i,
> - host_address_to_string (slot->objfile_context),
> - SYMBOL_PRINT_NAME (slot->value.found),
> - domain_name (SYMBOL_DOMAIN (slot->value.found)));
> - break;
> + {
> + struct symbol *found = slot->value.found.symbol;
> + const struct objfile *context = slot->objfile_context;
> +
> + printf_filtered (" [%4u] = %s, %s %s\n", i,
> + host_address_to_string (context),
> + SYMBOL_PRINT_NAME (found),
> + domain_name (SYMBOL_DOMAIN (found)));
> + break;
> + }
> }
> }
> }
> @@ -1945,13 +1949,13 @@ demangle_for_lookup (const char *name, enum language lang,
> variable and thus can probably assume it will never hit the C++
> code). */
>
> -struct symbol *
> +struct symbol_in_block
> lookup_symbol_in_language (const char *name, const struct block *block,
> const domain_enum domain, enum language lang,
> struct field_of_this_result *is_a_field_of_this)
> {
> const char *modified_name;
> - struct symbol *returnval;
> + struct symbol_in_block returnval;
> struct cleanup *cleanup = demangle_for_lookup (name, lang, &modified_name);
>
> returnval = lookup_symbol_aux (modified_name, block, domain, lang,
> @@ -1963,7 +1967,7 @@ lookup_symbol_in_language (const char *name, const struct block *block,
>
> /* See symtab.h. */
>
> -struct symbol *
> +struct symbol_in_block
> lookup_symbol (const char *name, const struct block *block,
> domain_enum domain,
> struct field_of_this_result *is_a_field_of_this)
> @@ -1975,12 +1979,12 @@ lookup_symbol (const char *name, const struct block *block,
>
> /* See symtab.h. */
>
> -struct symbol *
> +struct symbol_in_block
> lookup_language_this (const struct language_defn *lang,
> const struct block *block)
> {
> if (lang->la_name_of_this == NULL || block == NULL)
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
>
> if (symbol_lookup_debug > 1)
> {
> @@ -2006,8 +2010,7 @@ lookup_language_this (const struct language_defn *lang,
> host_address_to_string (sym),
> host_address_to_string (block));
> }
> - block_found = block;
> - return sym;
> + return (struct symbol_in_block) {sym, block};
> }
> if (BLOCK_FUNCTION (block))
> break;
> @@ -2016,7 +2019,7 @@ lookup_language_this (const struct language_defn *lang,
>
> if (symbol_lookup_debug > 1)
> fprintf_unfiltered (gdb_stdlog, " = NULL\n");
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* Given TYPE, a structure/union,
> @@ -2067,12 +2070,12 @@ check_field (struct type *type, const char *name,
> /* Behave like lookup_symbol except that NAME is the natural name
> (e.g., demangled name) of the symbol that we're looking for. */
>
> -static struct symbol *
> +static struct symbol_in_block
> lookup_symbol_aux (const char *name, const struct block *block,
> const domain_enum domain, enum language language,
> struct field_of_this_result *is_a_field_of_this)
> {
> - struct symbol *sym;
> + struct symbol_in_block result;
> const struct language_defn *langdef;
>
> if (symbol_lookup_debug)
> @@ -2087,13 +2090,6 @@ lookup_symbol_aux (const char *name, const struct block *block,
> domain_name (domain), language_str (language));
> }
>
> - /* Initialize block_found so that the language la_lookup_symbol_nonlocal
> - routines don't have to set it (to NULL) if a primitive type is found.
> - We do this early so that block_found is also NULL if no symbol is
> - found (though this is not part of the API, and callers cannot assume
> - this). */
> - block_found = NULL;
> -
> /* Make sure we do something sensible with is_a_field_of_this, since
> the callers that set this parameter to some non-null value will
> certainly use it later. If we don't set it, the contents of
> @@ -2104,15 +2100,15 @@ lookup_symbol_aux (const char *name, const struct block *block,
> /* Search specified block and its superiors. Don't search
> STATIC_BLOCK or GLOBAL_BLOCK. */
>
> - sym = lookup_local_symbol (name, block, domain, language);
> - if (sym != NULL)
> + result = lookup_local_symbol (name, block, domain, language);
> + if (result.symbol != NULL)
> {
> if (symbol_lookup_debug)
> {
> fprintf_unfiltered (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
> - host_address_to_string (sym));
> + host_address_to_string (result.symbol));
> }
> - return sym;
> + return result;
> }
>
> /* If requested to do so by the caller and if appropriate for LANGUAGE,
> @@ -2125,11 +2121,11 @@ lookup_symbol_aux (const char *name, const struct block *block,
> means. */
> if (is_a_field_of_this != NULL && domain != STRUCT_DOMAIN)
> {
> - struct symbol *sym = lookup_language_this (langdef, block);
> + result = lookup_language_this (langdef, block);
>
> - if (sym)
> + if (result.symbol)
> {
> - struct type *t = sym->type;
> + struct type *t = result.symbol->type;
>
> /* I'm not really sure that type of this can ever
> be typedefed; just be safe. */
> @@ -2150,7 +2146,7 @@ lookup_symbol_aux (const char *name, const struct block *block,
> fprintf_unfiltered (gdb_stdlog,
> "lookup_symbol_aux (...) = NULL\n");
> }
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
> }
> }
> @@ -2158,33 +2154,35 @@ lookup_symbol_aux (const char *name, const struct block *block,
> /* Now do whatever is appropriate for LANGUAGE to look
> up static and global variables. */
>
> - sym = langdef->la_lookup_symbol_nonlocal (langdef, name, block, domain);
> - if (sym != NULL)
> + result = langdef->la_lookup_symbol_nonlocal (langdef, name, block, domain);
> + if (result.symbol != NULL)
> {
> if (symbol_lookup_debug)
> {
> fprintf_unfiltered (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
> - host_address_to_string (sym));
> + host_address_to_string (result.symbol));
> }
> - return sym;
> + return result;
> }
>
> /* Now search all static file-level symbols. Not strictly correct,
> but more useful than an error. */
>
> - sym = lookup_static_symbol (name, domain);
> + result = lookup_static_symbol (name, domain);
> if (symbol_lookup_debug)
> {
> fprintf_unfiltered (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
> - sym != NULL ? host_address_to_string (sym) : "NULL");
> + result.symbol != NULL
> + ? host_address_to_string (result.symbol)
> + : "NULL");
> }
> - return sym;
> + return result;
> }
>
> /* Check to see if the symbol is defined in BLOCK or its superiors.
> Don't search STATIC_BLOCK or GLOBAL_BLOCK. */
>
> -static struct symbol *
> +static struct symbol_in_block
> lookup_local_symbol (const char *name, const struct block *block,
> const domain_enum domain,
> enum language language)
> @@ -2196,19 +2194,20 @@ lookup_local_symbol (const char *name, const struct block *block,
> /* Check if either no block is specified or it's a global block. */
>
> if (static_block == NULL)
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
>
> while (block != static_block)
> {
> sym = lookup_symbol_in_block (name, block, domain);
> if (sym != NULL)
> - return sym;
> + return (struct symbol_in_block) {sym, block};
>
> if (language == language_cplus || language == language_fortran)
> {
> - sym = cp_lookup_symbol_imports_or_template (scope, name, block,
> - domain);
> - if (sym != NULL)
> + struct symbol_in_block sym
> + = cp_lookup_symbol_imports_or_template (scope, name, block,
> + domain);
====
Coding conventions require a blank line here.
I think a saw a few more places like this.
[blank line after local variable definitions]
> + if (sym.symbol != NULL)
> return sym;
> }
>
> @@ -2219,7 +2218,7 @@ lookup_local_symbol (const char *name, const struct block *block,
>
> /* We've reached the end of the function without finding a result. */
>
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* See symtab.h. */
> @@ -2275,7 +2274,6 @@ lookup_symbol_in_block (const char *name, const struct block *block,
> fprintf_unfiltered (gdb_stdlog, " = %s\n",
> host_address_to_string (sym));
> }
> - block_found = block;
> return fixup_symbol_section (sym, NULL);
> }
>
> @@ -2286,7 +2284,7 @@ lookup_symbol_in_block (const char *name, const struct block *block,
>
> /* See symtab.h. */
>
> -struct symbol *
> +struct symbol_in_block
> lookup_global_symbol_from_objfile (struct objfile *main_objfile,
> const char *name,
> const domain_enum domain)
> @@ -2297,14 +2295,14 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
> objfile;
> objfile = objfile_separate_debug_iterate (main_objfile, objfile))
> {
> - struct symbol *sym = lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK,
> - name, domain);
> + struct symbol_in_block result
> + = lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK, name, domain);
>
> - if (sym != NULL)
> - return sym;
> + if (result.symbol != NULL)
> + return result;
> }
>
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* Check to see if the symbol is defined in one of the OBJFILE's
> @@ -2312,7 +2310,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
> depending on whether or not we want to search global symbols or
> static symbols. */
>
> -static struct symbol *
> +static struct symbol_in_block
> lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
> const char *name, const domain_enum domain)
> {
> @@ -2334,27 +2332,29 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
> {
> const struct blockvector *bv;
> const struct block *block;
> - struct symbol *sym;
> + struct symbol_in_block result;
>
> bv = COMPUNIT_BLOCKVECTOR (cust);
> block = BLOCKVECTOR_BLOCK (bv, block_index);
> - sym = block_lookup_symbol_primary (block, name, domain);
> - if (sym)
> + result.symbol = block_lookup_symbol_primary (block, name, domain);
> + result.block = block;
> + if (result.symbol != NULL)
> {
> if (symbol_lookup_debug > 1)
> {
> fprintf_unfiltered (gdb_stdlog, " = %s (block %s)\n",
> - host_address_to_string (sym),
> + host_address_to_string (result.symbol),
> host_address_to_string (block));
> }
> - block_found = block;
> - return fixup_symbol_section (sym, objfile);
> + result.symbol = fixup_symbol_section (result.symbol, objfile);
> + return result;
> +
> }
> }
>
> if (symbol_lookup_debug > 1)
> fprintf_unfiltered (gdb_stdlog, " = NULL\n");
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* Wrapper around lookup_symbol_in_objfile_symtabs for search_symbols.
> @@ -2366,7 +2366,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
> different. Here we're called from search_symbols where it will only
> call us for the the objfile that contains a matching minsym. */
>
> -static struct symbol *
> +static struct symbol_in_block
> lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
> const char *linkage_name,
> domain_enum domain)
> @@ -2386,22 +2386,22 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
> cur_objfile;
> cur_objfile = objfile_separate_debug_iterate (main_objfile, cur_objfile))
> {
> - struct symbol *sym;
> + struct symbol_in_block result;
>
> - sym = lookup_symbol_in_objfile_symtabs (cur_objfile, GLOBAL_BLOCK,
> - modified_name, domain);
> - if (sym == NULL)
> - sym = lookup_symbol_in_objfile_symtabs (cur_objfile, STATIC_BLOCK,
> - modified_name, domain);
> - if (sym != NULL)
> + result = lookup_symbol_in_objfile_symtabs (cur_objfile, GLOBAL_BLOCK,
> + modified_name, domain);
> + if (result.symbol == NULL)
> + result = lookup_symbol_in_objfile_symtabs (cur_objfile, STATIC_BLOCK,
> + modified_name, domain);
> + if (result.symbol != NULL)
> {
> do_cleanups (cleanup);
> - return sym;
> + return result;
> }
> }
>
> do_cleanups (cleanup);
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* A helper function that throws an exception when a symbol was found
> @@ -2424,17 +2424,17 @@ Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n\
> /* A helper function for various lookup routines that interfaces with
> the "quick" symbol table functions. */
>
> -static struct symbol *
> +static struct symbol_in_block
> lookup_symbol_via_quick_fns (struct objfile *objfile, int block_index,
> const char *name, const domain_enum domain)
> {
> struct compunit_symtab *cust;
> const struct blockvector *bv;
> const struct block *block;
> - struct symbol *sym;
> + struct symbol_in_block result;
>
> if (!objfile->sf)
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
>
> if (symbol_lookup_debug > 1)
> {
> @@ -2454,36 +2454,37 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, int block_index,
> fprintf_unfiltered (gdb_stdlog,
> "lookup_symbol_via_quick_fns (...) = NULL\n");
> }
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> bv = COMPUNIT_BLOCKVECTOR (cust);
> block = BLOCKVECTOR_BLOCK (bv, block_index);
> - sym = block_lookup_symbol (block, name, domain);
> - if (!sym)
> + result.symbol = block_lookup_symbol (block, name, domain);
> + if (result.symbol == NULL)
> error_in_psymtab_expansion (block_index, name, cust);
>
> if (symbol_lookup_debug > 1)
> {
> fprintf_unfiltered (gdb_stdlog,
> "lookup_symbol_via_quick_fns (...) = %s (block %s)\n",
> - host_address_to_string (sym),
> + host_address_to_string (result.symbol),
> host_address_to_string (block));
> }
>
> - block_found = block;
> - return fixup_symbol_section (sym, objfile);
> + result.symbol = fixup_symbol_section (result.symbol, objfile);
> + result.block = block;
> + return result;
> }
>
> /* See symtab.h. */
>
> -struct symbol *
> +struct symbol_in_block
> basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
> const char *name,
> const struct block *block,
> const domain_enum domain)
> {
> - struct symbol *sym;
> + struct symbol_in_block result;
>
> /* NOTE: carlton/2003-05-19: The comments below were written when
> this (or what turned into this) was part of lookup_symbol_aux;
> @@ -2517,9 +2518,9 @@ basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
> the current objfile. Searching the current objfile first is useful
> for both matching user expectations as well as performance. */
>
> - sym = lookup_symbol_in_static_block (name, block, domain);
> - if (sym != NULL)
> - return sym;
> + result = lookup_symbol_in_static_block (name, block, domain);
> + if (result.symbol != NULL)
> + return result;
>
> /* If we didn't find a definition for a builtin type in the static block,
> search for it now. This is actually the right thing to do and can be
> @@ -2535,9 +2536,11 @@ basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
> gdbarch = target_gdbarch ();
> else
> gdbarch = block_gdbarch (block);
> - sym = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name);
> - if (sym != NULL)
> - return sym;
> + result.symbol = language_lookup_primitive_type_as_symbol (langdef,
> + gdbarch, name);
> + result.block = NULL;
> + if (result.symbol != NULL)
> + return result;
> }
>
> return lookup_global_symbol (name, block, domain);
> @@ -2545,7 +2548,7 @@ basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
>
> /* See symtab.h. */
>
> -struct symbol *
> +struct symbol_in_block
> lookup_symbol_in_static_block (const char *name,
> const struct block *block,
> const domain_enum domain)
> @@ -2554,7 +2557,7 @@ lookup_symbol_in_static_block (const char *name,
> struct symbol *sym;
>
> if (static_block == NULL)
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
>
> if (symbol_lookup_debug)
> {
> @@ -2576,7 +2579,7 @@ lookup_symbol_in_static_block (const char *name,
> "lookup_symbol_in_static_block (...) = %s\n",
> sym != NULL ? host_address_to_string (sym) : "NULL");
> }
> - return sym;
> + return (struct symbol_in_block) {sym, static_block};
> }
>
> /* Perform the standard symbol lookup of NAME in OBJFILE:
> @@ -2584,11 +2587,11 @@ lookup_symbol_in_static_block (const char *name,
> 2) Search the "quick" symtabs (partial or .gdb_index).
> BLOCK_INDEX is one of GLOBAL_BLOCK or STATIC_BLOCK. */
>
> -static struct symbol *
> +static struct symbol_in_block
> lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
> const char *name, const domain_enum domain)
> {
> - struct symbol *result;
> + struct symbol_in_block result;
>
> if (symbol_lookup_debug)
> {
> @@ -2602,14 +2605,14 @@ lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
>
> result = lookup_symbol_in_objfile_symtabs (objfile, block_index,
> name, domain);
> - if (result != NULL)
> + if (result.symbol != NULL)
> {
> if (symbol_lookup_debug)
> {
> fprintf_unfiltered (gdb_stdlog,
> "lookup_symbol_in_objfile (...) = %s"
> " (in symtabs)\n",
> - host_address_to_string (result));
> + host_address_to_string (result.symbol));
> }
> return result;
> }
> @@ -2620,22 +2623,22 @@ lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
> {
> fprintf_unfiltered (gdb_stdlog,
> "lookup_symbol_in_objfile (...) = %s%s\n",
> - result != NULL
> - ? host_address_to_string (result)
> + result.symbol != NULL
> + ? host_address_to_string (result.symbol)
> : "NULL",
> - result != NULL ? " (via quick fns)" : "");
> + result.symbol != NULL ? " (via quick fns)" : "");
> }
> return result;
> }
>
> /* See symtab.h. */
>
> -struct symbol *
> +struct symbol_in_block
> lookup_static_symbol (const char *name, const domain_enum domain)
> {
> struct symbol_cache *cache = get_symbol_cache (current_program_space);
> struct objfile *objfile;
> - struct symbol *result;
> + struct symbol_in_block result;
> struct block_symbol_cache *bsc;
> struct symbol_cache_slot *slot;
>
> @@ -2643,27 +2646,28 @@ lookup_static_symbol (const char *name, const domain_enum domain)
> NULL for OBJFILE_CONTEXT. */
> result = symbol_cache_lookup (cache, NULL, STATIC_BLOCK, name, domain,
> &bsc, &slot);
> - if (result != NULL)
> + if (result.symbol != NULL)
> {
> - if (result == SYMBOL_LOOKUP_FAILED)
> - return NULL;
> + if (SYMBOL_LOOKUP_FAILED_P (result))
> + return (struct symbol_in_block) {NULL, NULL};
> return result;
> }
>
> ALL_OBJFILES (objfile)
> {
> result = lookup_symbol_in_objfile (objfile, STATIC_BLOCK, name, domain);
> - if (result != NULL)
> + if (result.symbol != NULL)
> {
> /* Still pass NULL for OBJFILE_CONTEXT here. */
> - symbol_cache_mark_found (bsc, slot, NULL, result);
> + symbol_cache_mark_found (bsc, slot, NULL, result.symbol,
> + result.block);
> return result;
> }
> }
>
> /* Still pass NULL for OBJFILE_CONTEXT here. */
> symbol_cache_mark_not_found (bsc, slot, NULL, name, domain);
> - return NULL;
> + return (struct symbol_in_block) {NULL, NULL};
> }
>
> /* Private data to be used with lookup_symbol_global_iterator_cb. */
> @@ -2677,8 +2681,8 @@ struct global_sym_lookup_data
> domain_enum domain;
>
> /* The field where the callback should store the symbol if found.
> - It should be initialized to NULL before the search is started. */
> - struct symbol *result;
> + It should be initialized to {NULL, NULL} before the search is started. */
> + struct symbol_in_block result;
> };
>
> /* A callback function for gdbarch_iterate_over_objfiles_in_search_order.
> @@ -2693,25 +2697,26 @@ lookup_symbol_global_iterator_cb (struct objfile *objfile,
> struct global_sym_lookup_data *data =
> (struct global_sym_lookup_data *) cb_data;
>
> - gdb_assert (data->result == NULL);
> + gdb_assert (data->result.symbol == NULL
> + && data->result.block == NULL);
>
> data->result = lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK,
> data->name, data->domain);
>
> /* If we found a match, tell the iterator to stop. Otherwise,
> keep going. */
> - return (data->result != NULL);
> + return (data->result.symbol != NULL);
> }
>
> /* See symtab.h. */
>
> -struct symbol *
> +struct symbol_in_block
> lookup_global_symbol (const char *name,
> const struct block *block,
> const domain_enum domain)
> {
> struct symbol_cache *cache = get_symbol_cache (current_program_space);
> - struct symbol *sym;
> + struct symbol_in_block result;
> struct objfile *objfile;
> struct global_sym_lookup_data lookup_data;
> struct block_symbol_cache *bsc;
> @@ -2721,21 +2726,21 @@ lookup_global_symbol (const char *name,
>
> /* First see if we can find the symbol in the cache.
> This works because we use the current objfile to qualify the lookup. */
> - sym = symbol_cache_lookup (cache, objfile, GLOBAL_BLOCK, name, domain,
> - &bsc, &slot);
> - if (sym != NULL)
> + result = symbol_cache_lookup (cache, objfile, GLOBAL_BLOCK, name, domain,
> + &bsc, &slot);
> + if (result.symbol != NULL)
> {
> - if (sym == SYMBOL_LOOKUP_FAILED)
> - return NULL;
> - return sym;
> + if (SYMBOL_LOOKUP_FAILED_P (result))
> + return (struct symbol_in_block) {NULL, NULL};
> + return result;
> }
>
> /* Call library-specific lookup procedure. */
> if (objfile != NULL)
> - sym = solib_global_lookup (objfile, name, domain);
> + result = solib_global_lookup (objfile, name, domain);
>
> /* If that didn't work go a global search (of global blocks, heh). */
> - if (sym == NULL)
> + if (result.symbol == NULL)
> {
> memset (&lookup_data, 0, sizeof (lookup_data));
> lookup_data.name = name;
> @@ -2743,15 +2748,15 @@ lookup_global_symbol (const char *name,
> gdbarch_iterate_over_objfiles_in_search_order
> (objfile != NULL ? get_objfile_arch (objfile) : target_gdbarch (),
> lookup_symbol_global_iterator_cb, &lookup_data, objfile);
> - sym = lookup_data.result;
> + result = lookup_data.result;
> }
>
> - if (sym != NULL)
> - symbol_cache_mark_found (bsc, slot, objfile, sym);
> + if (result.symbol != NULL)
> + symbol_cache_mark_found (bsc, slot, objfile, result.symbol, result.block);
> else
> symbol_cache_mark_not_found (bsc, slot, objfile, name, domain);
>
> - return sym;
> + return result;
> }
>
> int
> @@ -4602,7 +4607,7 @@ search_symbols (const char *regexp, enum search_domain kind,
> (MSYMBOL_VALUE_ADDRESS (objfile, msymbol)) == NULL)
> : (lookup_symbol_in_objfile_from_linkage_name
> (objfile, MSYMBOL_LINKAGE_NAME (msymbol), VAR_DOMAIN)
> - == NULL))
> + .symbol == NULL))
> found_misc = 1;
> }
> }
> @@ -4705,7 +4710,7 @@ search_symbols (const char *regexp, enum search_domain kind,
> {
> if (lookup_symbol_in_objfile_from_linkage_name
> (objfile, MSYMBOL_LINKAGE_NAME (msymbol), VAR_DOMAIN)
> - == NULL)
> + .symbol == NULL)
> {
> /* match */
> struct symbol_search *psr = (struct symbol_search *)
> diff --git a/gdb/symtab.h b/gdb/symtab.h
> index 6a0b8da..73026b3 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -782,6 +782,19 @@ struct symbol
> struct symbol *hash_next;
> };
>
> +/* Several lookup functions return both a symbol and the block in which the
> + symbol is found. This structure is used in these cases. */
> +
> +struct symbol_in_block
> +{
> + /* The symbol that was found, or NULL if no symbol was found. */
> + struct symbol *symbol;
> +
> + /* If SYMBOL is not NULL, then this is the block in which the symbol is
> + defined. */
> + const struct block *block;
> +};
> +
> extern const struct symbol_impl *symbol_impls;
>
> /* Note: There is no accessor macro for symbol.owner because it is
> @@ -1141,10 +1154,6 @@ DEF_VEC_P (compunit_symtab_ptr);
>
> extern int currently_reading_symtab;
>
> -/* The block in which the most recently looked up symbol was found. */
> -
> -extern const struct block *block_found;
> -
> /* symtab.c lookup functions */
>
> extern const char multiple_symbols_ask[];
> @@ -1190,27 +1199,27 @@ struct field_of_this_result
> C++: if IS_A_FIELD_OF_THIS is non-NULL on entry, check to see if
> NAME is a field of the current implied argument `this'. If so fill in the
> fields of IS_A_FIELD_OF_THIS, otherwise the fields are set to NULL.
> - BLOCK_FOUND is set to the block in which NAME is found (in the case of
> - a field of `this', value_of_this sets BLOCK_FOUND to the proper value).
> The symbol's section is fixed up if necessary. */
>
> -extern struct symbol *lookup_symbol_in_language (const char *,
> - const struct block *,
> - const domain_enum,
> - enum language,
> - struct field_of_this_result *);
> +extern struct symbol_in_block
> + lookup_symbol_in_language (const char *,
> + const struct block *,
> + const domain_enum,
> + enum language,
> + struct field_of_this_result *);
>
> /* Same as lookup_symbol_in_language, but using the current language. */
>
> -extern struct symbol *lookup_symbol (const char *, const struct block *,
> - const domain_enum,
> - struct field_of_this_result *);
> +extern struct symbol_in_block lookup_symbol (const char *,
> + const struct block *,
> + const domain_enum,
> + struct field_of_this_result *);
>
> /* A default version of lookup_symbol_nonlocal for use by languages
> that can't think of anything better to do.
> This implements the C lookup rules. */
>
> -extern struct symbol *
> +extern struct symbol_in_block
> basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
> const char *,
> const struct block *,
> @@ -1221,19 +1230,18 @@ extern struct symbol *
>
> /* Lookup a symbol in the static block associated to BLOCK, if there
> is one; do nothing if BLOCK is NULL or a global block.
> - Upon success sets BLOCK_FOUND and fixes up the symbol's section
> - if necessary. */
> + Upon success fixes up the symbol's section if necessary. */
>
> -extern struct symbol *lookup_symbol_in_static_block (const char *name,
> - const struct block *block,
> - const domain_enum domain);
> +extern struct symbol_in_block
> + lookup_symbol_in_static_block (const char *name,
> + const struct block *block,
> + const domain_enum domain);
>
> /* Search all static file-level symbols for NAME from DOMAIN.
> - Upon success sets BLOCK_FOUND and fixes up the symbol's section
> - if necessary. */
> + Upon success fixes up the symbol's section if necessary. */
>
> -extern struct symbol *lookup_static_symbol (const char *name,
> - const domain_enum domain);
> +extern struct symbol_in_block lookup_static_symbol (const char *name,
> + const domain_enum domain);
>
> /* Lookup a symbol in all files' global blocks.
>
> @@ -1244,26 +1252,27 @@ extern struct symbol *lookup_static_symbol (const char *name,
> if the target requires it.
> See gdbarch_iterate_over_objfiles_in_search_order.
>
> - Upon success sets BLOCK_FOUND and fixes up the symbol's section
> - if necessary. */
> + Upon success fixes up the symbol's section if necessary. */
>
> -extern struct symbol *lookup_global_symbol (const char *name,
> - const struct block *block,
> - const domain_enum domain);
> +extern struct symbol_in_block
> + lookup_global_symbol (const char *name,
> + const struct block *block,
> + const domain_enum domain);
>
> /* Lookup a symbol in block BLOCK.
> - Upon success sets BLOCK_FOUND and fixes up the symbol's section
> - if necessary. */
> + Upon success fixes up the symbol's section if necessary. */
>
> -extern struct symbol *lookup_symbol_in_block (const char *name,
> - const struct block *block,
> - const domain_enum domain);
> +extern struct symbol *
> + lookup_symbol_in_block (const char *name,
> + const struct block *block,
> + const domain_enum domain);
>
> /* Look up the `this' symbol for LANG in BLOCK. Return the symbol if
> found, or NULL if not found. */
>
> -extern struct symbol *lookup_language_this (const struct language_defn *lang,
> - const struct block *block);
> +extern struct symbol_in_block
> + lookup_language_this (const struct language_defn *lang,
> + const struct block *block);
>
> /* Lookup a [struct, union, enum] by name, within a specified block. */
>
> @@ -1524,10 +1533,9 @@ extern enum language main_language (void);
> /* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global blocks.
> This searches MAIN_OBJFILE as well as any associated separate debug info
> objfiles of MAIN_OBJFILE.
> - Upon success sets BLOCK_FOUND and fixes up the symbol's section
> - if necessary. */
> + Upon success fixes up the symbol's section if necessary. */
>
> -extern struct symbol *
> +extern struct symbol_in_block
> lookup_global_symbol_from_objfile (struct objfile *main_objfile,
> const char *name,
> const domain_enum domain);
> diff --git a/gdb/valops.c b/gdb/valops.c
> index d68e9f3..d326f93 100644
> --- a/gdb/valops.c
> +++ b/gdb/valops.c
> @@ -127,21 +127,21 @@ show_overload_resolution (struct ui_file *file, int from_tty,
> struct value *
> find_function_in_inferior (const char *name, struct objfile **objf_p)
> {
> - struct symbol *sym;
> + struct symbol_in_block sym;
>
> sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
> - if (sym != NULL)
> + if (sym.symbol != NULL)
> {
> - if (SYMBOL_CLASS (sym) != LOC_BLOCK)
> + if (SYMBOL_CLASS (sym.symbol) != LOC_BLOCK)
> {
> error (_("\"%s\" exists in this program but is not a function."),
> name);
> }
>
> if (objf_p)
> - *objf_p = symbol_objfile (sym);
> + *objf_p = symbol_objfile (sym.symbol);
>
> - return value_of_variable (sym, NULL);
> + return value_of_variable (sym.symbol, sym.block);
> }
> else
> {
> @@ -3453,7 +3453,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
> {
> struct symbol *s =
> lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
> - 0, VAR_DOMAIN, 0);
> + 0, VAR_DOMAIN, 0).symbol;
>
> if (s == NULL)
> return NULL;
> @@ -3484,7 +3484,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
> {
> struct symbol *s =
> lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
> - 0, VAR_DOMAIN, 0);
> + 0, VAR_DOMAIN, 0).symbol;
>
> if (s == NULL)
> return NULL;
> @@ -3560,19 +3560,19 @@ value_maybe_namespace_elt (const struct type *curtype,
> enum noside noside)
> {
> const char *namespace_name = TYPE_TAG_NAME (curtype);
> - struct symbol *sym;
> + struct symbol_in_block sym;
> struct value *result;
>
> sym = cp_lookup_symbol_namespace (namespace_name, name,
> get_selected_block (0), VAR_DOMAIN);
>
> - if (sym == NULL)
> + if (sym.symbol == NULL)
> return NULL;
> else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
> - && (SYMBOL_CLASS (sym) == LOC_TYPEDEF))
> - result = allocate_value (SYMBOL_TYPE (sym));
> + && (SYMBOL_CLASS (sym.symbol) == LOC_TYPEDEF))
> + result = allocate_value (SYMBOL_TYPE (sym.symbol));
> else
> - result = value_of_variable (sym, get_selected_block (0));
> + result = value_of_variable (sym.symbol, sym.block);
>
> if (want_address)
> result = value_addr (result);
> @@ -3736,7 +3736,7 @@ value_of_this (const struct language_defn *lang)
>
> b = get_frame_block (frame, NULL);
>
> - sym = lookup_language_this (lang, b);
> + sym = lookup_language_this (lang, b).symbol;
> if (sym == NULL)
> error (_("current stack frame does not contain a variable named `%s'"),
> lang->la_name_of_this);
> diff --git a/gdb/value.c b/gdb/value.c
> index 4399493..1e331de 100644
> --- a/gdb/value.c
> +++ b/gdb/value.c
> @@ -2937,9 +2937,9 @@ value_static_field (struct type *type, int fieldno)
> {
> const char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
> /* TYPE_FIELD_NAME (type, fieldno); */
> - struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0);
> + struct symbol_in_block sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0);
>
> - if (sym == NULL)
> + if (sym.symbol == NULL)
> {
> /* With some compilers, e.g. HP aCC, static data members are
> reported as non-debuggable symbols. */
> @@ -2955,7 +2955,7 @@ value_static_field (struct type *type, int fieldno)
> }
> }
> else
> - retval = value_of_variable (sym, NULL);
> + retval = value_of_variable (sym.symbol, sym.block);
> break;
> }
> default:
> @@ -3122,7 +3122,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
> struct symbol *sym;
> struct bound_minimal_symbol msym;
>
> - sym = lookup_symbol (physname, 0, VAR_DOMAIN, 0);
> + sym = lookup_symbol (physname, 0, VAR_DOMAIN, 0).symbol;
> if (sym != NULL)
> {
> memset (&msym, 0, sizeof (msym));
Here are the guile patches.
@@ -911,7 +911,7 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest)
{
if (block == NULL)
block = get_frame_block (frame, NULL);
- var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL);
+ var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL).symbol;
}
CATCH (ex, RETURN_MASK_ALL)
{
@@ -617,7 +617,7 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest)
TRY
{
- symbol = lookup_symbol (name, block, domain, &is_a_field_of_this);
+ symbol = lookup_symbol (name, block, domain, &is_a_field_of_this).symbol;
}
CATCH (ex, RETURN_MASK_ALL)
{
@@ -657,7 +657,7 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest)
TRY
{
- symbol = lookup_global_symbol (name, NULL, domain);
+ symbol = lookup_global_symbol (name, NULL, domain).symbol;
}
CATCH (ex, RETURN_MASK_ALL)
{