mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 20:14:06 +08:00
d12307c199
As Pedro suggested on gdb-patches@ (see https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this change makes symbol lookup functions return a structure that includes both the symbol found and the block in which it was found. This makes it possible to get rid of the block_found global variable and thus makes block hunting explicit. gdb/ * ada-exp.y (write_object_renaming): Replace struct ada_symbol_info with struct block_symbol. Update field references accordingly. (block_lookup, select_possible_type_sym): Likewise. (find_primitive_type): Likewise. Also update call to ada_lookup_symbol to extract the symbol itself. (write_var_or_type, write_name_assoc): Likewise. * ada-lang.h (struct ada_symbol_info): Remove. (ada_lookup_symbol_list): Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_encoded_symbol, user_select_syms): Likewise. (ada_lookup_symbol): Return struct block_symbol instead of a mere symbol. * ada-lang.c (defns_collected): Replace struct ada_symbol_info with struct block_symbol. (resolve_subexp, ada_resolve_function, sort_choices, user_select_syms, is_nonfunction, add_defn_to_vec, num_defns_collected, defns_collected, symbols_are_identical_enums, remove_extra_symbols, remove_irrelevant_renamings, add_lookup_symbol_list_worker, ada_lookup_symbol_list, ada_iterate_over_symbols, ada_lookup_encoded_symbol, get_var_value): Likewise. (ada_lookup_symbol): Return a block_symbol instead of a mere symbol. Replace struct ada_symbol_info with struct block_symbol. (ada_lookup_symbol_nonlocal): Likewise. (standard_lookup): Make block passing explicit through lookup_symbol_in_language. * ada-tasks.c (get_tcb_types_info): Update the calls to lookup_symbol_in_language to extract the mere symbol out of the returned value. (ada_tasks_inferior_data_sniffer): Likewise. * ax-gdb.c (gen_static_field): Likewise for the call to lookup_symbol. (gen_maybe_namespace_elt): Deal with struct symbol_in_block from lookup functions. (gen_expr): Likewise. * c-exp.y: Likewise. Remove uses of block_found. (lex_one_token, classify_inner_name, c_print_token): Likewise. (classify_name): Likewise. Rename the "sym" local variable to "bsym". * c-valprint.c (print_unpacked_pointer): Likewise. * compile/compile-c-symbols.c (convert_symbol_sym): Promote the "sym" parameter from struct symbol * to struct block_symbol. Use it to remove uses of block_found. Deal with struct symbol_in_block from lookup functions. (gcc_convert_symbol): Likewise. Update the call to convert_symbol_sym. * compile/compile-object-load.c (compile_object_load): Deal with struct symbol_in_block from lookup functions. * cp-namespace.c (cp_lookup_nested_symbol_1, cp_lookup_nested_symbol, cp_lookup_bare_symbol, cp_search_static_and_baseclasses, cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports, cp_lookup_symbol_imports_or_template, cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace, lookup_namespace_scope, cp_lookup_nonlocal, find_symbol_in_baseclass): Return struct symbol_in_block instead of mere symbols and deal with struct symbol_in_block from lookup functions. * cp-support.c (inspect_type, replace_typedefs, cp_lookup_rtti_type): Deal with struct symbol_in_block from lookup functions. * cp-support.h (cp_lookup_symbol_nonlocal, cp_lookup_symbol_from_namespace, cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol): Return struct symbol_in_block instead of mere symbols. * d-exp.y (d_type_from_name, d_module_from_name, push_variable, push_module_name): Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. * eval.c (evaluate_subexp_standard): Update call to cp_lookup_symbol_namespace. * f-exp.y: Deal with struct symbol_in_block from lookup functions. Remove uses of block_found. (yylex): Likewise. * gdbtypes.c (lookup_typename, lookup_struct, lookup_union, lookup_enum, lookup_template_type, check_typedef): Deal with struct symbol_in_block from lookup functions. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise. (gdbscm_lookup_global_symbol): Likewise. * gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise. * go-exp.y: Likewise. Remove uses of block_found. (package_name_p, classify_packaged_name, classify_name): Likewise. * infrun.c (insert_exception_resume_breakpoint): Likewise. * jv-exp.y (push_variable): Likewise. * jv-lang.c (java_lookup_class, get_java_object_type): Likewise. * language.c (language_bool_type): Likewise. * language.h (struct language_defn): Update la_lookup_symbol_nonlocal to return a struct symbol_in_block rather than a mere symbol. * linespec.c (find_label_symbols): Deal with struct symbol_in_block from lookup functions. * m2-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * mi/mi-cmd-stack.c (list_args_or_locals): Likewise. * objc-lang.c (lookup_struct_typedef, find_imps): Likewise. * p-exp.y: Likewise. Remove uses of block_found. (yylex): Likewise. * p-valprint.c (pascal_val_print): Likewise. * parse.c (write_dollar_variable): Likewise. Remove uses of block_found. * parser-defs.h (struct symtoken): Turn the SYM field into a struct symbol_in_block. * printcmd.c (address_info): Deal with struct symbol_in_block from lookup functions. * python/py-frame.c (frapy_read_var): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol, gdbpy_lookup_global_symbol): Likewise. * skip.c (skip_function_command): Likewise. * solib-darwin.c (darwin_lookup_lib_symbol): Return a struct symbol_in_block instead of a mere symbol. * solib-spu.c (spu_lookup_lib_symbol): Likewise. * solib-svr4.c (elf_lookup_lib_symbol): Likewise. * solib.c (solib_global_lookup): Likewise. * solist.h (solib_global_lookup): Likewise. (struct target_so_ops): Update lookup_lib_global_symbol to return a struct symbol_in_block rather than a mere symbol. * source.c (select_source_symtab): Deal with struct symbol_in_block from lookup functions. * stack.c (print_frame_args, iterate_over_block_arg_vars): Likewise. * symfile.c (set_initial_language): Likewise. * symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct symbol_in_block. (SYMBOL_LOOKUP_FAILED_P): New predicate as a macro. (struct symbol_cache_slot): Turn the FOUND field into a struct symbol_in_block. (block_found): Remove. (eq_symbol_entry): Update to deal with struct symbol_in_block in cache slots. (symbol_cache_lookup): Return a struct symbol_in_block rather than a mere symbol. (symbol_cache_mark_found): Add a BLOCK parameter to fill appropriately the cache slots. Update callers. (symbol_cache_dump): Update cache slots handling to the type change. (lookup_symbol_in_language, lookup_symbol, lookup_language_this, lookup_symbol_aux, lookup_local_symbol, lookup_symbol_in_objfile, lookup_global_symbol_from_objfile, lookup_symbol_in_objfile_symtabs, lookup_symbol_in_objfile_from_linkage_name, lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, lookup_static_symbol, lookup_global_symbol): Return a struct symbol_in_block rather than a mere symbol. Deal with struct symbol_in_block from other lookup functions. Remove uses of block_found. (lookup_symbol_in_block): Remove uses of block_found. (struct global_sym_lookup_data): Turn the RESULT field into a struct symbol_in_block. (lookup_symbol_global_iterator_cb): Update references to the RESULT field. (search_symbols): Deal with struct symbol_in_block from lookup functions. * symtab.h (struct symbol_in_block): New structure. (block_found): Remove. (lookup_symbol_in_language, lookup_symbol, basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block, looku_static_symbol, lookup_global_symbol, lookup_symbol_in_block, lookup_language_this, lookup_global_symbol_from_objfile): Return a struct symbol_in_block rather than just a mere symbol. Update comments to remove mentions of block_found. * valops.c (find_function_in_inferior, value_struct_elt_for_reference, value_maybe_namespace_elt, value_of_this): Deal with struct symbol_in_block from lookup functions. * value.c (value_static_field, value_fn_field): Likewise.
201 lines
7.9 KiB
C
201 lines
7.9 KiB
C
/* Shared library declarations for GDB, the GNU Debugger.
|
|
Copyright (C) 1990-2015 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef SOLIST_H
|
|
#define SOLIST_H
|
|
|
|
#define SO_NAME_MAX_PATH_SIZE 512 /* FIXME: Should be dynamic */
|
|
/* For domain_enum domain. */
|
|
#include "symtab.h"
|
|
|
|
/* Forward declaration for target specific link map information. This
|
|
struct is opaque to all but the target specific file. */
|
|
struct lm_info;
|
|
|
|
struct so_list
|
|
{
|
|
/* The following fields of the structure come directly from the
|
|
dynamic linker's tables in the inferior, and are initialized by
|
|
current_sos. */
|
|
|
|
struct so_list *next; /* next structure in linked list */
|
|
|
|
/* A pointer to target specific link map information. Often this
|
|
will be a copy of struct link_map from the user process, but
|
|
it need not be; it can be any collection of data needed to
|
|
traverse the dynamic linker's data structures. */
|
|
struct lm_info *lm_info;
|
|
|
|
/* Shared object file name, exactly as it appears in the
|
|
inferior's link map. This may be a relative path, or something
|
|
which needs to be looked up in LD_LIBRARY_PATH, etc. We use it
|
|
to tell which entries in the inferior's dynamic linker's link
|
|
map we've already loaded. */
|
|
char so_original_name[SO_NAME_MAX_PATH_SIZE];
|
|
|
|
/* Shared object file name, expanded to something GDB can open. */
|
|
char so_name[SO_NAME_MAX_PATH_SIZE];
|
|
|
|
/* Program space this shared library belongs to. */
|
|
struct program_space *pspace;
|
|
|
|
/* The following fields of the structure are built from
|
|
information gathered from the shared object file itself, and
|
|
are set when we actually add it to our symbol tables.
|
|
|
|
current_sos must initialize these fields to 0. */
|
|
|
|
bfd *abfd;
|
|
char symbols_loaded; /* flag: symbols read in yet? */
|
|
|
|
/* objfile with symbols for a loaded library. Target memory is read from
|
|
ABFD. OBJFILE may be NULL either before symbols have been loaded, if
|
|
the file cannot be found or after the command "nosharedlibrary". */
|
|
struct objfile *objfile;
|
|
|
|
struct target_section *sections;
|
|
struct target_section *sections_end;
|
|
|
|
/* Record the range of addresses belonging to this shared library.
|
|
There may not be just one (e.g. if two segments are relocated
|
|
differently); but this is only used for "info sharedlibrary". */
|
|
CORE_ADDR addr_low, addr_high;
|
|
};
|
|
|
|
struct target_so_ops
|
|
{
|
|
/* Adjust the section binding addresses by the base address at
|
|
which the object was actually mapped. */
|
|
void (*relocate_section_addresses) (struct so_list *so,
|
|
struct target_section *);
|
|
|
|
/* Free the link map info and any other private data structures
|
|
associated with a so_list entry. */
|
|
void (*free_so) (struct so_list *so);
|
|
|
|
/* Reset private data structures associated with SO.
|
|
This is called when SO is about to be reloaded.
|
|
It is also called before free_so when SO is about to be freed. */
|
|
void (*clear_so) (struct so_list *so);
|
|
|
|
/* Reset or free private data structures not associated with
|
|
so_list entries. */
|
|
void (*clear_solib) (void);
|
|
|
|
/* Target dependent code to run after child process fork. */
|
|
void (*solib_create_inferior_hook) (int from_tty);
|
|
|
|
/* Do additional symbol handling, lookup, etc. after symbols for a
|
|
shared object have been loaded in the usual way. This is
|
|
called to do any system specific symbol handling that might be
|
|
needed. */
|
|
void (*special_symbol_handling) (void);
|
|
|
|
/* Construct a list of the currently loaded shared objects. This
|
|
list does not include an entry for the main executable file.
|
|
|
|
Note that we only gather information directly available from the
|
|
inferior --- we don't examine any of the shared library files
|
|
themselves. The declaration of `struct so_list' says which fields
|
|
we provide values for. */
|
|
struct so_list *(*current_sos) (void);
|
|
|
|
/* Find, open, and read the symbols for the main executable. If
|
|
FROM_TTYP dereferences to a non-zero integer, allow messages to
|
|
be printed. This parameter is a pointer rather than an int
|
|
because open_symbol_file_object is called via catch_errors and
|
|
catch_errors requires a pointer argument. */
|
|
int (*open_symbol_file_object) (void *from_ttyp);
|
|
|
|
/* Determine if PC lies in the dynamic symbol resolution code of
|
|
the run time loader. */
|
|
int (*in_dynsym_resolve_code) (CORE_ADDR pc);
|
|
|
|
/* Find and open shared library binary file. */
|
|
bfd *(*bfd_open) (char *pathname);
|
|
|
|
/* Optional extra hook for finding and opening a solib.
|
|
If TEMP_PATHNAME is non-NULL: If the file is successfully opened a
|
|
pointer to a malloc'd and realpath'd copy of SONAME is stored there,
|
|
otherwise NULL is stored there. */
|
|
int (*find_and_open_solib) (char *soname,
|
|
unsigned o_flags, char **temp_pathname);
|
|
|
|
/* Hook for looking up global symbols in a library-specific way. */
|
|
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
|
|
if they represent the same library.
|
|
Falls back to using strcmp on so_original_name field when set
|
|
to NULL. */
|
|
int (*same) (struct so_list *gdb, struct so_list *inferior);
|
|
|
|
/* Return whether a region of memory must be kept in a core file
|
|
for shared libraries loaded before "gcore" is used to be
|
|
handled correctly when the core file is loaded. This only
|
|
applies when the section would otherwise not be kept in the
|
|
core file (in particular, for readonly sections). */
|
|
int (*keep_data_in_core) (CORE_ADDR vaddr,
|
|
unsigned long size);
|
|
|
|
/* Enable or disable optional solib event breakpoints as
|
|
appropriate. This should be called whenever
|
|
stop_on_solib_events is changed. This pointer can be
|
|
NULL, in which case no enabling or disabling is necessary
|
|
for this target. */
|
|
void (*update_breakpoints) (void);
|
|
|
|
/* Target-specific processing of solib events that will be
|
|
performed before solib_add is called. This pointer can be
|
|
NULL, in which case no specific preprocessing is necessary
|
|
for this target. */
|
|
void (*handle_event) (void);
|
|
};
|
|
|
|
/* Free the memory associated with a (so_list *). */
|
|
void free_so (struct so_list *so);
|
|
|
|
/* Return address of first so_list entry in master shared object list. */
|
|
struct so_list *master_so_list (void);
|
|
|
|
/* Find main executable binary file. */
|
|
extern char *exec_file_find (char *in_pathname, int *fd);
|
|
|
|
/* Find shared library binary file. */
|
|
extern char *solib_find (char *in_pathname, int *fd);
|
|
|
|
/* Open BFD for shared library file. */
|
|
extern bfd *solib_bfd_fopen (char *pathname, int fd);
|
|
|
|
/* Find solib binary file and open it. */
|
|
extern bfd *solib_bfd_open (char *in_pathname);
|
|
|
|
/* FIXME: gdbarch needs to control this variable. */
|
|
extern struct target_so_ops *current_target_so_ops;
|
|
|
|
/* Handler for library-specific global symbol lookup in solib.c. */
|
|
struct block_symbol solib_global_lookup (struct objfile *objfile,
|
|
const char *name,
|
|
const domain_enum domain);
|
|
|
|
#endif
|