GDB (xrefs)
Classes | Defines | Functions | Variables
/home/stan/gdb/src/gdb/minsyms.c File Reference
#include "defs.h"
#include <ctype.h>
#include "gdb_string.h"
#include "symtab.h"
#include "bfd.h"
#include "filenames.h"
#include "symfile.h"
#include "objfiles.h"
#include "demangle.h"
#include "value.h"
#include "cp-abi.h"
#include "target.h"
#include "cp-support.h"
#include "language.h"
#include "cli/cli-utils.h"

Go to the source code of this file.

Classes

struct  msym_bunch

Defines

#define BUNCH_SIZE   127

Functions

unsigned int msymbol_hash_iw (const char *string)
unsigned int msymbol_hash (const char *string)
static void add_minsym_to_hash_table (struct minimal_symbol *sym, struct minimal_symbol **table)
static void add_minsym_to_demangled_hash_table (struct minimal_symbol *sym, struct minimal_symbol **table)
static struct bound_minimal_symbol lookup_minimal_symbol_internal (const char *name, const char *sfile, struct objfile *objf)
struct minimal_symbollookup_minimal_symbol (const char *name, const char *sfile, struct objfile *objf)
struct bound_minimal_symbol lookup_bound_minimal_symbol (const char *name)
void iterate_over_minimal_symbols (struct objfile *objf, const char *name, void(*callback)(struct minimal_symbol *, void *), void *user_data)
struct minimal_symbollookup_minimal_symbol_text (const char *name, struct objfile *objf)
struct minimal_symbollookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name, struct objfile *objf)
struct minimal_symbollookup_minimal_symbol_solib_trampoline (const char *name, struct objfile *objf)
static struct bound_minimal_symbol lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, struct obj_section *section, int want_trampoline)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc_section (CORE_ADDR pc, struct obj_section *section)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc (CORE_ADDR pc)
int in_gnu_ifunc_stub (CORE_ADDR pc)
static CORE_ADDR stub_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc)
static int stub_gnu_ifunc_resolve_name (const char *function_name, CORE_ADDR *function_address_p)
static void stub_gnu_ifunc_resolver_stop (struct breakpoint *b)
static void stub_gnu_ifunc_resolver_return_stop (struct breakpoint *b)
struct bound_minimal_symbol lookup_minimal_symbol_and_objfile (const char *name)
static int get_symbol_leading_char (bfd *)
void init_minimal_symbol_collection (void)
void prim_record_minimal_symbol (const char *name, CORE_ADDR address, enum minimal_symbol_type ms_type, struct objfile *objfile)
struct minimal_symbolprim_record_minimal_symbol_full (const char *name, int name_len, int copy_name, CORE_ADDR address, enum minimal_symbol_type ms_type, int section, struct objfile *objfile)
struct minimal_symbolprim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address, enum minimal_symbol_type ms_type, int section, struct objfile *objfile)
static int compare_minimal_symbols (const void *fn1p, const void *fn2p)
static void do_discard_minimal_symbols_cleanup (void *arg)
struct cleanupmake_cleanup_discard_minimal_symbols (void)
static int compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount, struct objfile *objfile)
static void build_minimal_symbol_hash_tables (struct objfile *objfile)
void install_minimal_symbols (struct objfile *objfile)
void terminate_minimal_symbol_table (struct objfile *objfile)
void msymbols_sort (struct objfile *objfile)
static struct minimal_symbollookup_solib_trampoline_symbol_by_pc (CORE_ADDR pc)
CORE_ADDR find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc)

Variables

static struct msym_bunchmsym_bunch
static int msym_bunch_index
static int msym_count
static struct gnu_ifunc_fns stub_gnu_ifunc_fns
struct gnu_ifunc_fnsgnu_ifunc_fns_p = &stub_gnu_ifunc_fns

Define Documentation

#define BUNCH_SIZE   127

Function Documentation

static void add_minsym_to_demangled_hash_table ( struct minimal_symbol sym,
struct minimal_symbol **  table 
) [static]
static void add_minsym_to_hash_table ( struct minimal_symbol sym,
struct minimal_symbol **  table 
) [static]
static void build_minimal_symbol_hash_tables ( struct objfile objfile) [static]
static int compact_minimal_symbols ( struct minimal_symbol msymbol,
int  mcount,
struct objfile objfile 
) [static]

Definition at line 1089 of file minsyms.c.

References mst_unknown, MSYMBOL_TYPE, SYMBOL_LINKAGE_NAME, and SYMBOL_VALUE_ADDRESS.

Referenced by install_minimal_symbols().

static int compare_minimal_symbols ( const void *  fn1p,
const void *  fn2p 
) [static]

Definition at line 988 of file minsyms.c.

References SYMBOL_LINKAGE_NAME, and SYMBOL_VALUE_ADDRESS.

Referenced by install_minimal_symbols(), and msymbols_sort().

static void do_discard_minimal_symbols_cleanup ( void *  arg) [static]

Definition at line 1030 of file minsyms.c.

References msym_bunch::next, and xfree().

Referenced by make_cleanup_discard_minimal_symbols().

static int get_symbol_leading_char ( bfd *  abfd) [static]

Definition at line 849 of file minsyms.c.

References symfile_objfile.

Referenced by prim_record_minimal_symbol_full().

Prepare to start collecting minimal symbols. This should be called by a symbol reader to initialize the minimal symbol module. Currently, minimal symbol table creation is not reentrant; it relies on global (static) variables in minsyms.c.

Definition at line 861 of file minsyms.c.

References BUNCH_SIZE, msym_bunch_index, and msym_count.

Referenced by coff_symfile_read(), dbx_symfile_read(), elf_symfile_read(), elfmdebug_build_psymtabs(), macho_symfile_read(), mipscoff_symfile_read(), som_symfile_read(), and xcoff_initial_scan().

void install_minimal_symbols ( struct objfile objfile)

Install the minimal symbols that have been collected into the given objfile. After this is called, the cleanup returned by make_cleanup_discard_minimal_symbols should be run in order to clean up global state.

Parameters:
objfilethe objfile from which to get minimal symbols

Definition at line 1176 of file minsyms.c.

References build_minimal_symbol_hash_tables(), BUNCH_SIZE, compact_minimal_symbols(), compare_minimal_symbols(), msym_bunch::contents, fprintf_unfiltered(), gdb_stdlog, memcpy(), memset(), objfile::minimal_symbol_count, msym_bunch_index, msym_count, objfile::msymbols, msym_bunch::next, objfile_name(), objfile::objfile_obstack, qsort, and symtab_create_debug.

Referenced by coff_symfile_read(), dbx_symfile_read(), elf_symfile_read(), elfmdebug_build_psymtabs(), macho_symfile_read(), mipscoff_symfile_read(), som_symfile_read(), and xcoff_initial_scan().

void iterate_over_minimal_symbols ( struct objfile objf,
const char *  name,
void(*)(struct minimal_symbol *, void *)  callback,
void *  user_data 
)

Iterate over all the minimal symbols in the objfile OBJF which match NAME. Both the ordinary and demangled names of each symbol are considered. The caller is responsible for canonicalizing NAME, should that need to be done.

For each matching symbol, CALLBACK is called with the symbol and USER_DATA as arguments.

Definition at line 319 of file minsyms.c.

References case_sensitive_on, minimal_symbol::demangled_hash_next, hash(), minimal_symbol::hash_next, int, MINIMAL_SYMBOL_HASH_SIZE, objfile::msymbol_demangled_hash, msymbol_hash(), objfile::msymbol_hash, msymbol_hash_iw(), SYMBOL_LINKAGE_NAME, and SYMBOL_MATCHES_SEARCH_NAME.

Referenced by search_minsyms_for_name().

struct bound_minimal_symbol lookup_bound_minimal_symbol ( const char *  name) [read]

Like lookup_minimal_symbol, but searches all files and objfiles and returns a bound minimal symbol.

Parameters:
namestring to look for
Returns:
minimal symbol and its objfile

Definition at line 311 of file minsyms.c.

References lookup_minimal_symbol_internal().

Referenced by address_info(), find_function_in_inferior(), push_expression_name(), simple_read_overlay_table(), value_fn_field(), and write_dollar_variable().

struct minimal_symbol* lookup_minimal_symbol ( const char *  name,
const char *  sfile,
struct objfile objf 
) [read]

Look through all the current minimal symbol tables and find the first minimal symbol that matches NAME. If OBJF is non-NULL, limit the search to that objfile. If SFILE is non-NULL, the only file-scope symbols considered will be from that source file (global symbols are still preferred). Returns a pointer to the minimal symbol that matches, or NULL if no match is found.

Parameters:
namestring to look for
sfileif supplied, name of a source file
objfif supplied, pointer to objfile to lookup in

Definition at line 298 of file minsyms.c.

References lookup_minimal_symbol_internal(), and bound_minimal_symbol::minsym.

Referenced by ada_has_this_exception_support(), ada_main_name(), ada_tasks_inferior_data_sniffer(), ada_update_initial_language(), agent_look_up_symbols(), arm_skip_stub(), avr_scan_prologue(), bsd_uthread_lookup_address(), call_site_to_target_addr(), call_target_sbrk(), checkpoint_command(), coff_symfile_read(), convert_code_addr_to_desc_addr(), create_exception_master_breakpoint(), create_std_terminate_master_breakpoint(), define_symbol(), elf_gnu_ifunc_resolve_by_got(), elf_locate_base(), enable_break(), enable_dec_thread(), end_psymtab(), evaluate_subexp_standard(), find_imps(), find_objc_msgsend(), find_stab_function_addr(), flush_ea_cache(), frv_frame_this_id(), gen_var_ref(), get_running_thread_msymbol(), get_signo(), glibc_skip_solib_resolver(), gnuv3_get_typeid(), gnuv3_skip_trampoline(), go_main_name(), has_ravenscar_runtime(), hppa_hpux_skip_trampoline_code(), hppa_symbol_address(), inferior_call_waitpid(), inferior_has_bug(), inside_main_func(), jit_breakpoint_re_set_internal(), ld_so_xfer_auxv(), link_map_start(), lm_base(), locate_base(), lookup_child_selector(), lookup_objc_class(), m32c_m16c_address_to_pointer(), m32c_m16c_pointer_to_address(), m32c_return_value(), m32r_frame_this_id(), m68hc11_get_register_info(), macho_resolve_oso_sym_with_minsym(), main_got(), minsym_lookup_iterator_cb(), mips_linux_skip_resolver(), obsd_skip_solib_resolver(), ocl_enable_break(), pascal_main_name(), pd_enable(), pdc_symbol_addrs(), ppc_linux_spe_context_lookup(), ps_pglobal_lookup(), remote_check_symbols(), scope_info(), simple_overlay_update(), simple_read_overlay_table(), sol2_skip_solib_resolver(), som_solib_create_inferior_hook(), som_solib_desire_dynamic_linker_symbols(), spu_catch_start(), spu_enable_break(), spu_get_overlay_table(), tui_get_begin_asm_address(), value_nsstring(), and value_static_field().

Find the minimal symbol named NAME, and return both the minsym struct and its objfile. This only checks the linkage name.

Parameters:
namestring to look for
Returns:
minimal symbol and its objfile

Definition at line 815 of file minsyms.c.

References ALL_OBJFILES, hash(), minimal_symbol::hash_next, memset(), MINIMAL_SYMBOL_HASH_SIZE, bound_minimal_symbol::minsym, msymbol_hash(), objfile::msymbol_hash, bound_minimal_symbol::objfile, and SYMBOL_LINKAGE_NAME.

Referenced by add_pe_forwarded_sym(), address_info(), glibc_skip_solib_resolver(), and jit_breakpoint_re_set_internal().

Backward compatibility: search through the minimal symbol table for a matching PC (no section given).

This is a wrapper that calls lookup_minimal_symbol_by_pc_section with a NULL section argument.

Definition at line 735 of file minsyms.c.

References find_pc_section(), lookup_minimal_symbol_by_pc_section_1(), and memset().

Referenced by amd64_skip_main_prologue(), amd64_windows_skip_trampoline_code(), arm_pc_is_thumb(), arm_pe_skip_trampoline_code(), arm_skip_stack_protector(), arm_wince_skip_main_prologue(), c_val_print(), call_site_find_chain_1(), call_site_for_pc(), call_site_to_target_addr(), convert_code_addr_to_desc_addr(), dwarf_expr_reg_to_entry_parameter(), elf_gnu_ifunc_record_cache(), find_frame_funname(), find_pc_sect_line(), frame_info(), frv_skip_main_prologue(), func_verify_no_selftailcall(), get_function_name(), get_pc_function_start(), get_prev_frame_1(), gnuv2_value_rtti_type(), gnuv3_get_typename_from_type_info(), gnuv3_rtti_type(), gnuv3_skip_trampoline(), hppa32_hpux_in_solib_call_trampoline(), hppa64_hpux_in_solib_call_trampoline(), hppa_hpux_find_import_stub_for_addr(), hppa_hpux_skip_trampoline_code(), i386_pe_skip_trampoline_code(), i386_skip_main_prologue(), ia64_convert_from_func_ptr_addr(), in_gnu_ifunc_stub(), info_cb(), info_checkpoints_command(), m32c_m16c_address_to_pointer(), m32c_m16c_pointer_to_address(), m68hc11_get_return_insn(), maintenance_translate_address(), mips_pc_is_micromips(), mips_pc_is_mips(), mips_pc_is_mips16(), mips_pc_isa(), mips_skip_pic_trampoline_code(), mips_stub_frame_sniffer(), msp430_skip_trampoline_code(), pascal_val_print(), pc_function_name(), pc_is_isa32(), powerpc_linux_in_dynsym_resolve_code(), py_print_frame(), read_atcb(), resolve_sal_pc(), rs6000_skip_main_prologue(), rs6000_skip_trampoline_code(), skip_prologue_function(), tailcall_dump(), until_next_command(), VEC(), and write_exp_msymbol().

struct minimal_symbol* lookup_minimal_symbol_by_pc_name ( CORE_ADDR  ,
const char *  ,
struct objfile  
) [read]

Look through all the current minimal symbol tables and find the first minimal symbol that matches NAME and PC. If OBJF is non-NULL, limit the search to that objfile. Returns a pointer to the minimal symbol that matches, or NULL if no match is found.

Definition at line 405 of file minsyms.c.

References hash(), minimal_symbol::hash_next, MINIMAL_SYMBOL_HASH_SIZE, msymbol_hash(), objfile::msymbol_hash, objfile::next, object_files, objfile::separate_debug_objfile_backlink, SYMBOL_LINKAGE_NAME, and SYMBOL_VALUE_ADDRESS.

Referenced by arm_exidx_new_objfile(), and fixup_section().

Search through the minimal symbol table for each objfile and find the symbol whose address is the largest address that is still less than or equal to PC, and which matches SECTION.

If SECTION is NULL, this uses the result of find_pc_section instead.

The result has a non-NULL 'minsym' member if such a symbol is found, or NULL if PC is not in a suitable range.

Definition at line 713 of file minsyms.c.

References find_pc_section(), lookup_minimal_symbol_by_pc_section_1(), and memset().

Referenced by build_address_symbolic(), find_pc_partial_function_gnu_ifunc(), find_pc_sect_symtab(), find_pc_sect_symtab_via_partial(), maintenance_translate_address(), skip_prologue_sal(), sym_info(), and tui_find_disassembly_address().

static struct bound_minimal_symbol lookup_minimal_symbol_by_pc_section_1 ( CORE_ADDR  pc,
struct obj_section section,
int  want_trampoline 
) [static, read]
static struct bound_minimal_symbol lookup_minimal_symbol_internal ( const char *  name,
const char *  sfile,
struct objfile objf 
) [static, read]
struct minimal_symbol* lookup_minimal_symbol_solib_trampoline ( const char *  ,
struct objfile  
) [read]

Look through all the current minimal symbol tables and find the first minimal symbol that matches NAME and is a solib trampoline. If OBJF is non-NULL, limit the search to that objfile. Returns a pointer to the minimal symbol that matches, or NULL if no match is found.

This function only searches the mangled (linkage) names.

Definition at line 437 of file minsyms.c.

References hash(), minimal_symbol::hash_next, MINIMAL_SYMBOL_HASH_SIZE, mst_solib_trampoline, msymbol_hash(), objfile::msymbol_hash, MSYMBOL_TYPE, objfile::next, object_files, objfile::separate_debug_objfile_backlink, and SYMBOL_LINKAGE_NAME.

Referenced by hppa_hpux_find_import_stub_for_addr(), and som_solib_desire_dynamic_linker_symbols().

struct minimal_symbol* lookup_minimal_symbol_text ( const char *  name,
struct objfile objf 
) [read]

Look through all the current minimal symbol tables and find the first minimal symbol that matches NAME and has text type. If OBJF is non-NULL, limit the search to that objfile. Returns a pointer to the minimal symbol that matches, or NULL if no match is found.

This function only searches the mangled (linkage) names.

Definition at line 353 of file minsyms.c.

References hash(), minimal_symbol::hash_next, MINIMAL_SYMBOL_HASH_SIZE, mst_file_text, mst_text, mst_text_gnu_ifunc, msymbol_hash(), objfile::msymbol_hash, MSYMBOL_TYPE, objfile::next, object_files, objfile::separate_debug_objfile_backlink, and SYMBOL_LINKAGE_NAME.

Referenced by create_longjmp_master_breakpoint(), create_overlay_event_breakpoint(), and find_pc_sect_line().

static struct minimal_symbol* lookup_solib_trampoline_symbol_by_pc ( CORE_ADDR  pc) [static, read]
struct cleanup* make_cleanup_discard_minimal_symbols ( void  ) [read]

Return a cleanup which is used to clean up the global state left over by minimal symbol creation. After calling init_minimal_symbol_collection, a symbol reader should call this function. Then, after all minimal symbols have been read, regardless of whether they are installed or not, the cleanup returned by this function should be run.

Definition at line 1045 of file minsyms.c.

References do_discard_minimal_symbols_cleanup(), and make_cleanup().

Referenced by coff_symfile_read(), dbx_symfile_read(), elf_symfile_read(), elfmdebug_build_psymtabs(), macho_symfile_read(), mipscoff_symfile_read(), som_symfile_read(), and xcoff_initial_scan().

unsigned int msymbol_hash ( const char *  )
unsigned int msymbol_hash_iw ( const char *  )

Like msymbol_hash, but compute a hash code that is compatible with strcmp_iw.

Definition at line 83 of file minsyms.c.

References hash(), skip_spaces_const(), string, and SYMBOL_HASH_NEXT.

Referenced by add_minsym_to_demangled_hash_table(), dict_hash(), iterate_over_minimal_symbols(), and lookup_minimal_symbol_internal().

void msymbols_sort ( struct objfile objfile)

Sort all the minimal symbols in OBJFILE. This should be only be called after relocating symbols; it ensures that the minimal symbols are properly sorted by address.

Definition at line 1289 of file minsyms.c.

References build_minimal_symbol_hash_tables(), compare_minimal_symbols(), objfile::minimal_symbol_count, objfile::msymbols, and qsort.

Referenced by objfile_relocate1().

void prim_record_minimal_symbol ( const char *  ,
CORE_ADDR  ,
enum  minimal_symbol_type,
struct objfile  
)

Like prim_record_minimal_symbol_full, but:

  • uses strlen to compute NAME_LEN,
  • passes COPY_NAME = 0,
  • and passes a default SECTION, depending on the type

This variant does not return the new symbol.

Definition at line 874 of file minsyms.c.

References mst_bss, mst_data, mst_file_bss, mst_file_data, mst_file_text, mst_solib_trampoline, mst_text, mst_text_gnu_ifunc, prim_record_minimal_symbol_and_info(), SECT_OFF_BSS, SECT_OFF_DATA, and SECT_OFF_TEXT.

Referenced by add_pe_exported_sym(), add_pe_forwarded_sym(), read_alphacoff_dynamic_symtab(), and read_dbx_dynamic_symtab().

struct minimal_symbol* prim_record_minimal_symbol_and_info ( const char *  ,
CORE_ADDR  ,
enum  minimal_symbol_type,
int  section,
struct objfile  
) [read]

Like prim_record_minimal_symbol_full, but:

  • uses strlen to compute NAME_LEN,
  • passes COPY_NAME = 0.

Definition at line 973 of file minsyms.c.

References prim_record_minimal_symbol_full().

Referenced by macho_symtab_add_minsym(), parse_partial_symbols(), prim_record_minimal_symbol(), record_minimal_symbol(), and som_symtab_read().

struct minimal_symbol* prim_record_minimal_symbol_full ( const char *  name,
int  name_len,
int  copy_name,
CORE_ADDR  address,
enum minimal_symbol_type  ms_type,
int  section,
struct objfile objfile 
) [read]

Record a new minimal symbol. This is the "full" entry point; simpler convenience entry points are also provided below.

This returns a new minimal symbol. It is ok to modify the returned minimal symbol (though generally not necessary). It is not ok, though, to stash the pointer anywhere; as minimal symbols may be moved after creation. The memory for the returned minimal symbol is still owned by the minsyms.c code, and should not be freed.

Arguments are:

Parameters:
NAME- the symbol's name
NAME_LEN- the length of the name
COPY_NAME- if true, the minsym code must make a copy of NAME. If false, then NAME must be NUL-terminated, and must have a lifetime that is at least as long as OBJFILE's lifetime.
ADDRESS- the address of the symbol
MS_TYPE- the type of the symbol
SECTION- the symbol's section appropriate obj_section for the minimal symbol. This can be NULL.
OBJFILE- the objfile associated with the minimal symbol.

Definition at line 907 of file minsyms.c.

References BUNCH_SIZE, msym_bunch::contents, minimal_symbol::demangled_hash_next, get_symbol_leading_char(), minimal_symbol::hash_next, language_auto, mst_file_text, msym_bunch, msym_bunch_index, msym_count, MSYMBOL_TARGET_FLAG_1, MSYMBOL_TARGET_FLAG_2, MSYMBOL_TYPE, name, objfile::obfd, objfile::objfile_obstack, OBJSTAT, minimal_symbol::size, SYMBOL_SECTION, SYMBOL_SET_LANGUAGE, SYMBOL_SET_NAMES, SYMBOL_VALUE_ADDRESS, and XCALLOC.

Referenced by prim_record_minimal_symbol_and_info(), and record_minimal_symbol().

static CORE_ADDR stub_gnu_ifunc_resolve_addr ( struct gdbarch gdbarch,
CORE_ADDR  pc 
) [static]

Definition at line 762 of file minsyms.c.

References _, error(), and paddress().

static int stub_gnu_ifunc_resolve_name ( const char *  function_name,
CORE_ADDR function_address_p 
) [static]

Definition at line 772 of file minsyms.c.

References _, and error().

static void stub_gnu_ifunc_resolver_return_stop ( struct breakpoint b) [static]

Definition at line 792 of file minsyms.c.

References _, and internal_error().

static void stub_gnu_ifunc_resolver_stop ( struct breakpoint b) [static]

Definition at line 783 of file minsyms.c.

References _, and internal_error().

void terminate_minimal_symbol_table ( struct objfile objfile)

Create the terminating entry of OBJFILE's minimal symbol table. If OBJFILE->msymbols is zero, allocate a single entry from OBJFILE->objfile_obstack; otherwise, just initialize OBJFILE->msymbols[OBJFILE->minimal_symbol_count].

Definition at line 1268 of file minsyms.c.

References language_unknown, arm-linux::m, memset(), objfile::minimal_symbol_count, mst_unknown, MSYMBOL_TYPE, objfile::msymbols, objfile::objfile_obstack, and SYMBOL_SET_LANGUAGE.

Referenced by allocate_objfile(), jit_object_close_impl(), and reread_symbols().


Variable Documentation

Definition at line 810 of file minsyms.c.

struct msym_bunch* msym_bunch [static]

Definition at line 70 of file minsyms.c.

Referenced by prim_record_minimal_symbol_full().

int msym_count [static]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines