+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
{
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"));
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;
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,
{
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)
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)
{
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;
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);
{
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;
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:
}
if (preferred_type == NULL)
return NULL;
- return syms[preferred_index].sym;
+ return syms[preferred_index].symbol;
}
static struct type*
(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);
}
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;
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);
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;
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;
}
{
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)
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 *);
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 *);
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 =
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:
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;
}
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;
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 =
}
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;
case UNOP_ABS:
if (possible_user_operator_p (op, argvec))
{
- struct ada_symbol_info *candidates;
+ struct block_symbol *candidates;
int n_candidates;
n_candidates =
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;
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)
{
{
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];
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];
}
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);
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;
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));
}
}
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;
}
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;
}
}
-/* 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
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
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
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;
/* 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;
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;
/* 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;
}
}
/* 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;
}
}
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;
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;
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)
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;
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;
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;
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);
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);
}
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;
}
}
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
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
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};
}
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,
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
/* 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
{
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 *,
- domain_enum, int *);
+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 *);
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"));
/* 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. */
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. */
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)
{
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;
}
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);
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));
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));
;
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))
;
variable: block COLONCOLON name
- { struct symbol *sym;
- sym = lookup_symbol (copy_name ($3), $1,
- VAR_DOMAIN, NULL);
- if (sym == 0)
+ { struct block_symbol sym
+ = lookup_symbol (copy_name ($3), $1,
+ VAR_DOMAIN, NULL);
+
+ 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); }
;
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);
;
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);
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)
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);
VAR_DOMAIN,
(parse_language (par_state)->la_language
== language_cplus ? &is_a_field_of_this
- : NULL))
+ : NULL)).symbol
!= NULL)
{
/* The keyword is shadowed. */
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;
}
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;
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,
- parse_language (par_state)->la_name_of_this
- ? &is_a_field_of_this : NULL);
+ 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
{
struct field_of_this_result inner_is_a_field_of_this;
- sym = lookup_symbol (copy, block, STRUCT_DOMAIN,
- &inner_is_a_field_of_this);
- if (sym != NULL)
+ bsym = lookup_symbol (copy, block, STRUCT_DOMAIN,
+ &inner_is_a_field_of_this);
+ if (bsym.symbol != NULL)
{
- yylval.tsym.type = SYMBOL_TYPE (sym);
+ yylval.tsym.type = SYMBOL_TYPE (bsym.symbol);
return TYPENAME;
}
}
}
}
- 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)
/* 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)
/* 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);
return ERROR;
}
- switch (SYMBOL_CLASS (yylval.ssym.sym))
+ switch (SYMBOL_CLASS (yylval.ssym.sym.symbol))
{
case LOC_BLOCK:
case LOC_LABEL:
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:
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;
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)
{
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:
}
*/
- 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);
}
}
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
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;
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)
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));
#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,
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)
const struct block *global_block = block_global_block (block);
if (global_block != NULL)
- sym = lookup_symbol_in_block (name, global_block, domain);
+ {
+ sym.symbol = lookup_symbol_in_block (name, global_block, domain);
+ sym.block = global_block;
+ }
}
else
- {
- sym = lookup_global_symbol (name, block, domain);
- }
+ sym = lookup_global_symbol (name, block, domain);
return sym;
}
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
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,
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);
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,
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.
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)
char *concatenated_name = NULL;
int is_in_anonymous;
unsigned int prefix_len;
- struct symbol *sym;
+ struct block_symbol sym;
if (the_namespace[0] != '\0')
{
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)
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,
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
/* 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;
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. */
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)
{
{
struct template_symbol *templ
= (struct template_symbol *) function;
+ struct symbol *sym = search_symbol_list (name,
+ templ->n_template_arguments,
+ templ->template_arguments);
- result = 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};
}
}
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)
{
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};
}
}
{
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;
}
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
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)
{
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;
}
"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,
{
/* 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. */
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;
}
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)
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;
}
/* 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);
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;
}
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,
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,
{
sym = cp_basic_lookup_symbol (concatenated_name, block, domain,
is_in_anonymous);
- if (sym != NULL)
+ if (sym.symbol != NULL)
return sym;
}
/* 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,
if (!is_in_anonymous)
{
sym = lookup_static_symbol (concatenated_name, domain);
- if (sym != NULL)
+ if (sym.symbol != NULL)
return sym;
}
{
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++
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,
{
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;
{
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;
}
"cp_lookup_nested_symbol (...) = NULL"
" (func/method)\n");
}
- return NULL;
+ return (struct block_symbol) {NULL, NULL};
default:
internal_error (__FILE__, __LINE__,
TRY
{
- sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
+ sym = lookup_symbol (name, 0, VAR_DOMAIN, 0).symbol;
}
CATCH (except, RETURN_MASK_ALL)
{
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)
{
/* 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)
{
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,
- const char *name,
- const struct block *block,
- const domain_enum domain);
+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,
- const char *nested_name,
- const struct block *block,
- const domain_enum domain);
+extern struct block_symbol
+ cp_lookup_nested_symbol (struct type *parent_type,
+ const char *nested_name,
+ const struct block *block,
+ const domain_enum domain);
struct type *cp_lookup_transparent_type (const char *name);
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);
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);
{
char *copy = copy_name (name);
struct field_of_this_result is_a_field_of_this;
- struct symbol *sym;
- sym = lookup_symbol (copy, expression_context_block, VAR_DOMAIN,
- &is_a_field_of_this);
- if (sym && SYMBOL_CLASS (sym) != LOC_TYPEDEF)
+ struct block_symbol sym
+ = lookup_symbol (copy, expression_context_block, VAR_DOMAIN,
+ &is_a_field_of_this);
+
+ if (sym.symbol && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
{
- if (symbol_read_needs_frame (sym))
+ if (symbol_read_needs_frame (sym.symbol))
{
if (innermost_block == 0 ||
- contained_in (block_found, innermost_block))
- innermost_block = block_found;
+ contained_in (sym.block, innermost_block))
+ innermost_block = sym.block;
}
write_exp_elt_opcode (ps, OP_VAR_VALUE);
/* We want to use the selected frame, not another more inner frame
which happens to be in the same block. */
write_exp_elt_block (ps, NULL);
- write_exp_elt_sym (ps, sym);
+ write_exp_elt_sym (ps, sym.symbol);
write_exp_elt_opcode (ps, OP_VAR_VALUE);
return 1;
}
/* 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);
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)
{
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));
;
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;
}
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[] =
{
way we can refer to it unconditionally below. */
memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
- sym = lookup_symbol (tmp, expression_context_block,
- lookup_domains[i],
- parse_language (pstate)->la_language
- == language_cplus ? &is_a_field_of_this : NULL);
- if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+ result = lookup_symbol (tmp, expression_context_block,
+ lookup_domains[i],
+ parse_language (pstate)->la_language
+ == language_cplus
+ ? &is_a_field_of_this : NULL);
+ if (result.symbol && SYMBOL_CLASS (result.symbol) == LOC_TYPEDEF)
{
- yylval.tsym.type = SYMBOL_TYPE (sym);
+ yylval.tsym.type = SYMBOL_TYPE (result.symbol);
return TYPENAME;
}
- if (sym)
+ if (result.symbol)
break;
}
/* 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)))
{
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;
}
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);
{
struct symbol *sym;
- sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0);
+ sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
if (sym == NULL)
{
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);
{
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);
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)
{
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 */
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
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
;
variable: name_not_typename ENTRY
- { struct symbol *sym = $1.sym;
+ { struct symbol *sym = $1.sym.symbol;
if (sym == NULL
|| !SYMBOL_IS_ARGUMENT (sym)
;
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);
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)
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
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;
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;
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;
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;
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;
}
{
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)
{
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)
{
TRY
{
- symbol = lookup_global_symbol (name, NULL, domain);
+ symbol = lookup_global_symbol (name, NULL, domain).symbol;
}
CATCH (ex, RETURN_MASK_ALL)
{
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))
{
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;
}
/* 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);
{
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. */
{
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);
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);
}
/* 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. */
the part of symbol lookup where C looks up static and global
variables. */
- struct symbol *(*la_lookup_symbol_nonlocal) (const struct language_defn *,
- const char *,
- const struct block *,
- const domain_enum);
+ struct block_symbol (*la_lookup_symbol_nonlocal)
+ (const struct language_defn *,
+ const char *,
+ const struct block *,
+ const domain_enum);
/* Find the definition of the type with the given name. */
struct type *(*la_lookup_transparent_type) (const char *);
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)
{
{
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)
{
{ struct symbol *sym
= lookup_symbol (copy_name ($1),
expression_context_block,
- VAR_DOMAIN, 0);
+ VAR_DOMAIN, 0).symbol;
$$ = sym;}
;
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));
/* GDB scope operator */
variable: block COLONCOLON NAME
- { struct symbol *sym;
- sym = lookup_symbol (copy_name ($3), $1,
- VAR_DOMAIN, 0);
- if (sym == 0)
+ { struct block_symbol sym
+ = lookup_symbol (copy_name ($3), $1,
+ VAR_DOMAIN, 0);
+
+ if (sym.symbol == 0)
error (_("No symbol \"%s\" in specified context."),
copy_name ($3));
- if (symbol_read_needs_frame (sym))
+ if (symbol_read_needs_frame (sym.symbol))
{
if (innermost_block == 0
- || contained_in (block_found,
+ || contained_in (sym.block,
innermost_block))
- innermost_block = block_found;
+ innermost_block = sym.block;
}
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
- /* block_found is set by lookup_symbol. */
- write_exp_elt_block (pstate, block_found);
- write_exp_elt_sym (pstate, sym);
+ write_exp_elt_block (pstate, sym.block);
+ write_exp_elt_sym (pstate, sym.symbol);
write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
;
/* Base case for variables. */
variable: NAME
- { struct symbol *sym;
+ { struct block_symbol sym;
struct field_of_this_result is_a_field_of_this;
- sym = lookup_symbol (copy_name ($1),
+ sym = lookup_symbol (copy_name ($1),
expression_context_block,
VAR_DOMAIN,
&is_a_field_of_this);
- if (sym)
+
+ if (sym.symbol)
{
- if (symbol_read_needs_frame (sym))
+ if (symbol_read_needs_frame (sym.symbol))
{
if (innermost_block == 0 ||
- contained_in (block_found,
+ contained_in (sym.block,
innermost_block))
- innermost_block = block_found;
+ innermost_block = sym.block;
}
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
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 (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),
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);
{
struct symbol *sym;
- sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0);
+ sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
if (sym == NULL)
{
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,
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 =
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));
;
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."),
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);
;
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);
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;
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);
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;
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)
{
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)
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))
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)
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;
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)
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;
free(uptokstart);
/* Any other kind of symbol. */
- yylval.ssym.sym = sym;
+ yylval.ssym.sym.symbol = sym;
+ yylval.ssym.sym.block = NULL;
return NAME;
}
}
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)
{
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;
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;
}
struct symtoken
{
struct stoken stoken;
- struct symbol *sym;
+ struct block_symbol sym;
int is_a_field_of_this;
};
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)
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)
{
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)
{
TRY
{
- symbol = lookup_global_symbol (name, NULL, domain);
+ symbol = lookup_global_symbol (name, NULL, domain).symbol;
}
CATCH (except, RETURN_MASK_ALL)
{
}
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);
so->addr_low = sec->addr;
}
\f
-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 *
}
/* 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)
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. */
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)
}
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);
}
/* 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)
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
unsigned o_flags, char **temp_pathname);
/* Hook for looking up global symbols in a library-specific way. */
- struct symbol * (*lookup_lib_global_symbol) (struct objfile *objfile,
- const char *name,
- const domain_enum domain);
+ struct block_symbol (*lookup_lib_global_symbol)
+ (struct objfile *objfile,
+ const char *name,
+ const domain_enum domain);
/* Given two so_list objects, one from the GDB thread list
and another from the list returned by current_sos, return 1
extern struct target_so_ops *current_target_so_ops;
/* Handler for library-specific global symbol lookup in solib.c. */
-struct symbol *solib_global_lookup (struct objfile *objfile,
- const char *name,
- const domain_enum domain);
+struct block_symbol solib_global_lookup (struct objfile *objfile,
+ const char *name,
+ const domain_enum domain);
#endif
/* 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);
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))
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);
}
}
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);
static int find_line_common (struct linetable *, int, int *, int);
-static struct symbol *lookup_symbol_aux (const char *name,
- const struct block *block,
- const domain_enum domain,
- enum language language,
- struct field_of_this_result *);
+static struct 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,
- const struct block *block,
- const domain_enum domain,
- enum language language);
+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);
/* 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. */
union
{
- struct symbol *found;
+ struct block_symbol found;
struct
{
char *name;
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 *
}
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. */
}
else
{
- struct symbol *sym = slot->value.found;
+ struct symbol *sym = slot->value.found.symbol;
if (strcmp_iw (slot_name, name) != 0)
return 0;
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,
{
*bsc_ptr = NULL;
*slot_ptr = NULL;
- return NULL;
+ return (struct block_symbol) {NULL, NULL};
}
hash = hash_symbol_entry (objfile_context, name, domain);
name, domain_name (domain));
}
++bsc->misses;
- return NULL;
+ return (struct block_symbol) {NULL, NULL};
}
/* Clear out SLOT. */
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;
}
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.
domain_name (slot->value.not_found.domain));
break;
case SYMBOL_SLOT_FOUND:
- printf_filtered (" [%4u] = %s, %s %s\n", i,
- host_address_to_string (slot->objfile_context),
- SYMBOL_PRINT_NAME (slot->value.found),
- domain_name (SYMBOL_DOMAIN (slot->value.found)));
- break;
+ {
+ struct symbol *found = slot->value.found.symbol;
+ const struct objfile *context = slot->objfile_context;
+
+ printf_filtered (" [%4u] = %s, %s %s\n", i,
+ host_address_to_string (context),
+ SYMBOL_PRINT_NAME (found),
+ domain_name (SYMBOL_DOMAIN (found)));
+ break;
+ }
}
}
}
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,
/* 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)
/* 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)
{
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;
if (symbol_lookup_debug > 1)
fprintf_unfiltered (gdb_stdlog, " = NULL\n");
- return NULL;
+ return (struct block_symbol) {NULL, NULL};
}
/* Given TYPE, a structure/union,
/* 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)
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
/* 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,
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. */
fprintf_unfiltered (gdb_stdlog,
"lookup_symbol_aux (...) = NULL\n");
}
- return NULL;
+ return (struct block_symbol) {NULL, NULL};
}
}
}
/* 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)
/* 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,
- domain);
- if (sym != NULL)
+ struct block_symbol sym
+ = cp_lookup_symbol_imports_or_template (scope, name, block,
+ domain);
+
+ if (sym.symbol != NULL)
return sym;
}
/* We've reached the end of the function without finding a result. */
- return NULL;
+ return (struct block_symbol) {NULL, NULL};
}
/* See symtab.h. */
fprintf_unfiltered (gdb_stdlog, " = %s\n",
host_address_to_string (sym));
}
- block_found = block;
return fixup_symbol_section (sym, NULL);
}
/* See symtab.h. */
-struct symbol *
+struct block_symbol
lookup_global_symbol_from_objfile (struct objfile *main_objfile,
const char *name,
const domain_enum domain)
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
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)
{
{
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.
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)
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,
- modified_name, domain);
- if (sym == NULL)
- sym = lookup_symbol_in_objfile_symtabs (cur_objfile, STATIC_BLOCK,
- modified_name, domain);
- if (sym != NULL)
+ result = lookup_symbol_in_objfile_symtabs (cur_objfile, GLOBAL_BLOCK,
+ modified_name, domain);
+ if (result.symbol == NULL)
+ result = lookup_symbol_in_objfile_symtabs (cur_objfile, STATIC_BLOCK,
+ modified_name, domain);
+ if (result.symbol != NULL)
{
do_cleanups (cleanup);
- return sym;
+ return result;
}
}
do_cleanups (cleanup);
- return NULL;
+ return (struct block_symbol) {NULL, NULL};
}
/* A helper function that throws an exception when a symbol was found
/* 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)
{
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;
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
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);
/* See symtab.h. */
-struct symbol *
+struct block_symbol
lookup_symbol_in_static_block (const char *name,
const struct block *block,
const domain_enum domain)
struct symbol *sym;
if (static_block == NULL)
- return NULL;
+ return (struct block_symbol) {NULL, NULL};
if (symbol_lookup_debug)
{
"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:
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)
{
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;
}
{
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;
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. */
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.
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;
/* First see if we can find the symbol in the cache.
This works because we use the current objfile to qualify the lookup. */
- sym = symbol_cache_lookup (cache, objfile, GLOBAL_BLOCK, name, domain,
- &bsc, &slot);
- if (sym != NULL)
+ result = symbol_cache_lookup (cache, objfile, GLOBAL_BLOCK, name, domain,
+ &bsc, &slot);
+ if (result.symbol != NULL)
{
- if (sym == SYMBOL_LOOKUP_FAILED)
- return NULL;
- return sym;
+ if (SYMBOL_LOOKUP_FAILED_P (result))
+ return (struct 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;
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
(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;
}
}
{
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 *)
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
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[];
C++: if IS_A_FIELD_OF_THIS is non-NULL on entry, check to see if
NAME is a field of the current implied argument `this'. If so fill in the
fields of IS_A_FIELD_OF_THIS, otherwise the fields are set to NULL.
- BLOCK_FOUND is set to the block in which NAME is found (in the case of
- a field of `this', value_of_this sets BLOCK_FOUND to the proper value).
The symbol's section is fixed up if necessary. */
-extern struct symbol *lookup_symbol_in_language (const char *,
- const struct block *,
- const domain_enum,
- enum language,
- struct field_of_this_result *);
+extern struct block_symbol
+ lookup_symbol_in_language (const char *,
+ const struct block *,
+ const domain_enum,
+ enum language,
+ struct field_of_this_result *);
/* Same as lookup_symbol_in_language, but using the current language. */
-extern struct symbol *lookup_symbol (const char *, const struct block *,
- const domain_enum,
- struct field_of_this_result *);
+extern struct block_symbol lookup_symbol (const char *,
+ const struct block *,
+ const domain_enum,
+ struct field_of_this_result *);
/* A default version of lookup_symbol_nonlocal for use by languages
that can't think of anything better to do.
This implements the C lookup rules. */
-extern struct symbol *
+extern struct block_symbol
basic_lookup_symbol_nonlocal (const struct language_defn *langdef,
const char *,
const struct block *,
/* Lookup a symbol in the static block associated to BLOCK, if there
is one; do nothing if BLOCK is NULL or a global block.
- Upon success sets BLOCK_FOUND and fixes up the symbol's section
- if necessary. */
+ Upon success fixes up the symbol's section if necessary. */
-extern struct symbol *lookup_symbol_in_static_block (const char *name,
- const struct block *block,
- const domain_enum domain);
+extern struct 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,
- const domain_enum domain);
+extern struct block_symbol lookup_static_symbol (const char *name,
+ const domain_enum domain);
/* Lookup a symbol in all files' global blocks.
if the target requires it.
See gdbarch_iterate_over_objfiles_in_search_order.
- Upon success sets BLOCK_FOUND and fixes up the symbol's section
- if necessary. */
+ Upon success fixes up the symbol's section if necessary. */
-extern struct symbol *lookup_global_symbol (const char *name,
- const struct block *block,
- const domain_enum domain);
+extern struct 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,
- const struct block *block,
- const domain_enum domain);
+extern struct symbol *
+ lookup_symbol_in_block (const char *name,
+ const struct block *block,
+ const domain_enum domain);
/* Look up the `this' symbol for LANG in BLOCK. Return the symbol if
found, or NULL if not found. */
-extern struct symbol *lookup_language_this (const struct language_defn *lang,
- const struct block *block);
+extern struct 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. */
/* 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);
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
{
{
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;
{
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;
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);
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);
{
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. */
}
}
else
- retval = value_of_variable (sym, NULL);
+ retval = value_of_variable (sym.symbol, sym.block);
break;
}
default:
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));