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:
Pierre-Marie de Rodat
2015-07-21 17:02:15 +02:00
parent 5efafabf7b
commit d12307c199
50 changed files with 910 additions and 697 deletions

View File

@@ -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 =
@@ -3468,8 +3468,9 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
if (i < 0)
break;
replace_operator_with_call (expp, pc, nargs, 1,
candidates[i].sym, candidates[i].block);
replace_operator_with_call (expp, pc, nargs, 1,
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