Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
This commit is contained in:
parent
5efafabf7b
commit
d12307c199
50 changed files with 910 additions and 697 deletions
174
gdb/ChangeLog
174
gdb/ChangeLog
|
@ -1,3 +1,177 @@
|
|||
2015-08-01 Pierre-Marie de Rodat <derodat@adacore.com>
|
||||
|
||||
* ada-exp.y (write_object_renaming): Replace struct
|
||||
ada_symbol_info with struct block_symbol. Update field
|
||||
references accordingly.
|
||||
(block_lookup, select_possible_type_sym): Likewise.
|
||||
(find_primitive_type): Likewise. Also update call to
|
||||
ada_lookup_symbol to extract the symbol itself.
|
||||
(write_var_or_type, write_name_assoc): Likewise.
|
||||
* ada-lang.h (struct ada_symbol_info): Remove.
|
||||
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
|
||||
struct block_symbol.
|
||||
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
|
||||
(ada_lookup_symbol): Return struct block_symbol instead of a
|
||||
mere symbol.
|
||||
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
|
||||
with struct block_symbol.
|
||||
(resolve_subexp, ada_resolve_function, sort_choices,
|
||||
user_select_syms, is_nonfunction, add_defn_to_vec,
|
||||
num_defns_collected, defns_collected,
|
||||
symbols_are_identical_enums, remove_extra_symbols,
|
||||
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
|
||||
ada_lookup_symbol_list, ada_iterate_over_symbols,
|
||||
ada_lookup_encoded_symbol, get_var_value): Likewise.
|
||||
(ada_lookup_symbol): Return a block_symbol instead of a mere
|
||||
symbol. Replace struct ada_symbol_info with struct
|
||||
block_symbol.
|
||||
(ada_lookup_symbol_nonlocal): Likewise.
|
||||
(standard_lookup): Make block passing explicit through
|
||||
lookup_symbol_in_language.
|
||||
* ada-tasks.c (get_tcb_types_info): Update the calls to
|
||||
lookup_symbol_in_language to extract the mere symbol out of the
|
||||
returned value.
|
||||
(ada_tasks_inferior_data_sniffer): Likewise.
|
||||
* ax-gdb.c (gen_static_field): Likewise for the call to
|
||||
lookup_symbol.
|
||||
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
|
||||
lookup functions.
|
||||
(gen_expr): Likewise.
|
||||
* c-exp.y: Likewise. Remove uses of block_found.
|
||||
(lex_one_token, classify_inner_name, c_print_token): Likewise.
|
||||
(classify_name): Likewise. Rename the "sym" local variable to
|
||||
"bsym".
|
||||
* c-valprint.c (print_unpacked_pointer): Likewise.
|
||||
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
|
||||
"sym" parameter from struct symbol * to struct block_symbol.
|
||||
Use it to remove uses of block_found. Deal with struct
|
||||
symbol_in_block from lookup functions.
|
||||
(gcc_convert_symbol): Likewise. Update the call to
|
||||
convert_symbol_sym.
|
||||
* compile/compile-object-load.c (compile_object_load): Deal with
|
||||
struct symbol_in_block from lookup functions.
|
||||
* cp-namespace.c (cp_lookup_nested_symbol_1,
|
||||
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
|
||||
cp_search_static_and_baseclasses,
|
||||
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
|
||||
cp_lookup_symbol_imports_or_template,
|
||||
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
|
||||
lookup_namespace_scope, cp_lookup_nonlocal,
|
||||
find_symbol_in_baseclass): Return struct symbol_in_block instead
|
||||
of mere symbols and deal with struct symbol_in_block from lookup
|
||||
functions.
|
||||
* cp-support.c (inspect_type, replace_typedefs,
|
||||
cp_lookup_rtti_type): Deal with struct symbol_in_block from
|
||||
lookup functions.
|
||||
* cp-support.h (cp_lookup_symbol_nonlocal,
|
||||
cp_lookup_symbol_from_namespace,
|
||||
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
|
||||
Return struct symbol_in_block instead of mere symbols.
|
||||
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
|
||||
push_module_name):
|
||||
Deal with struct symbol_in_block from lookup functions. Remove
|
||||
uses of block_found.
|
||||
* eval.c (evaluate_subexp_standard): Update call to
|
||||
cp_lookup_symbol_namespace.
|
||||
* f-exp.y: Deal with struct symbol_in_block from lookup
|
||||
functions. Remove uses of block_found.
|
||||
(yylex): Likewise.
|
||||
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
|
||||
lookup_enum, lookup_template_type, check_typedef): Deal with
|
||||
struct symbol_in_block from lookup functions.
|
||||
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
|
||||
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
|
||||
(gdbscm_lookup_global_symbol): Likewise.
|
||||
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
|
||||
* go-exp.y: Likewise. Remove uses of block_found.
|
||||
(package_name_p, classify_packaged_name, classify_name):
|
||||
Likewise.
|
||||
* infrun.c (insert_exception_resume_breakpoint): Likewise.
|
||||
* jv-exp.y (push_variable): Likewise.
|
||||
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
|
||||
* language.c (language_bool_type): Likewise.
|
||||
* language.h (struct language_defn): Update
|
||||
la_lookup_symbol_nonlocal to return a struct symbol_in_block
|
||||
rather than a mere symbol.
|
||||
* linespec.c (find_label_symbols): Deal with struct
|
||||
symbol_in_block from lookup functions.
|
||||
* m2-exp.y: Likewise. Remove uses of block_found.
|
||||
(yylex): Likewise.
|
||||
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
|
||||
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
|
||||
* p-exp.y: Likewise. Remove uses of block_found.
|
||||
(yylex): Likewise.
|
||||
* p-valprint.c (pascal_val_print): Likewise.
|
||||
* parse.c (write_dollar_variable): Likewise. Remove uses of
|
||||
block_found.
|
||||
* parser-defs.h (struct symtoken): Turn the SYM field into a
|
||||
struct symbol_in_block.
|
||||
* printcmd.c (address_info): Deal with struct symbol_in_block
|
||||
from lookup functions.
|
||||
* python/py-frame.c (frapy_read_var): Likewise.
|
||||
* python/py-symbol.c (gdbpy_lookup_symbol,
|
||||
gdbpy_lookup_global_symbol): Likewise.
|
||||
* skip.c (skip_function_command): Likewise.
|
||||
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
|
||||
symbol_in_block instead of a mere symbol.
|
||||
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
|
||||
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
|
||||
* solib.c (solib_global_lookup): Likewise.
|
||||
* solist.h (solib_global_lookup): Likewise.
|
||||
(struct target_so_ops): Update lookup_lib_global_symbol to
|
||||
return a struct symbol_in_block rather than a mere symbol.
|
||||
* source.c (select_source_symtab): Deal with struct
|
||||
symbol_in_block from lookup functions.
|
||||
* stack.c (print_frame_args, iterate_over_block_arg_vars):
|
||||
Likewise.
|
||||
* symfile.c (set_initial_language): Likewise.
|
||||
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
|
||||
symbol_in_block.
|
||||
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
|
||||
(struct symbol_cache_slot): Turn the FOUND field into a struct
|
||||
symbol_in_block.
|
||||
(block_found): Remove.
|
||||
(eq_symbol_entry): Update to deal with struct symbol_in_block in
|
||||
cache slots.
|
||||
(symbol_cache_lookup): Return a struct symbol_in_block rather
|
||||
than a mere symbol.
|
||||
(symbol_cache_mark_found): Add a BLOCK parameter to fill
|
||||
appropriately the cache slots. Update callers.
|
||||
(symbol_cache_dump): Update cache slots handling to the type
|
||||
change.
|
||||
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
|
||||
lookup_symbol_aux, lookup_local_symbol,
|
||||
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
|
||||
lookup_symbol_in_objfile_symtabs,
|
||||
lookup_symbol_in_objfile_from_linkage_name,
|
||||
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
|
||||
lookup_symbol_in_static_block, lookup_static_symbol,
|
||||
lookup_global_symbol):
|
||||
Return a struct symbol_in_block rather than a mere symbol. Deal
|
||||
with struct symbol_in_block from other lookup functions. Remove
|
||||
uses of block_found.
|
||||
(lookup_symbol_in_block): Remove uses of block_found.
|
||||
(struct global_sym_lookup_data): Turn the RESULT field into a
|
||||
struct symbol_in_block.
|
||||
(lookup_symbol_global_iterator_cb): Update references to the
|
||||
RESULT field.
|
||||
(search_symbols): Deal with struct symbol_in_block from lookup
|
||||
functions.
|
||||
* symtab.h (struct symbol_in_block): New structure.
|
||||
(block_found): Remove.
|
||||
(lookup_symbol_in_language, lookup_symbol,
|
||||
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
|
||||
looku_static_symbol, lookup_global_symbol,
|
||||
lookup_symbol_in_block, lookup_language_this,
|
||||
lookup_global_symbol_from_objfile): Return a struct
|
||||
symbol_in_block rather than just a mere symbol. Update comments
|
||||
to remove mentions of block_found.
|
||||
* valops.c (find_function_in_inferior,
|
||||
value_struct_elt_for_reference, value_maybe_namespace_elt,
|
||||
value_of_this): Deal with struct symbol_in_block from lookup
|
||||
functions.
|
||||
* value.c (value_static_field, value_fn_field): Likewise.
|
||||
|
||||
2015-07-31 Simon Marchi <simon.marchi@ericsson.com>
|
||||
|
||||
* remote-m32r-sdi.c (m32r_remove_watchpoint): Use enum type
|
||||
|
|
|
@ -868,7 +868,7 @@ write_object_renaming (struct parser_state *par_state,
|
|||
{
|
||||
char *name;
|
||||
enum { SIMPLE_INDEX, LOWER_BOUND, UPPER_BOUND } slice_state;
|
||||
struct ada_symbol_info sym_info;
|
||||
struct block_symbol sym_info;
|
||||
|
||||
if (max_depth <= 0)
|
||||
error (_("Could not find renamed symbol"));
|
||||
|
@ -878,9 +878,9 @@ write_object_renaming (struct parser_state *par_state,
|
|||
|
||||
name = obstack_copy0 (&temp_parse_space, renamed_entity, renamed_entity_len);
|
||||
ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, &sym_info);
|
||||
if (sym_info.sym == NULL)
|
||||
if (sym_info.symbol == NULL)
|
||||
error (_("Could not find renamed variable: %s"), ada_decode (name));
|
||||
else if (SYMBOL_CLASS (sym_info.sym) == LOC_TYPEDEF)
|
||||
else if (SYMBOL_CLASS (sym_info.symbol) == LOC_TYPEDEF)
|
||||
/* We have a renaming of an old-style renaming symbol. Don't
|
||||
trust the block information. */
|
||||
sym_info.block = orig_left_context;
|
||||
|
@ -890,13 +890,13 @@ write_object_renaming (struct parser_state *par_state,
|
|||
int inner_renamed_entity_len;
|
||||
const char *inner_renaming_expr;
|
||||
|
||||
switch (ada_parse_renaming (sym_info.sym, &inner_renamed_entity,
|
||||
switch (ada_parse_renaming (sym_info.symbol, &inner_renamed_entity,
|
||||
&inner_renamed_entity_len,
|
||||
&inner_renaming_expr))
|
||||
{
|
||||
case ADA_NOT_RENAMING:
|
||||
write_var_from_sym (par_state, orig_left_context, sym_info.block,
|
||||
sym_info.sym);
|
||||
sym_info.symbol);
|
||||
break;
|
||||
case ADA_OBJECT_RENAMING:
|
||||
write_object_renaming (par_state, sym_info.block,
|
||||
|
@ -939,7 +939,7 @@ write_object_renaming (struct parser_state *par_state,
|
|||
{
|
||||
const char *end;
|
||||
char *index_name;
|
||||
struct ada_symbol_info index_sym_info;
|
||||
struct block_symbol index_sym_info;
|
||||
|
||||
end = strchr (renaming_expr, 'X');
|
||||
if (end == NULL)
|
||||
|
@ -952,13 +952,13 @@ write_object_renaming (struct parser_state *par_state,
|
|||
|
||||
ada_lookup_encoded_symbol (index_name, NULL, VAR_DOMAIN,
|
||||
&index_sym_info);
|
||||
if (index_sym_info.sym == NULL)
|
||||
if (index_sym_info.symbol == NULL)
|
||||
error (_("Could not find %s"), index_name);
|
||||
else if (SYMBOL_CLASS (index_sym_info.sym) == LOC_TYPEDEF)
|
||||
else if (SYMBOL_CLASS (index_sym_info.symbol) == LOC_TYPEDEF)
|
||||
/* Index is an old-style renaming symbol. */
|
||||
index_sym_info.block = orig_left_context;
|
||||
write_var_from_sym (par_state, NULL, index_sym_info.block,
|
||||
index_sym_info.sym);
|
||||
index_sym_info.symbol);
|
||||
}
|
||||
if (slice_state == SIMPLE_INDEX)
|
||||
{
|
||||
|
@ -1013,7 +1013,7 @@ static const struct block*
|
|||
block_lookup (const struct block *context, const char *raw_name)
|
||||
{
|
||||
const char *name;
|
||||
struct ada_symbol_info *syms;
|
||||
struct block_symbol *syms;
|
||||
int nsyms;
|
||||
struct symtab *symtab;
|
||||
|
||||
|
@ -1027,14 +1027,14 @@ block_lookup (const struct block *context, const char *raw_name)
|
|||
|
||||
nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms);
|
||||
if (context == NULL
|
||||
&& (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK))
|
||||
&& (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK))
|
||||
symtab = lookup_symtab (name);
|
||||
else
|
||||
symtab = NULL;
|
||||
|
||||
if (symtab != NULL)
|
||||
return BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), STATIC_BLOCK);
|
||||
else if (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK)
|
||||
else if (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK)
|
||||
{
|
||||
if (context == NULL)
|
||||
error (_("No file or function \"%s\"."), raw_name);
|
||||
|
@ -1045,12 +1045,12 @@ block_lookup (const struct block *context, const char *raw_name)
|
|||
{
|
||||
if (nsyms > 1)
|
||||
warning (_("Function name \"%s\" ambiguous here"), raw_name);
|
||||
return SYMBOL_BLOCK_VALUE (syms[0].sym);
|
||||
return SYMBOL_BLOCK_VALUE (syms[0].symbol);
|
||||
}
|
||||
}
|
||||
|
||||
static struct symbol*
|
||||
select_possible_type_sym (struct ada_symbol_info *syms, int nsyms)
|
||||
select_possible_type_sym (struct block_symbol *syms, int nsyms)
|
||||
{
|
||||
int i;
|
||||
int preferred_index;
|
||||
|
@ -1058,13 +1058,13 @@ select_possible_type_sym (struct ada_symbol_info *syms, int nsyms)
|
|||
|
||||
preferred_index = -1; preferred_type = NULL;
|
||||
for (i = 0; i < nsyms; i += 1)
|
||||
switch (SYMBOL_CLASS (syms[i].sym))
|
||||
switch (SYMBOL_CLASS (syms[i].symbol))
|
||||
{
|
||||
case LOC_TYPEDEF:
|
||||
if (ada_prefer_type (SYMBOL_TYPE (syms[i].sym), preferred_type))
|
||||
if (ada_prefer_type (SYMBOL_TYPE (syms[i].symbol), preferred_type))
|
||||
{
|
||||
preferred_index = i;
|
||||
preferred_type = SYMBOL_TYPE (syms[i].sym);
|
||||
preferred_type = SYMBOL_TYPE (syms[i].symbol);
|
||||
}
|
||||
break;
|
||||
case LOC_REGISTER:
|
||||
|
@ -1079,7 +1079,7 @@ select_possible_type_sym (struct ada_symbol_info *syms, int nsyms)
|
|||
}
|
||||
if (preferred_type == NULL)
|
||||
return NULL;
|
||||
return syms[preferred_index].sym;
|
||||
return syms[preferred_index].symbol;
|
||||
}
|
||||
|
||||
static struct type*
|
||||
|
@ -1101,7 +1101,7 @@ find_primitive_type (struct parser_state *par_state, char *name)
|
|||
(char *) alloca (strlen (name) + sizeof ("standard__"));
|
||||
strcpy (expanded_name, "standard__");
|
||||
strcat (expanded_name, name);
|
||||
sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN, NULL);
|
||||
sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN, NULL).symbol;
|
||||
if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
|
||||
type = SYMBOL_TYPE (sym);
|
||||
}
|
||||
|
@ -1274,7 +1274,7 @@ write_var_or_type (struct parser_state *par_state,
|
|||
while (tail_index > 0)
|
||||
{
|
||||
int nsyms;
|
||||
struct ada_symbol_info *syms;
|
||||
struct block_symbol *syms;
|
||||
struct symbol *type_sym;
|
||||
struct symbol *renaming_sym;
|
||||
const char* renaming;
|
||||
|
@ -1294,10 +1294,10 @@ write_var_or_type (struct parser_state *par_state,
|
|||
if (nsyms == 1)
|
||||
{
|
||||
struct symbol *ren_sym =
|
||||
ada_find_renaming_symbol (syms[0].sym, syms[0].block);
|
||||
ada_find_renaming_symbol (syms[0].symbol, syms[0].block);
|
||||
|
||||
if (ren_sym != NULL)
|
||||
syms[0].sym = ren_sym;
|
||||
syms[0].symbol = ren_sym;
|
||||
}
|
||||
|
||||
type_sym = select_possible_type_sym (syms, nsyms);
|
||||
|
@ -1305,7 +1305,7 @@ write_var_or_type (struct parser_state *par_state,
|
|||
if (type_sym != NULL)
|
||||
renaming_sym = type_sym;
|
||||
else if (nsyms == 1)
|
||||
renaming_sym = syms[0].sym;
|
||||
renaming_sym = syms[0].symbol;
|
||||
else
|
||||
renaming_sym = NULL;
|
||||
|
||||
|
@ -1367,7 +1367,7 @@ write_var_or_type (struct parser_state *par_state,
|
|||
if (nsyms == 1)
|
||||
{
|
||||
write_var_from_sym (par_state, block, syms[0].block,
|
||||
syms[0].sym);
|
||||
syms[0].symbol);
|
||||
write_selectors (par_state, encoded_name + tail_index);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1433,13 +1433,14 @@ write_name_assoc (struct parser_state *par_state, struct stoken name)
|
|||
{
|
||||
if (strchr (name.ptr, '.') == NULL)
|
||||
{
|
||||
struct ada_symbol_info *syms;
|
||||
struct block_symbol *syms;
|
||||
int nsyms = ada_lookup_symbol_list (name.ptr, expression_context_block,
|
||||
VAR_DOMAIN, &syms);
|
||||
if (nsyms != 1 || SYMBOL_CLASS (syms[0].sym) == LOC_TYPEDEF)
|
||||
|
||||
if (nsyms != 1 || SYMBOL_CLASS (syms[0].symbol) == LOC_TYPEDEF)
|
||||
write_exp_op_with_string (par_state, OP_NAME, name);
|
||||
else
|
||||
write_var_from_sym (par_state, NULL, syms[0].block, syms[0].sym);
|
||||
write_var_from_sym (par_state, NULL, syms[0].block, syms[0].symbol);
|
||||
}
|
||||
else
|
||||
if (write_var_or_type (par_state, NULL, name) != NULL)
|
||||
|
|
227
gdb/ada-lang.c
227
gdb/ada-lang.c
|
@ -108,14 +108,14 @@ static void ada_add_block_symbols (struct obstack *,
|
|||
const struct block *, const char *,
|
||||
domain_enum, struct objfile *, int);
|
||||
|
||||
static int is_nonfunction (struct ada_symbol_info *, int);
|
||||
static int is_nonfunction (struct block_symbol *, int);
|
||||
|
||||
static void add_defn_to_vec (struct obstack *, struct symbol *,
|
||||
const struct block *);
|
||||
|
||||
static int num_defns_collected (struct obstack *);
|
||||
|
||||
static struct ada_symbol_info *defns_collected (struct obstack *, int);
|
||||
static struct block_symbol *defns_collected (struct obstack *, int);
|
||||
|
||||
static struct value *resolve_subexp (struct expression **, int *, int,
|
||||
struct type *);
|
||||
|
@ -223,7 +223,7 @@ static int find_struct_field (const char *, struct type *, int,
|
|||
static struct value *ada_to_fixed_value_create (struct type *, CORE_ADDR,
|
||||
struct value *);
|
||||
|
||||
static int ada_resolve_function (struct ada_symbol_info *, int,
|
||||
static int ada_resolve_function (struct block_symbol *, int,
|
||||
struct value **, int, const char *,
|
||||
struct type *);
|
||||
|
||||
|
@ -3311,7 +3311,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
|||
case OP_VAR_VALUE:
|
||||
if (SYMBOL_DOMAIN (exp->elts[pc + 2].symbol) == UNDEF_DOMAIN)
|
||||
{
|
||||
struct ada_symbol_info *candidates;
|
||||
struct block_symbol *candidates;
|
||||
int n_candidates;
|
||||
|
||||
n_candidates =
|
||||
|
@ -3327,7 +3327,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
|||
out all types. */
|
||||
int j;
|
||||
for (j = 0; j < n_candidates; j += 1)
|
||||
switch (SYMBOL_CLASS (candidates[j].sym))
|
||||
switch (SYMBOL_CLASS (candidates[j].symbol))
|
||||
{
|
||||
case LOC_REGISTER:
|
||||
case LOC_ARG:
|
||||
|
@ -3345,7 +3345,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
|||
j = 0;
|
||||
while (j < n_candidates)
|
||||
{
|
||||
if (SYMBOL_CLASS (candidates[j].sym) == LOC_TYPEDEF)
|
||||
if (SYMBOL_CLASS (candidates[j].symbol) == LOC_TYPEDEF)
|
||||
{
|
||||
candidates[j] = candidates[n_candidates - 1];
|
||||
n_candidates -= 1;
|
||||
|
@ -3381,7 +3381,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
|||
}
|
||||
|
||||
exp->elts[pc + 1].block = candidates[i].block;
|
||||
exp->elts[pc + 2].symbol = candidates[i].sym;
|
||||
exp->elts[pc + 2].symbol = candidates[i].symbol;
|
||||
if (innermost_block == NULL
|
||||
|| contained_in (candidates[i].block, innermost_block))
|
||||
innermost_block = candidates[i].block;
|
||||
|
@ -3403,7 +3403,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
|||
if (exp->elts[pc + 3].opcode == OP_VAR_VALUE
|
||||
&& SYMBOL_DOMAIN (exp->elts[pc + 5].symbol) == UNDEF_DOMAIN)
|
||||
{
|
||||
struct ada_symbol_info *candidates;
|
||||
struct block_symbol *candidates;
|
||||
int n_candidates;
|
||||
|
||||
n_candidates =
|
||||
|
@ -3426,7 +3426,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
|||
}
|
||||
|
||||
exp->elts[pc + 4].block = candidates[i].block;
|
||||
exp->elts[pc + 5].symbol = candidates[i].sym;
|
||||
exp->elts[pc + 5].symbol = candidates[i].symbol;
|
||||
if (innermost_block == NULL
|
||||
|| contained_in (candidates[i].block, innermost_block))
|
||||
innermost_block = candidates[i].block;
|
||||
|
@ -3456,7 +3456,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
|||
case UNOP_ABS:
|
||||
if (possible_user_operator_p (op, argvec))
|
||||
{
|
||||
struct ada_symbol_info *candidates;
|
||||
struct block_symbol *candidates;
|
||||
int n_candidates;
|
||||
|
||||
n_candidates =
|
||||
|
@ -3469,7 +3469,8 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
|||
break;
|
||||
|
||||
replace_operator_with_call (expp, pc, nargs, 1,
|
||||
candidates[i].sym, candidates[i].block);
|
||||
candidates[i].symbol,
|
||||
candidates[i].block);
|
||||
exp = *expp;
|
||||
}
|
||||
break;
|
||||
|
@ -3623,7 +3624,7 @@ return_match (struct type *func_type, struct type *context_type)
|
|||
the process; the index returned is for the modified vector. */
|
||||
|
||||
static int
|
||||
ada_resolve_function (struct ada_symbol_info syms[],
|
||||
ada_resolve_function (struct block_symbol syms[],
|
||||
int nsyms, struct value **args, int nargs,
|
||||
const char *name, struct type *context_type)
|
||||
{
|
||||
|
@ -3639,9 +3640,9 @@ ada_resolve_function (struct ada_symbol_info syms[],
|
|||
{
|
||||
for (k = 0; k < nsyms; k += 1)
|
||||
{
|
||||
struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].sym));
|
||||
struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].symbol));
|
||||
|
||||
if (ada_args_match (syms[k].sym, args, nargs)
|
||||
if (ada_args_match (syms[k].symbol, args, nargs)
|
||||
&& (fallback || return_match (type, context_type)))
|
||||
{
|
||||
syms[m] = syms[k];
|
||||
|
@ -3704,19 +3705,19 @@ encoded_ordered_before (const char *N0, const char *N1)
|
|||
encoded names. */
|
||||
|
||||
static void
|
||||
sort_choices (struct ada_symbol_info syms[], int nsyms)
|
||||
sort_choices (struct block_symbol syms[], int nsyms)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i < nsyms; i += 1)
|
||||
{
|
||||
struct ada_symbol_info sym = syms[i];
|
||||
struct block_symbol sym = syms[i];
|
||||
int j;
|
||||
|
||||
for (j = i - 1; j >= 0; j -= 1)
|
||||
{
|
||||
if (encoded_ordered_before (SYMBOL_LINKAGE_NAME (syms[j].sym),
|
||||
SYMBOL_LINKAGE_NAME (sym.sym)))
|
||||
if (encoded_ordered_before (SYMBOL_LINKAGE_NAME (syms[j].symbol),
|
||||
SYMBOL_LINKAGE_NAME (sym.symbol)))
|
||||
break;
|
||||
syms[j + 1] = syms[j];
|
||||
}
|
||||
|
@ -3733,7 +3734,7 @@ sort_choices (struct ada_symbol_info syms[], int nsyms)
|
|||
to be re-integrated one of these days. */
|
||||
|
||||
int
|
||||
user_select_syms (struct ada_symbol_info *syms, int nsyms, int max_results)
|
||||
user_select_syms (struct block_symbol *syms, int nsyms, int max_results)
|
||||
{
|
||||
int i;
|
||||
int *chosen = (int *) alloca (sizeof (int) * nsyms);
|
||||
|
@ -3765,22 +3766,22 @@ See set/show multiple-symbol."));
|
|||
|
||||
for (i = 0; i < nsyms; i += 1)
|
||||
{
|
||||
if (syms[i].sym == NULL)
|
||||
if (syms[i].symbol == NULL)
|
||||
continue;
|
||||
|
||||
if (SYMBOL_CLASS (syms[i].sym) == LOC_BLOCK)
|
||||
if (SYMBOL_CLASS (syms[i].symbol) == LOC_BLOCK)
|
||||
{
|
||||
struct symtab_and_line sal =
|
||||
find_function_start_sal (syms[i].sym, 1);
|
||||
find_function_start_sal (syms[i].symbol, 1);
|
||||
|
||||
if (sal.symtab == NULL)
|
||||
printf_unfiltered (_("[%d] %s at <no source file available>:%d\n"),
|
||||
i + first_choice,
|
||||
SYMBOL_PRINT_NAME (syms[i].sym),
|
||||
SYMBOL_PRINT_NAME (syms[i].symbol),
|
||||
sal.line);
|
||||
else
|
||||
printf_unfiltered (_("[%d] %s at %s:%d\n"), i + first_choice,
|
||||
SYMBOL_PRINT_NAME (syms[i].sym),
|
||||
SYMBOL_PRINT_NAME (syms[i].symbol),
|
||||
symtab_to_filename_for_display (sal.symtab),
|
||||
sal.line);
|
||||
continue;
|
||||
|
@ -3788,42 +3789,42 @@ See set/show multiple-symbol."));
|
|||
else
|
||||
{
|
||||
int is_enumeral =
|
||||
(SYMBOL_CLASS (syms[i].sym) == LOC_CONST
|
||||
&& SYMBOL_TYPE (syms[i].sym) != NULL
|
||||
&& TYPE_CODE (SYMBOL_TYPE (syms[i].sym)) == TYPE_CODE_ENUM);
|
||||
(SYMBOL_CLASS (syms[i].symbol) == LOC_CONST
|
||||
&& SYMBOL_TYPE (syms[i].symbol) != NULL
|
||||
&& TYPE_CODE (SYMBOL_TYPE (syms[i].symbol)) == TYPE_CODE_ENUM);
|
||||
struct symtab *symtab = NULL;
|
||||
|
||||
if (SYMBOL_OBJFILE_OWNED (syms[i].sym))
|
||||
symtab = symbol_symtab (syms[i].sym);
|
||||
if (SYMBOL_OBJFILE_OWNED (syms[i].symbol))
|
||||
symtab = symbol_symtab (syms[i].symbol);
|
||||
|
||||
if (SYMBOL_LINE (syms[i].sym) != 0 && symtab != NULL)
|
||||
if (SYMBOL_LINE (syms[i].symbol) != 0 && symtab != NULL)
|
||||
printf_unfiltered (_("[%d] %s at %s:%d\n"),
|
||||
i + first_choice,
|
||||
SYMBOL_PRINT_NAME (syms[i].sym),
|
||||
SYMBOL_PRINT_NAME (syms[i].symbol),
|
||||
symtab_to_filename_for_display (symtab),
|
||||
SYMBOL_LINE (syms[i].sym));
|
||||
SYMBOL_LINE (syms[i].symbol));
|
||||
else if (is_enumeral
|
||||
&& TYPE_NAME (SYMBOL_TYPE (syms[i].sym)) != NULL)
|
||||
&& TYPE_NAME (SYMBOL_TYPE (syms[i].symbol)) != NULL)
|
||||
{
|
||||
printf_unfiltered (("[%d] "), i + first_choice);
|
||||
ada_print_type (SYMBOL_TYPE (syms[i].sym), NULL,
|
||||
ada_print_type (SYMBOL_TYPE (syms[i].symbol), NULL,
|
||||
gdb_stdout, -1, 0, &type_print_raw_options);
|
||||
printf_unfiltered (_("'(%s) (enumeral)\n"),
|
||||
SYMBOL_PRINT_NAME (syms[i].sym));
|
||||
SYMBOL_PRINT_NAME (syms[i].symbol));
|
||||
}
|
||||
else if (symtab != NULL)
|
||||
printf_unfiltered (is_enumeral
|
||||
? _("[%d] %s in %s (enumeral)\n")
|
||||
: _("[%d] %s at %s:?\n"),
|
||||
i + first_choice,
|
||||
SYMBOL_PRINT_NAME (syms[i].sym),
|
||||
SYMBOL_PRINT_NAME (syms[i].symbol),
|
||||
symtab_to_filename_for_display (symtab));
|
||||
else
|
||||
printf_unfiltered (is_enumeral
|
||||
? _("[%d] %s (enumeral)\n")
|
||||
: _("[%d] %s at ?\n"),
|
||||
i + first_choice,
|
||||
SYMBOL_PRINT_NAME (syms[i].sym));
|
||||
SYMBOL_PRINT_NAME (syms[i].symbol));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4603,13 +4604,13 @@ standard_lookup (const char *name, const struct block *block,
|
|||
domain_enum domain)
|
||||
{
|
||||
/* Initialize it just to avoid a GCC false warning. */
|
||||
struct symbol *sym = NULL;
|
||||
struct block_symbol sym = {NULL, NULL};
|
||||
|
||||
if (lookup_cached_symbol (name, domain, &sym, NULL))
|
||||
return sym;
|
||||
if (lookup_cached_symbol (name, domain, &sym.symbol, NULL))
|
||||
return sym.symbol;
|
||||
sym = lookup_symbol_in_language (name, block, domain, language_c, 0);
|
||||
cache_symbol (name, domain, sym, block_found);
|
||||
return sym;
|
||||
cache_symbol (name, domain, sym.symbol, sym.block);
|
||||
return sym.symbol;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4617,14 +4618,14 @@ standard_lookup (const char *name, const struct block *block,
|
|||
in the symbol fields of SYMS[0..N-1]. We treat enumerals as functions,
|
||||
since they contend in overloading in the same way. */
|
||||
static int
|
||||
is_nonfunction (struct ada_symbol_info syms[], int n)
|
||||
is_nonfunction (struct block_symbol syms[], int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i += 1)
|
||||
if (TYPE_CODE (SYMBOL_TYPE (syms[i].sym)) != TYPE_CODE_FUNC
|
||||
&& (TYPE_CODE (SYMBOL_TYPE (syms[i].sym)) != TYPE_CODE_ENUM
|
||||
|| SYMBOL_CLASS (syms[i].sym) != LOC_CONST))
|
||||
if (TYPE_CODE (SYMBOL_TYPE (syms[i].symbol)) != TYPE_CODE_FUNC
|
||||
&& (TYPE_CODE (SYMBOL_TYPE (syms[i].symbol)) != TYPE_CODE_ENUM
|
||||
|| SYMBOL_CLASS (syms[i].symbol) != LOC_CONST))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -4688,7 +4689,7 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1)
|
|||
}
|
||||
}
|
||||
|
||||
/* Append (SYM,BLOCK,SYMTAB) to the end of the array of struct ada_symbol_info
|
||||
/* Append (SYM,BLOCK,SYMTAB) to the end of the array of struct block_symbol
|
||||
records in OBSTACKP. Do nothing if SYM is a duplicate. */
|
||||
|
||||
static void
|
||||
|
@ -4697,7 +4698,7 @@ add_defn_to_vec (struct obstack *obstackp,
|
|||
const struct block *block)
|
||||
{
|
||||
int i;
|
||||
struct ada_symbol_info *prevDefns = defns_collected (obstackp, 0);
|
||||
struct block_symbol *prevDefns = defns_collected (obstackp, 0);
|
||||
|
||||
/* Do not try to complete stub types, as the debugger is probably
|
||||
already scanning all symbols matching a certain name at the
|
||||
|
@ -4710,45 +4711,44 @@ add_defn_to_vec (struct obstack *obstackp,
|
|||
|
||||
for (i = num_defns_collected (obstackp) - 1; i >= 0; i -= 1)
|
||||
{
|
||||
if (lesseq_defined_than (sym, prevDefns[i].sym))
|
||||
if (lesseq_defined_than (sym, prevDefns[i].symbol))
|
||||
return;
|
||||
else if (lesseq_defined_than (prevDefns[i].sym, sym))
|
||||
else if (lesseq_defined_than (prevDefns[i].symbol, sym))
|
||||
{
|
||||
prevDefns[i].sym = sym;
|
||||
prevDefns[i].symbol = sym;
|
||||
prevDefns[i].block = block;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
struct ada_symbol_info info;
|
||||
struct block_symbol info;
|
||||
|
||||
info.sym = sym;
|
||||
info.symbol = sym;
|
||||
info.block = block;
|
||||
obstack_grow (obstackp, &info, sizeof (struct ada_symbol_info));
|
||||
obstack_grow (obstackp, &info, sizeof (struct block_symbol));
|
||||
}
|
||||
}
|
||||
|
||||
/* Number of ada_symbol_info structures currently collected in
|
||||
current vector in *OBSTACKP. */
|
||||
/* Number of block_symbol structures currently collected in current vector in
|
||||
OBSTACKP. */
|
||||
|
||||
static int
|
||||
num_defns_collected (struct obstack *obstackp)
|
||||
{
|
||||
return obstack_object_size (obstackp) / sizeof (struct ada_symbol_info);
|
||||
return obstack_object_size (obstackp) / sizeof (struct block_symbol);
|
||||
}
|
||||
|
||||
/* Vector of ada_symbol_info structures currently collected in current
|
||||
vector in *OBSTACKP. If FINISH, close off the vector and return
|
||||
its final address. */
|
||||
/* Vector of block_symbol structures currently collected in current vector in
|
||||
OBSTACKP. If FINISH, close off the vector and return its final address. */
|
||||
|
||||
static struct ada_symbol_info *
|
||||
static struct block_symbol *
|
||||
defns_collected (struct obstack *obstackp, int finish)
|
||||
{
|
||||
if (finish)
|
||||
return obstack_finish (obstackp);
|
||||
else
|
||||
return (struct ada_symbol_info *) obstack_base (obstackp);
|
||||
return (struct block_symbol *) obstack_base (obstackp);
|
||||
}
|
||||
|
||||
/* Return a bound minimal symbol matching NAME according to Ada
|
||||
|
@ -4879,7 +4879,7 @@ ada_identical_enum_types_p (struct type *type1, struct type *type2)
|
|||
So, for practical purposes, we consider them as the same. */
|
||||
|
||||
static int
|
||||
symbols_are_identical_enums (struct ada_symbol_info *syms, int nsyms)
|
||||
symbols_are_identical_enums (struct block_symbol *syms, int nsyms)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -4892,26 +4892,26 @@ symbols_are_identical_enums (struct ada_symbol_info *syms, int nsyms)
|
|||
|
||||
/* Quick check: All symbols should have an enum type. */
|
||||
for (i = 0; i < nsyms; i++)
|
||||
if (TYPE_CODE (SYMBOL_TYPE (syms[i].sym)) != TYPE_CODE_ENUM)
|
||||
if (TYPE_CODE (SYMBOL_TYPE (syms[i].symbol)) != TYPE_CODE_ENUM)
|
||||
return 0;
|
||||
|
||||
/* Quick check: They should all have the same value. */
|
||||
for (i = 1; i < nsyms; i++)
|
||||
if (SYMBOL_VALUE (syms[i].sym) != SYMBOL_VALUE (syms[0].sym))
|
||||
if (SYMBOL_VALUE (syms[i].symbol) != SYMBOL_VALUE (syms[0].symbol))
|
||||
return 0;
|
||||
|
||||
/* Quick check: They should all have the same number of enumerals. */
|
||||
for (i = 1; i < nsyms; i++)
|
||||
if (TYPE_NFIELDS (SYMBOL_TYPE (syms[i].sym))
|
||||
!= TYPE_NFIELDS (SYMBOL_TYPE (syms[0].sym)))
|
||||
if (TYPE_NFIELDS (SYMBOL_TYPE (syms[i].symbol))
|
||||
!= TYPE_NFIELDS (SYMBOL_TYPE (syms[0].symbol)))
|
||||
return 0;
|
||||
|
||||
/* All the sanity checks passed, so we might have a set of
|
||||
identical enumeration types. Perform a more complete
|
||||
comparison of the type of each symbol. */
|
||||
for (i = 1; i < nsyms; i++)
|
||||
if (!ada_identical_enum_types_p (SYMBOL_TYPE (syms[i].sym),
|
||||
SYMBOL_TYPE (syms[0].sym)))
|
||||
if (!ada_identical_enum_types_p (SYMBOL_TYPE (syms[i].symbol),
|
||||
SYMBOL_TYPE (syms[0].symbol)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
@ -4925,7 +4925,7 @@ symbols_are_identical_enums (struct ada_symbol_info *syms, int nsyms)
|
|||
Returns the number of items in the modified list. */
|
||||
|
||||
static int
|
||||
remove_extra_symbols (struct ada_symbol_info *syms, int nsyms)
|
||||
remove_extra_symbols (struct block_symbol *syms, int nsyms)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
@ -4943,16 +4943,16 @@ remove_extra_symbols (struct ada_symbol_info *syms, int nsyms)
|
|||
/* If two symbols have the same name and one of them is a stub type,
|
||||
the get rid of the stub. */
|
||||
|
||||
if (TYPE_STUB (SYMBOL_TYPE (syms[i].sym))
|
||||
&& SYMBOL_LINKAGE_NAME (syms[i].sym) != NULL)
|
||||
if (TYPE_STUB (SYMBOL_TYPE (syms[i].symbol))
|
||||
&& SYMBOL_LINKAGE_NAME (syms[i].symbol) != NULL)
|
||||
{
|
||||
for (j = 0; j < nsyms; j++)
|
||||
{
|
||||
if (j != i
|
||||
&& !TYPE_STUB (SYMBOL_TYPE (syms[j].sym))
|
||||
&& SYMBOL_LINKAGE_NAME (syms[j].sym) != NULL
|
||||
&& strcmp (SYMBOL_LINKAGE_NAME (syms[i].sym),
|
||||
SYMBOL_LINKAGE_NAME (syms[j].sym)) == 0)
|
||||
&& !TYPE_STUB (SYMBOL_TYPE (syms[j].symbol))
|
||||
&& SYMBOL_LINKAGE_NAME (syms[j].symbol) != NULL
|
||||
&& strcmp (SYMBOL_LINKAGE_NAME (syms[i].symbol),
|
||||
SYMBOL_LINKAGE_NAME (syms[j].symbol)) == 0)
|
||||
remove_p = 1;
|
||||
}
|
||||
}
|
||||
|
@ -4960,19 +4960,20 @@ remove_extra_symbols (struct ada_symbol_info *syms, int nsyms)
|
|||
/* Two symbols with the same name, same class and same address
|
||||
should be identical. */
|
||||
|
||||
else if (SYMBOL_LINKAGE_NAME (syms[i].sym) != NULL
|
||||
&& SYMBOL_CLASS (syms[i].sym) == LOC_STATIC
|
||||
&& is_nondebugging_type (SYMBOL_TYPE (syms[i].sym)))
|
||||
else if (SYMBOL_LINKAGE_NAME (syms[i].symbol) != NULL
|
||||
&& SYMBOL_CLASS (syms[i].symbol) == LOC_STATIC
|
||||
&& is_nondebugging_type (SYMBOL_TYPE (syms[i].symbol)))
|
||||
{
|
||||
for (j = 0; j < nsyms; j += 1)
|
||||
{
|
||||
if (i != j
|
||||
&& SYMBOL_LINKAGE_NAME (syms[j].sym) != NULL
|
||||
&& strcmp (SYMBOL_LINKAGE_NAME (syms[i].sym),
|
||||
SYMBOL_LINKAGE_NAME (syms[j].sym)) == 0
|
||||
&& SYMBOL_CLASS (syms[i].sym) == SYMBOL_CLASS (syms[j].sym)
|
||||
&& SYMBOL_VALUE_ADDRESS (syms[i].sym)
|
||||
== SYMBOL_VALUE_ADDRESS (syms[j].sym))
|
||||
&& SYMBOL_LINKAGE_NAME (syms[j].symbol) != NULL
|
||||
&& strcmp (SYMBOL_LINKAGE_NAME (syms[i].symbol),
|
||||
SYMBOL_LINKAGE_NAME (syms[j].symbol)) == 0
|
||||
&& SYMBOL_CLASS (syms[i].symbol)
|
||||
== SYMBOL_CLASS (syms[j].symbol)
|
||||
&& SYMBOL_VALUE_ADDRESS (syms[i].symbol)
|
||||
== SYMBOL_VALUE_ADDRESS (syms[j].symbol))
|
||||
remove_p = 1;
|
||||
}
|
||||
}
|
||||
|
@ -5151,7 +5152,7 @@ old_renaming_is_invisible (const struct symbol *sym, const char *function_name)
|
|||
the user will be unable to print such rename entities. */
|
||||
|
||||
static int
|
||||
remove_irrelevant_renamings (struct ada_symbol_info *syms,
|
||||
remove_irrelevant_renamings (struct block_symbol *syms,
|
||||
int nsyms, const struct block *current_block)
|
||||
{
|
||||
struct symbol *current_function;
|
||||
|
@ -5165,7 +5166,7 @@ remove_irrelevant_renamings (struct ada_symbol_info *syms,
|
|||
is_new_style_renaming = 0;
|
||||
for (i = 0; i < nsyms; i += 1)
|
||||
{
|
||||
struct symbol *sym = syms[i].sym;
|
||||
struct symbol *sym = syms[i].symbol;
|
||||
const struct block *block = syms[i].block;
|
||||
const char *name;
|
||||
const char *suffix;
|
||||
|
@ -5182,11 +5183,11 @@ remove_irrelevant_renamings (struct ada_symbol_info *syms,
|
|||
|
||||
is_new_style_renaming = 1;
|
||||
for (j = 0; j < nsyms; j += 1)
|
||||
if (i != j && syms[j].sym != NULL
|
||||
&& strncmp (name, SYMBOL_LINKAGE_NAME (syms[j].sym),
|
||||
if (i != j && syms[j].symbol != NULL
|
||||
&& strncmp (name, SYMBOL_LINKAGE_NAME (syms[j].symbol),
|
||||
name_len) == 0
|
||||
&& block == syms[j].block)
|
||||
syms[j].sym = NULL;
|
||||
syms[j].symbol = NULL;
|
||||
}
|
||||
}
|
||||
if (is_new_style_renaming)
|
||||
|
@ -5194,7 +5195,7 @@ remove_irrelevant_renamings (struct ada_symbol_info *syms,
|
|||
int j, k;
|
||||
|
||||
for (j = k = 0; j < nsyms; j += 1)
|
||||
if (syms[j].sym != NULL)
|
||||
if (syms[j].symbol != NULL)
|
||||
{
|
||||
syms[k] = syms[j];
|
||||
k += 1;
|
||||
|
@ -5223,9 +5224,9 @@ remove_irrelevant_renamings (struct ada_symbol_info *syms,
|
|||
i = 0;
|
||||
while (i < nsyms)
|
||||
{
|
||||
if (ada_parse_renaming (syms[i].sym, NULL, NULL, NULL)
|
||||
if (ada_parse_renaming (syms[i].symbol, NULL, NULL, NULL)
|
||||
== ADA_OBJECT_RENAMING
|
||||
&& old_renaming_is_invisible (syms[i].sym, current_function_name))
|
||||
&& old_renaming_is_invisible (syms[i].symbol, current_function_name))
|
||||
{
|
||||
int j;
|
||||
|
||||
|
@ -5479,7 +5480,7 @@ add_nonlocal_symbols (struct obstack *obstackp, const char *name,
|
|||
static int
|
||||
ada_lookup_symbol_list_worker (const char *name0, const struct block *block0,
|
||||
domain_enum domain,
|
||||
struct ada_symbol_info **results,
|
||||
struct block_symbol **results,
|
||||
int full_search)
|
||||
{
|
||||
struct symbol *sym;
|
||||
|
@ -5566,7 +5567,7 @@ done:
|
|||
cache_symbol (name0, domain, NULL, NULL);
|
||||
|
||||
if (ndefns == 1 && full_search && syms_from_global_search)
|
||||
cache_symbol (name0, domain, (*results)[0].sym, (*results)[0].block);
|
||||
cache_symbol (name0, domain, (*results)[0].symbol, (*results)[0].block);
|
||||
|
||||
ndefns = remove_irrelevant_renamings (*results, ndefns, block0);
|
||||
|
||||
|
@ -5580,7 +5581,7 @@ done:
|
|||
|
||||
int
|
||||
ada_lookup_symbol_list (const char *name0, const struct block *block0,
|
||||
domain_enum domain, struct ada_symbol_info **results)
|
||||
domain_enum domain, struct block_symbol **results)
|
||||
{
|
||||
return ada_lookup_symbol_list_worker (name0, block0, domain, results, 1);
|
||||
}
|
||||
|
@ -5594,12 +5595,12 @@ ada_iterate_over_symbols (const struct block *block,
|
|||
void *data)
|
||||
{
|
||||
int ndefs, i;
|
||||
struct ada_symbol_info *results;
|
||||
struct block_symbol *results;
|
||||
|
||||
ndefs = ada_lookup_symbol_list_worker (name, block, domain, &results, 0);
|
||||
for (i = 0; i < ndefs; ++i)
|
||||
{
|
||||
if (! (*callback) (results[i].sym, data))
|
||||
if (! (*callback) (results[i].symbol, data))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5639,20 +5640,20 @@ ada_name_for_lookup (const char *name)
|
|||
void
|
||||
ada_lookup_encoded_symbol (const char *name, const struct block *block,
|
||||
domain_enum domain,
|
||||
struct ada_symbol_info *info)
|
||||
struct block_symbol *info)
|
||||
{
|
||||
struct ada_symbol_info *candidates;
|
||||
struct block_symbol *candidates;
|
||||
int n_candidates;
|
||||
|
||||
gdb_assert (info != NULL);
|
||||
memset (info, 0, sizeof (struct ada_symbol_info));
|
||||
memset (info, 0, sizeof (struct block_symbol));
|
||||
|
||||
n_candidates = ada_lookup_symbol_list (name, block, domain, &candidates);
|
||||
if (n_candidates == 0)
|
||||
return;
|
||||
|
||||
*info = candidates[0];
|
||||
info->sym = fixup_symbol_section (info->sym, NULL);
|
||||
info->symbol = fixup_symbol_section (info->symbol, NULL);
|
||||
}
|
||||
|
||||
/* Return a symbol in DOMAIN matching NAME, in BLOCK0 and enclosing
|
||||
|
@ -5661,30 +5662,30 @@ ada_lookup_encoded_symbol (const char *name, const struct block *block,
|
|||
choosing the first symbol if there are multiple choices.
|
||||
If IS_A_FIELD_OF_THIS is not NULL, it is set to zero. */
|
||||
|
||||
struct symbol *
|
||||
struct block_symbol
|
||||
ada_lookup_symbol (const char *name, const struct block *block0,
|
||||
domain_enum domain, int *is_a_field_of_this)
|
||||
{
|
||||
struct ada_symbol_info info;
|
||||
struct block_symbol info;
|
||||
|
||||
if (is_a_field_of_this != NULL)
|
||||
*is_a_field_of_this = 0;
|
||||
|
||||
ada_lookup_encoded_symbol (ada_encode (ada_fold_name (name)),
|
||||
block0, domain, &info);
|
||||
return info.sym;
|
||||
return info;
|
||||
}
|
||||
|
||||
static struct symbol *
|
||||
static struct block_symbol
|
||||
ada_lookup_symbol_nonlocal (const struct language_defn *langdef,
|
||||
const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct block_symbol sym;
|
||||
|
||||
sym = ada_lookup_symbol (name, block_static_block (block), domain, NULL);
|
||||
if (sym != NULL)
|
||||
if (sym.symbol != NULL)
|
||||
return sym;
|
||||
|
||||
/* If we haven't found a match at this point, try the primitive
|
||||
|
@ -5707,12 +5708,12 @@ ada_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)
|
||||
sym.symbol = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name);
|
||||
if (sym.symbol != NULL)
|
||||
return sym;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return (struct block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
|
||||
|
@ -11372,7 +11373,7 @@ scan_discrim_bound (char *str, int k, struct value *dval, LONGEST * px,
|
|||
static struct value *
|
||||
get_var_value (char *name, char *err_msg)
|
||||
{
|
||||
struct ada_symbol_info *syms;
|
||||
struct block_symbol *syms;
|
||||
int nsyms;
|
||||
|
||||
nsyms = ada_lookup_symbol_list (name, get_selected_block (0), VAR_DOMAIN,
|
||||
|
@ -11386,7 +11387,7 @@ get_var_value (char *name, char *err_msg)
|
|||
error (("%s"), err_msg);
|
||||
}
|
||||
|
||||
return value_of_variable (syms[0].sym, syms[0].block);
|
||||
return value_of_variable (syms[0].symbol, syms[0].block);
|
||||
}
|
||||
|
||||
/* Value of integer variable named NAME in the current environment. If
|
||||
|
|
|
@ -79,17 +79,6 @@ struct ada_opname_map
|
|||
/* Defined in ada-lang.c */
|
||||
extern const struct ada_opname_map ada_opname_table[];
|
||||
|
||||
/* A tuple representing one instance of a symbol-lookup operation. */
|
||||
|
||||
struct ada_symbol_info
|
||||
{
|
||||
/* The symbol that was found. */
|
||||
struct symbol *sym;
|
||||
|
||||
/* The block where the symbol was found. */
|
||||
const struct block *block;
|
||||
};
|
||||
|
||||
/* Denotes a type of renaming symbol (see ada_parse_renaming). */
|
||||
enum ada_renaming_category
|
||||
{
|
||||
|
@ -236,22 +225,23 @@ extern const char *ada_decode (const char*);
|
|||
extern enum language ada_update_initial_language (enum language);
|
||||
|
||||
extern int ada_lookup_symbol_list (const char *, const struct block *,
|
||||
domain_enum, struct ada_symbol_info**);
|
||||
domain_enum, struct block_symbol**);
|
||||
|
||||
extern char *ada_fold_name (const char *);
|
||||
|
||||
extern struct symbol *ada_lookup_symbol (const char *, const struct block *,
|
||||
extern struct block_symbol ada_lookup_symbol (const char *,
|
||||
const struct block *,
|
||||
domain_enum, int *);
|
||||
|
||||
extern void ada_lookup_encoded_symbol
|
||||
(const char *name, const struct block *block, domain_enum domain,
|
||||
struct ada_symbol_info *symbol_info);
|
||||
struct block_symbol *symbol_info);
|
||||
|
||||
extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *);
|
||||
|
||||
extern void ada_fill_in_ada_prototype (struct symbol *);
|
||||
|
||||
extern int user_select_syms (struct ada_symbol_info *, int, int);
|
||||
extern int user_select_syms (struct block_symbol *, int, int);
|
||||
|
||||
extern int get_selections (int *, int, int, int, char *);
|
||||
|
||||
|
|
|
@ -471,23 +471,24 @@ get_tcb_types_info (void)
|
|||
|
||||
struct symbol *atcb_sym =
|
||||
lookup_symbol_in_language (atcb_name, NULL, STRUCT_DOMAIN,
|
||||
language_c, NULL);
|
||||
language_c, NULL).symbol;
|
||||
const struct symbol *common_atcb_sym =
|
||||
lookup_symbol_in_language (common_atcb_name, NULL, STRUCT_DOMAIN,
|
||||
language_c, NULL);
|
||||
language_c, NULL).symbol;
|
||||
const struct symbol *private_data_sym =
|
||||
lookup_symbol_in_language (private_data_name, NULL, STRUCT_DOMAIN,
|
||||
language_c, NULL);
|
||||
language_c, NULL).symbol;
|
||||
const struct symbol *entry_call_record_sym =
|
||||
lookup_symbol_in_language (entry_call_record_name, NULL, STRUCT_DOMAIN,
|
||||
language_c, NULL);
|
||||
language_c, NULL).symbol;
|
||||
|
||||
if (atcb_sym == NULL || atcb_sym->type == NULL)
|
||||
{
|
||||
/* In Ravenscar run-time libs, the ATCB does not have a dynamic
|
||||
size, so the symbol name differs. */
|
||||
atcb_sym = lookup_symbol_in_language (atcb_name_fixed, NULL,
|
||||
STRUCT_DOMAIN, language_c, NULL);
|
||||
STRUCT_DOMAIN, language_c,
|
||||
NULL).symbol;
|
||||
|
||||
if (atcb_sym == NULL || atcb_sym->type == NULL)
|
||||
error (_("Cannot find Ada_Task_Control_Block type. Aborting"));
|
||||
|
@ -863,7 +864,7 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
|
|||
|
||||
/* Try to get pointer type and array length from the symtab. */
|
||||
sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL, VAR_DOMAIN,
|
||||
language_c, NULL);
|
||||
language_c, NULL).symbol;
|
||||
if (sym != NULL)
|
||||
{
|
||||
/* Validate. */
|
||||
|
@ -908,7 +909,7 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
|
|||
data->known_tasks_length = 1;
|
||||
|
||||
sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL, VAR_DOMAIN,
|
||||
language_c, NULL);
|
||||
language_c, NULL).symbol;
|
||||
if (sym != NULL && SYMBOL_VALUE_ADDRESS (sym) != 0)
|
||||
{
|
||||
/* Validate. */
|
||||
|
|
12
gdb/ax-gdb.c
12
gdb/ax-gdb.c
|
@ -1556,7 +1556,7 @@ gen_static_field (struct gdbarch *gdbarch,
|
|||
else
|
||||
{
|
||||
const char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
|
||||
struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0);
|
||||
struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0).symbol;
|
||||
|
||||
if (sym)
|
||||
{
|
||||
|
@ -1647,20 +1647,20 @@ gen_maybe_namespace_elt (struct expression *exp,
|
|||
const struct type *curtype, char *name)
|
||||
{
|
||||
const char *namespace_name = TYPE_TAG_NAME (curtype);
|
||||
struct symbol *sym;
|
||||
struct block_symbol sym;
|
||||
|
||||
sym = cp_lookup_symbol_namespace (namespace_name, name,
|
||||
block_for_pc (ax->scope),
|
||||
VAR_DOMAIN);
|
||||
|
||||
if (sym == NULL)
|
||||
if (sym.symbol == NULL)
|
||||
return 0;
|
||||
|
||||
gen_var_ref (exp->gdbarch, ax, value, sym);
|
||||
gen_var_ref (exp->gdbarch, ax, value, sym.symbol);
|
||||
|
||||
if (value->optimized_out)
|
||||
error (_("`%s' has been optimized out, cannot use"),
|
||||
SYMBOL_PRINT_NAME (sym));
|
||||
SYMBOL_PRINT_NAME (sym.symbol));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -2194,7 +2194,7 @@ gen_expr (struct expression *exp, union exp_element **pc,
|
|||
func = block_linkage_function (b);
|
||||
lang = language_def (SYMBOL_LANGUAGE (func));
|
||||
|
||||
sym = lookup_language_this (lang, b);
|
||||
sym = lookup_language_this (lang, b).symbol;
|
||||
if (!sym)
|
||||
error (_("no `%s' found"), lang->la_name_of_this);
|
||||
|
||||
|
|
97
gdb/c-exp.y
97
gdb/c-exp.y
|
@ -923,8 +923,8 @@ exp : FALSEKEYWORD
|
|||
|
||||
block : BLOCKNAME
|
||||
{
|
||||
if ($1.sym)
|
||||
$$ = SYMBOL_BLOCK_VALUE ($1.sym);
|
||||
if ($1.sym.symbol)
|
||||
$$ = SYMBOL_BLOCK_VALUE ($1.sym.symbol);
|
||||
else
|
||||
error (_("No file or function \"%s\"."),
|
||||
copy_name ($1.stoken));
|
||||
|
@ -938,7 +938,8 @@ 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));
|
||||
|
@ -946,7 +947,7 @@ block : block COLONCOLON name
|
|||
;
|
||||
|
||||
variable: name_not_typename ENTRY
|
||||
{ struct symbol *sym = $1.sym;
|
||||
{ struct symbol *sym = $1.sym.symbol;
|
||||
|
||||
if (sym == NULL || !SYMBOL_IS_ARGUMENT (sym)
|
||||
|| !symbol_read_needs_frame (sym))
|
||||
|
@ -961,24 +962,24 @@ variable: name_not_typename ENTRY
|
|||
;
|
||||
|
||||
variable: block COLONCOLON name
|
||||
{ struct symbol *sym;
|
||||
sym = lookup_symbol (copy_name ($3), $1,
|
||||
{ struct block_symbol 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));
|
||||
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); }
|
||||
;
|
||||
|
||||
|
@ -1035,9 +1036,9 @@ variable: qualified_name
|
|||
struct symbol *sym;
|
||||
struct bound_minimal_symbol msymbol;
|
||||
|
||||
sym =
|
||||
lookup_symbol (name, (const struct block *) NULL,
|
||||
VAR_DOMAIN, NULL);
|
||||
sym
|
||||
= lookup_symbol (name, (const struct block *) NULL,
|
||||
VAR_DOMAIN, NULL).symbol;
|
||||
if (sym)
|
||||
{
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
|
@ -1058,16 +1059,16 @@ variable: qualified_name
|
|||
;
|
||||
|
||||
variable: name_not_typename
|
||||
{ struct symbol *sym = $1.sym;
|
||||
{ struct block_symbol 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);
|
||||
|
@ -1075,7 +1076,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)
|
||||
|
@ -1084,9 +1085,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);
|
||||
|
@ -2817,7 +2818,7 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name)
|
|||
VAR_DOMAIN,
|
||||
(parse_language (par_state)->la_language
|
||||
== language_cplus ? &is_a_field_of_this
|
||||
: NULL))
|
||||
: NULL)).symbol
|
||||
!= NULL)
|
||||
{
|
||||
/* The keyword is shadowed. */
|
||||
|
@ -2838,7 +2839,8 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name)
|
|||
saw_name_at_eof = 1;
|
||||
|
||||
yylval.ssym.stoken = yylval.sval;
|
||||
yylval.ssym.sym = NULL;
|
||||
yylval.ssym.sym.symbol = NULL;
|
||||
yylval.ssym.sym.block = NULL;
|
||||
yylval.ssym.is_a_field_of_this = 0;
|
||||
return NAME;
|
||||
}
|
||||
|
@ -2873,7 +2875,7 @@ static int
|
|||
classify_name (struct parser_state *par_state, const struct block *block,
|
||||
int is_quoted_name)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct block_symbol bsym;
|
||||
char *copy;
|
||||
struct field_of_this_result is_a_field_of_this;
|
||||
|
||||
|
@ -2883,17 +2885,17 @@ classify_name (struct parser_state *par_state, const struct block *block,
|
|||
we can refer to it unconditionally below. */
|
||||
memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
|
||||
|
||||
sym = lookup_symbol (copy, block, VAR_DOMAIN,
|
||||
bsym = lookup_symbol (copy, block, VAR_DOMAIN,
|
||||
parse_language (par_state)->la_name_of_this
|
||||
? &is_a_field_of_this : NULL);
|
||||
|
||||
if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
|
||||
if (bsym.symbol && SYMBOL_CLASS (bsym.symbol) == LOC_BLOCK)
|
||||
{
|
||||
yylval.ssym.sym = sym;
|
||||
yylval.ssym.sym = bsym;
|
||||
yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
|
||||
return BLOCKNAME;
|
||||
}
|
||||
else if (!sym)
|
||||
else if (!bsym.symbol)
|
||||
{
|
||||
/* If we found a field of 'this', we might have erroneously
|
||||
found a constructor where we wanted a type name. Handle this
|
||||
|
@ -2906,11 +2908,11 @@ classify_name (struct parser_state *par_state, const struct block *block,
|
|||
{
|
||||
struct field_of_this_result inner_is_a_field_of_this;
|
||||
|
||||
sym = lookup_symbol (copy, block, STRUCT_DOMAIN,
|
||||
bsym = lookup_symbol (copy, block, STRUCT_DOMAIN,
|
||||
&inner_is_a_field_of_this);
|
||||
if (sym != NULL)
|
||||
if (bsym.symbol != NULL)
|
||||
{
|
||||
yylval.tsym.type = SYMBOL_TYPE (sym);
|
||||
yylval.tsym.type = SYMBOL_TYPE (bsym.symbol);
|
||||
return TYPENAME;
|
||||
}
|
||||
}
|
||||
|
@ -2934,18 +2936,20 @@ classify_name (struct parser_state *par_state, const struct block *block,
|
|||
}
|
||||
}
|
||||
|
||||
if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
|
||||
if (bsym.symbol && SYMBOL_CLASS (bsym.symbol) == LOC_TYPEDEF)
|
||||
{
|
||||
yylval.tsym.type = SYMBOL_TYPE (sym);
|
||||
yylval.tsym.type = SYMBOL_TYPE (bsym.symbol);
|
||||
return TYPENAME;
|
||||
}
|
||||
|
||||
/* See if it's an ObjC classname. */
|
||||
if (parse_language (par_state)->la_language == language_objc && !sym)
|
||||
if (parse_language (par_state)->la_language == language_objc && !bsym.symbol)
|
||||
{
|
||||
CORE_ADDR Class = lookup_objc_class (parse_gdbarch (par_state), copy);
|
||||
if (Class)
|
||||
{
|
||||
struct symbol *sym;
|
||||
|
||||
yylval.theclass.theclass = Class;
|
||||
sym = lookup_struct_typedef (copy, expression_context_block, 1);
|
||||
if (sym)
|
||||
|
@ -2957,26 +2961,27 @@ 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 (!bsym.symbol
|
||||
&& ((copy[0] >= 'a' && copy[0] < 'a' + input_radix - 10)
|
||||
|| (copy[0] >= 'A' && copy[0] < 'A' + input_radix - 10)))
|
||||
{
|
||||
YYSTYPE newlval; /* Its value is ignored. */
|
||||
int hextype = parse_number (par_state, copy, yylval.sval.length,
|
||||
0, &newlval);
|
||||
|
||||
if (hextype == INT)
|
||||
{
|
||||
yylval.ssym.sym = sym;
|
||||
yylval.ssym.sym = bsym;
|
||||
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 = bsym;
|
||||
yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
|
||||
|
||||
if (sym == NULL
|
||||
if (bsym.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 +3015,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 +3028,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 +3047,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 +3307,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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -304,13 +304,11 @@ 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 block_symbol sym, domain_enum domain)
|
||||
{
|
||||
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 +321,24 @@ convert_symbol_sym (struct compile_c_instance *context, const char *identifier,
|
|||
}
|
||||
*/
|
||||
|
||||
static_block = block_static_block (found_block);
|
||||
static_block = block_static_block (sym.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 = (sym.block != static_block && static_block != NULL);
|
||||
if (is_local_symbol)
|
||||
{
|
||||
struct symbol *global_sym;
|
||||
struct block_symbol 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -348,7 +346,7 @@ convert_symbol_sym (struct compile_c_instance *context, const char *identifier,
|
|||
fprintf_unfiltered (gdb_stdlog,
|
||||
"gcc_convert_symbol \"%s\": local symbol\n",
|
||||
identifier);
|
||||
convert_one_symbol (context, sym, 0, is_local_symbol);
|
||||
convert_one_symbol (context, sym.symbol, 0, is_local_symbol);
|
||||
}
|
||||
|
||||
/* Convert a minimal symbol to its gcc form. CONTEXT is the compiler
|
||||
|
@ -444,10 +442,10 @@ gcc_convert_symbol (void *datum,
|
|||
is to simply emit a gcc error. */
|
||||
TRY
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct block_symbol sym;
|
||||
|
||||
sym = lookup_symbol (identifier, context->base.block, domain, NULL);
|
||||
if (sym != NULL)
|
||||
if (sym.symbol != NULL)
|
||||
{
|
||||
convert_symbol_sym (context, identifier, sym, domain);
|
||||
found = 1;
|
||||
|
@ -495,7 +493,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)
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "buildsym.h"
|
||||
#include "language.h"
|
||||
|
||||
static struct symbol *
|
||||
static struct block_symbol
|
||||
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 block_symbol
|
||||
cp_basic_lookup_symbol (const char *name, const struct block *block,
|
||||
const domain_enum domain, int is_in_anonymous)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct block_symbol 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);
|
||||
}
|
||||
|
||||
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 block_symbol
|
||||
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 block_symbol 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 block_symbol 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 block_symbol) {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 block_symbol) {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 block_symbol
|
||||
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 block_symbol sym;
|
||||
char *klass, *nested;
|
||||
struct cleanup *cleanup;
|
||||
struct symbol *klass_sym;
|
||||
struct block_symbol 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 block_symbol) {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 block_symbol
|
||||
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 block_symbol 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 block_symbol
|
||||
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 block_symbol 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 block_symbol) {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 block_symbol
|
||||
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 block_symbol result;
|
||||
|
||||
if (symbol_lookup_debug)
|
||||
{
|
||||
|
@ -629,20 +634,20 @@ cp_lookup_symbol_imports_or_template (const char *scope,
|
|||
{
|
||||
struct template_symbol *templ
|
||||
= (struct template_symbol *) function;
|
||||
|
||||
result = search_symbol_list (name,
|
||||
struct symbol *sym = search_symbol_list (name,
|
||||
templ->n_template_arguments,
|
||||
templ->template_arguments);
|
||||
if (result != NULL)
|
||||
|
||||
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 block_symbol) {sym, block};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,6 +661,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 +680,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 block_symbol) {sym, parent};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -701,8 +707,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 +717,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 block_symbol
|
||||
cp_lookup_symbol_via_all_imports (const char *scope, const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct block_symbol 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 block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
/* Searches for NAME in the current namespace, and by applying
|
||||
|
@ -735,13 +741,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 block_symbol
|
||||
cp_lookup_symbol_namespace (const char *scope,
|
||||
const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct block_symbol sym;
|
||||
|
||||
if (symbol_lookup_debug)
|
||||
{
|
||||
|
@ -755,14 +761,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 +789,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 block_symbol
|
||||
lookup_namespace_scope (const struct language_defn *langdef,
|
||||
const char *name,
|
||||
const struct block *block,
|
||||
|
@ -796,7 +803,7 @@ lookup_namespace_scope (const struct language_defn *langdef,
|
|||
{
|
||||
/* Recursively search for names in child namespaces first. */
|
||||
|
||||
struct symbol *sym;
|
||||
struct block_symbol sym;
|
||||
int new_scope_len = scope_len;
|
||||
|
||||
/* If the current scope is followed by "::", skip past that. */
|
||||
|
@ -808,7 +815,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 +846,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 block_symbol
|
||||
cp_lookup_symbol_nonlocal (const struct language_defn *langdef,
|
||||
const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct block_symbol sym;
|
||||
const char *scope = block_scope (block);
|
||||
|
||||
if (symbol_lookup_debug)
|
||||
|
@ -862,14 +869,16 @@ 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 +914,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 block_symbol
|
||||
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 block_symbol 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 +944,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 +964,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 block_symbol
|
||||
cp_lookup_nested_symbol_1 (struct type *container_type,
|
||||
const char *nested_name,
|
||||
const char *concatenated_name,
|
||||
|
@ -962,7 +972,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 block_symbol sym;
|
||||
|
||||
/* NOTE: carlton/2003-11-10: We don't treat C++ class members
|
||||
of classes like, say, data or function members. Instead,
|
||||
|
@ -975,7 +985,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 +996,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 +1007,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 +1017,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 block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
/* Look up a symbol named NESTED_NAME that is nested inside the C++
|
||||
|
@ -1019,7 +1029,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 block_symbol
|
||||
cp_lookup_nested_symbol (struct type *parent_type,
|
||||
const char *nested_name,
|
||||
const struct block *block,
|
||||
|
@ -1055,7 +1065,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 block_symbol sym;
|
||||
char *concatenated_name;
|
||||
int is_in_anonymous;
|
||||
|
||||
|
@ -1073,8 +1083,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 +1098,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
|
|||
"cp_lookup_nested_symbol (...) = NULL"
|
||||
" (func/method)\n");
|
||||
}
|
||||
return NULL;
|
||||
return (struct block_symbol) {NULL, NULL};
|
||||
|
||||
default:
|
||||
internal_error (__FILE__, __LINE__,
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -192,24 +192,26 @@ 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 block_symbol 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,
|
||||
extern struct block_symbol
|
||||
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 block_symbol 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,
|
||||
extern struct block_symbol
|
||||
cp_lookup_nested_symbol (struct type *parent_type,
|
||||
const char *nested_name,
|
||||
const struct block *block,
|
||||
const domain_enum domain);
|
||||
|
|
27
gdb/d-exp.y
27
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,24 @@ 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,
|
||||
struct block_symbol sym
|
||||
= lookup_symbol (copy, 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 (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 +1079,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 +1181,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)
|
||||
{
|
||||
|
|
|
@ -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));
|
||||
|
|
31
gdb/f-exp.y
31
gdb/f-exp.y
|
@ -509,23 +509,23 @@ exp : STRING_LITERAL
|
|||
;
|
||||
|
||||
variable: name_not_typename
|
||||
{ struct symbol *sym = $1.sym;
|
||||
{ struct block_symbol 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 block_symbol 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,
|
||||
result = 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)
|
||||
== 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;
|
||||
}
|
||||
|
|
|
@ -1420,7 +1420,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);
|
||||
|
||||
|
@ -1464,7 +1464,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)
|
||||
{
|
||||
|
@ -1487,7 +1487,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);
|
||||
|
@ -1510,7 +1510,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);
|
||||
|
@ -1539,7 +1539,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)
|
||||
{
|
||||
|
@ -2256,7 +2256,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 */
|
||||
|
@ -2347,7 +2347,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
|
||||
|
|
|
@ -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
|
||||
|
|
32
gdb/go-exp.y
32
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 block_symbol 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 block_symbol 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 block_symbol 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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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))
|
||||
|
|
16
gdb/jv-exp.y
16
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 block_symbol 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -267,7 +267,8 @@ 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 *,
|
||||
struct block_symbol (*la_lookup_symbol_nonlocal)
|
||||
(const struct language_defn *,
|
||||
const char *,
|
||||
const struct block *,
|
||||
const domain_enum);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
37
gdb/m2-exp.y
37
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,45 @@ variable: INTERNAL_VAR
|
|||
|
||||
/* GDB scope operator */
|
||||
variable: block COLONCOLON NAME
|
||||
{ struct symbol *sym;
|
||||
sym = lookup_symbol (copy_name ($3), $1,
|
||||
{ struct block_symbol sym
|
||||
= lookup_symbol (copy_name ($3), $1,
|
||||
VAR_DOMAIN, 0);
|
||||
if (sym == 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 block_symbol sym;
|
||||
struct field_of_this_result is_a_field_of_this;
|
||||
|
||||
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 +641,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 +1029,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),
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
60
gdb/p-exp.y
60
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,8 @@ 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,23 +696,24 @@ block : block COLONCOLON name
|
|||
;
|
||||
|
||||
variable: block COLONCOLON name
|
||||
{ struct symbol *sym;
|
||||
{ struct block_symbol 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); }
|
||||
;
|
||||
|
||||
qualified_name: typebase COLONCOLON name
|
||||
{
|
||||
struct type *type = $1;
|
||||
|
||||
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
|
||||
&& TYPE_CODE (type) != TYPE_CODE_UNION)
|
||||
error (_("`%s' is not defined as an aggregate type."),
|
||||
|
@ -733,7 +735,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 +759,16 @@ variable: qualified_name
|
|||
;
|
||||
|
||||
variable: name_not_typename
|
||||
{ struct symbol *sym = $1.sym;
|
||||
{ struct block_symbol 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 +776,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 +787,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 +1510,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 +1560,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 +1575,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 +1597,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 +1607,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 +1622,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 +1690,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 +1738,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 +1748,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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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 block_symbol 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;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ struct ttype
|
|||
struct symtoken
|
||||
{
|
||||
struct stoken stoken;
|
||||
struct symbol *sym;
|
||||
struct block_symbol sym;
|
||||
int is_a_field_of_this;
|
||||
};
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -569,12 +569,12 @@ darwin_relocate_section_addresses (struct so_list *so,
|
|||
so->addr_low = sec->addr;
|
||||
}
|
||||
|
||||
static struct symbol *
|
||||
static struct block_symbol
|
||||
darwin_lookup_lib_symbol (struct objfile *objfile,
|
||||
const char *name,
|
||||
const domain_enum domain)
|
||||
{
|
||||
return NULL;
|
||||
return (struct block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
static bfd *
|
||||
|
|
|
@ -389,7 +389,7 @@ spu_bfd_open (char *pathname)
|
|||
}
|
||||
|
||||
/* Lookup global symbol in a SPE executable. */
|
||||
static struct symbol *
|
||||
static struct block_symbol
|
||||
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 block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
/* Enable shared library breakpoint. */
|
||||
|
|
|
@ -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 block_symbol
|
||||
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 block_symbol) {NULL, NULL};
|
||||
|
||||
return lookup_global_symbol_from_objfile (objfile, name, domain);
|
||||
}
|
||||
|
|
|
@ -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 block_symbol
|
||||
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 block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
/* Lookup the value for a specific symbol from dynamic symbol table. Look
|
||||
|
|
|
@ -137,7 +137,8 @@ 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,
|
||||
struct block_symbol (*lookup_lib_global_symbol)
|
||||
(struct objfile *objfile,
|
||||
const char *name,
|
||||
const domain_enum domain);
|
||||
|
||||
|
@ -192,7 +193,7 @@ 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,
|
||||
struct block_symbol solib_global_lookup (struct objfile *objfile,
|
||||
const char *name,
|
||||
const domain_enum domain);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
280
gdb/symtab.c
280
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,
|
||||
static struct block_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 *lookup_local_symbol (const char *name,
|
||||
struct block_symbol lookup_local_symbol (const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain,
|
||||
enum language language);
|
||||
|
||||
static struct symbol *
|
||||
static struct block_symbol
|
||||
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 block_symbol) {(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 block_symbol 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 block_symbol
|
||||
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 block_symbol) {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 block_symbol) {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,14 +1596,19 @@ symbol_cache_dump (const struct symbol_cache *cache)
|
|||
domain_name (slot->value.not_found.domain));
|
||||
break;
|
||||
case SYMBOL_SLOT_FOUND:
|
||||
{
|
||||
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 (slot->objfile_context),
|
||||
SYMBOL_PRINT_NAME (slot->value.found),
|
||||
domain_name (SYMBOL_DOMAIN (slot->value.found)));
|
||||
host_address_to_string (context),
|
||||
SYMBOL_PRINT_NAME (found),
|
||||
domain_name (SYMBOL_DOMAIN (found)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The "mt print symbol-cache" command. */
|
||||
|
@ -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 block_symbol
|
||||
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 block_symbol 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 block_symbol
|
||||
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 block_symbol
|
||||
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 block_symbol) {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 block_symbol) {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 block_symbol) {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 block_symbol
|
||||
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 block_symbol 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 block_symbol) {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 block_symbol
|
||||
lookup_local_symbol (const char *name, const struct block *block,
|
||||
const domain_enum domain,
|
||||
enum language language)
|
||||
|
@ -2196,19 +2194,21 @@ 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 block_symbol) {NULL, NULL};
|
||||
|
||||
while (block != static_block)
|
||||
{
|
||||
sym = lookup_symbol_in_block (name, block, domain);
|
||||
if (sym != NULL)
|
||||
return sym;
|
||||
return (struct block_symbol) {sym, block};
|
||||
|
||||
if (language == language_cplus || language == language_fortran)
|
||||
{
|
||||
sym = cp_lookup_symbol_imports_or_template (scope, name, block,
|
||||
struct block_symbol sym
|
||||
= cp_lookup_symbol_imports_or_template (scope, name, block,
|
||||
domain);
|
||||
if (sym != NULL)
|
||||
|
||||
if (sym.symbol != NULL)
|
||||
return sym;
|
||||
}
|
||||
|
||||
|
@ -2219,7 +2219,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 block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
/* See symtab.h. */
|
||||
|
@ -2275,7 +2275,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 +2285,7 @@ lookup_symbol_in_block (const char *name, const struct block *block,
|
|||
|
||||
/* See symtab.h. */
|
||||
|
||||
struct symbol *
|
||||
struct block_symbol
|
||||
lookup_global_symbol_from_objfile (struct objfile *main_objfile,
|
||||
const char *name,
|
||||
const domain_enum domain)
|
||||
|
@ -2297,14 +2296,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 block_symbol 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 block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
/* Check to see if the symbol is defined in one of the OBJFILE's
|
||||
|
@ -2312,7 +2311,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 block_symbol
|
||||
lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
|
||||
const char *name, const domain_enum domain)
|
||||
{
|
||||
|
@ -2334,27 +2333,29 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
|
|||
{
|
||||
const struct blockvector *bv;
|
||||
const struct block *block;
|
||||
struct symbol *sym;
|
||||
struct block_symbol 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 block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
/* Wrapper around lookup_symbol_in_objfile_symtabs for search_symbols.
|
||||
|
@ -2366,7 +2367,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 block_symbol
|
||||
lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
|
||||
const char *linkage_name,
|
||||
domain_enum domain)
|
||||
|
@ -2386,22 +2387,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 block_symbol result;
|
||||
|
||||
sym = lookup_symbol_in_objfile_symtabs (cur_objfile, GLOBAL_BLOCK,
|
||||
result = 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,
|
||||
if (result.symbol == NULL)
|
||||
result = lookup_symbol_in_objfile_symtabs (cur_objfile, STATIC_BLOCK,
|
||||
modified_name, domain);
|
||||
if (sym != NULL)
|
||||
if (result.symbol != NULL)
|
||||
{
|
||||
do_cleanups (cleanup);
|
||||
return sym;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
do_cleanups (cleanup);
|
||||
return NULL;
|
||||
return (struct block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
/* A helper function that throws an exception when a symbol was found
|
||||
|
@ -2424,17 +2425,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 block_symbol
|
||||
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 block_symbol result;
|
||||
|
||||
if (!objfile->sf)
|
||||
return NULL;
|
||||
return (struct block_symbol) {NULL, NULL};
|
||||
|
||||
if (symbol_lookup_debug > 1)
|
||||
{
|
||||
|
@ -2454,36 +2455,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 block_symbol) {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 block_symbol
|
||||
basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
|
||||
const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct block_symbol 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 +2519,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 +2537,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 +2549,7 @@ basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
|
|||
|
||||
/* See symtab.h. */
|
||||
|
||||
struct symbol *
|
||||
struct block_symbol
|
||||
lookup_symbol_in_static_block (const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain)
|
||||
|
@ -2554,7 +2558,7 @@ lookup_symbol_in_static_block (const char *name,
|
|||
struct symbol *sym;
|
||||
|
||||
if (static_block == NULL)
|
||||
return NULL;
|
||||
return (struct block_symbol) {NULL, NULL};
|
||||
|
||||
if (symbol_lookup_debug)
|
||||
{
|
||||
|
@ -2576,7 +2580,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 block_symbol) {sym, static_block};
|
||||
}
|
||||
|
||||
/* Perform the standard symbol lookup of NAME in OBJFILE:
|
||||
|
@ -2584,11 +2588,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 block_symbol
|
||||
lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
|
||||
const char *name, const domain_enum domain)
|
||||
{
|
||||
struct symbol *result;
|
||||
struct block_symbol result;
|
||||
|
||||
if (symbol_lookup_debug)
|
||||
{
|
||||
|
@ -2602,14 +2606,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 +2624,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 block_symbol
|
||||
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 block_symbol result;
|
||||
struct block_symbol_cache *bsc;
|
||||
struct symbol_cache_slot *slot;
|
||||
|
||||
|
@ -2643,27 +2647,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 block_symbol) {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 block_symbol) {NULL, NULL};
|
||||
}
|
||||
|
||||
/* Private data to be used with lookup_symbol_global_iterator_cb. */
|
||||
|
@ -2677,8 +2682,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 block_symbol result;
|
||||
};
|
||||
|
||||
/* A callback function for gdbarch_iterate_over_objfiles_in_search_order.
|
||||
|
@ -2693,25 +2698,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 block_symbol
|
||||
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 block_symbol result;
|
||||
struct objfile *objfile;
|
||||
struct global_sym_lookup_data lookup_data;
|
||||
struct block_symbol_cache *bsc;
|
||||
|
@ -2721,21 +2727,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,
|
||||
result = symbol_cache_lookup (cache, objfile, GLOBAL_BLOCK, name, domain,
|
||||
&bsc, &slot);
|
||||
if (sym != NULL)
|
||||
if (result.symbol != NULL)
|
||||
{
|
||||
if (sym == SYMBOL_LOOKUP_FAILED)
|
||||
return NULL;
|
||||
return sym;
|
||||
if (SYMBOL_LOOKUP_FAILED_P (result))
|
||||
return (struct block_symbol) {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 +2749,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 +4608,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 +4711,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 *)
|
||||
|
|
58
gdb/symtab.h
58
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 block_symbol
|
||||
{
|
||||
/* 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,11 +1199,10 @@ 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 *,
|
||||
extern struct block_symbol
|
||||
lookup_symbol_in_language (const char *,
|
||||
const struct block *,
|
||||
const domain_enum,
|
||||
enum language,
|
||||
|
@ -1202,7 +1210,8 @@ extern struct symbol *lookup_symbol_in_language (const char *,
|
|||
|
||||
/* Same as lookup_symbol_in_language, but using the current language. */
|
||||
|
||||
extern struct symbol *lookup_symbol (const char *, const struct block *,
|
||||
extern struct block_symbol lookup_symbol (const char *,
|
||||
const struct block *,
|
||||
const domain_enum,
|
||||
struct field_of_this_result *);
|
||||
|
||||
|
@ -1210,7 +1219,7 @@ extern struct symbol *lookup_symbol (const char *, const struct block *,
|
|||
that can't think of anything better to do.
|
||||
This implements the C lookup rules. */
|
||||
|
||||
extern struct symbol *
|
||||
extern struct block_symbol
|
||||
basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
|
||||
const char *,
|
||||
const struct block *,
|
||||
|
@ -1221,18 +1230,17 @@ 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,
|
||||
extern struct block_symbol
|
||||
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,
|
||||
extern struct block_symbol lookup_static_symbol (const char *name,
|
||||
const domain_enum domain);
|
||||
|
||||
/* Lookup a symbol in all files' global blocks.
|
||||
|
@ -1244,25 +1252,26 @@ 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,
|
||||
extern struct block_symbol
|
||||
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,
|
||||
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,
|
||||
extern struct block_symbol
|
||||
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 block_symbol
|
||||
lookup_global_symbol_from_objfile (struct objfile *main_objfile,
|
||||
const char *name,
|
||||
const domain_enum domain);
|
||||
|
|
26
gdb/valops.c
26
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 block_symbol 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
|
||||
{
|
||||
|
@ -3457,7 +3457,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;
|
||||
|
@ -3488,7 +3488,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;
|
||||
|
@ -3564,19 +3564,19 @@ value_maybe_namespace_elt (const struct type *curtype,
|
|||
enum noside noside)
|
||||
{
|
||||
const char *namespace_name = TYPE_TAG_NAME (curtype);
|
||||
struct symbol *sym;
|
||||
struct block_symbol 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);
|
||||
|
@ -3740,7 +3740,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);
|
||||
|
|
|
@ -2953,9 +2953,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 block_symbol 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. */
|
||||
|
@ -2971,7 +2971,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:
|
||||
|
@ -3141,7 +3141,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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue