53#include "gdbsupport/symbol.h"
55#include "gdbsupport/gdb-safe-ctype.h"
56#include "gdbsupport/parallel-for.h"
75 size_t name_len = strlen (
name);
79 const char *last = &
name[name_len - 1];
83 const char *suffix =
" [clone .cold";
84 size_t suffix_len = strlen (suffix);
85 const char *found = strstr (
name, suffix);
89 const char *start = &found[suffix_len];
97 for (p = start + 1; p <= last; ++p)
99 if (*p >=
'0' && *p <=
'9')
114 CORE_ADDR *func_address_p)
118 switch (minsym->
type ())
133 if (func_address_p != NULL)
134 *func_address_p = pc;
145 if (func_address_p != NULL)
146 *func_address_p = msym_addr;
154#define BUNCH_SIZE 127
167 unsigned int hash = 0;
169 while (*
string && *
string !=
'(')
171 string = skip_spaces (
string);
172 if (*
string && *
string !=
'(')
186 unsigned int hash = 0;
188 for (; *string; ++string)
197 unsigned int hash_value)
213 unsigned int hash_value)
223 table[hash_index] = sym;
256 switch (msymbol->
type ())
262 || filename_cmp (msymbol->
filename, sfile) == 0)
303 int (*namecmp) (
const char *,
const char *),
310 const char *symbol_name = msymbol->linkage_name ();
312 if (namecmp (symbol_name, lookup_name) == 0
334 const char *symbol_name = msymbol->search_name ();
336 if (matcher (symbol_name, lookup_name, NULL)
376 sfile = lbasename (sfile);
385 if (objf == NULL || objf ==
objfile
389 name, sfile != NULL ? sfile :
"NULL",
396 mangled_hash, mangled_cmp, found);
420 msymbol_demangled_hash,
438 (
"lookup_minimal_symbol (...) = %s (external)",
439 host_address_to_string (minsym));
452 (
"lookup_minimal_symbol (...) = %s (file-local)",
453 host_address_to_string (minsym));
466 (
"lookup_minimal_symbol (...) = %s (trampoline)",
467 host_address_to_string (minsym));
498 return sym.
minsym == NULL;
517 return lookup_name.
c_str ();
538 iter = iter->hash_next)
540 if (mangled_cmp (iter->linkage_name (),
name) == 0)
563 iter = iter->demangled_hash_next)
564 if (name_match (iter->search_name (), lookup_name, NULL))
581 msymbol = msymbol->hash_next)
583 if (strcmp (msymbol->linkage_name (),
name) == 0
585 || msymbol->type () ==
mst_bss))
608 if (
minsym.minsym !=
nullptr)
628 if (found_symbol.
minsym != NULL)
631 if (objf == NULL || objf ==
objfile
635 msymbol != NULL && found_symbol.
minsym == NULL;
643 switch (msymbol->
type ())
646 found_file_symbol.
minsym = msymbol;
650 found_symbol.
minsym = msymbol;
663 return found_file_symbol;
678 if (objf == NULL || objf ==
objfile
706 if (pc >= iter->addr () && pc < iter->endaddr ())
708 *
unrel_addr = unrelocated_addr (pc - iter->offset ());
734 gdb_assert_not_reached (
"unhandled lookup_msym_prefer");
755 struct objfile *best_objfile = NULL;
758 if (previous !=
nullptr)
760 previous->
minsym =
nullptr;
782 gdb_assert (section != NULL);
786 CORE_ADDR pc = pc_in;
793 int best_zero_sized = -1;
817 unrelocated_addr unrel_pc;
821 while (msymbol[hi].unrelocated_address () > unrel_pc)
825 newobj = (lo + hi) / 2;
826 if ((msymbol[newobj].unrelocated_address () >= unrel_pc)
840 while (hi < objfile->per_bfd->minimal_symbol_count - 1
886 && msymbol[hi].
type () != want_type
887 && msymbol[hi - 1].
type () == want_type
888 && (msymbol[hi].
size () == msymbol[hi - 1].
size ())
889 && (msymbol[hi].unrelocated_address ()
904 if (msymbol[hi].
size () == 0)
906 if (best_zero_sized == -1)
907 best_zero_sized = hi;
918 && msymbol[hi].
size () != 0
936 if (best_zero_sized != -1
937 && (hi < 0 || msymbol[hi].
size () == 0))
938 hi = best_zero_sized;
948 && msymbol[hi].
size () != 0
951 if (best_zero_sized != -1)
952 hi = best_zero_sized;
957 if (previous !=
nullptr)
959 if (previous->
minsym ==
nullptr
963 previous->
minsym = &msymbol[hi];
1017 error (_(
"GDB cannot resolve STT_GNU_IFUNC symbol at address %s without "
1018 "the ELF support compiled in."),
1026 CORE_ADDR *function_address_p)
1028 error (_(
"GDB cannot resolve STT_GNU_IFUNC symbol \"%s\" without "
1029 "the ELF support compiled in."),
1038 internal_error (_(
"elf_gnu_ifunc_resolver_stop cannot be reached."));
1046 internal_error (_(
"elf_gnu_ifunc_resolver_return_stop cannot be reached."));
1072 return bfd_get_symbol_leading_char (abfd);
1076 if (objf->
obfd != NULL)
1077 return bfd_get_symbol_leading_char (objf->
obfd.get ());
1086 m_msym_bunch (NULL),
1149#define MST_TO_STR(x) case x: return #x;
1201 hex_string (LONGEST (address)),
1202 section, (
int)
name.size (),
name.data ());
1260 return strcmp (name1, name2) < 0;
1306 copyfrom = copyto = msymbol;
1307 while (copyfrom < msymbol + mcount - 1)
1310 == (copyfrom + 1)->unrelocated_address ()
1312 == (copyfrom + 1)->section_index ())
1314 (copyfrom + 1)->linkage_name ()) == 0)
1322 *copyto++ = *copyfrom++;
1324 *copyto++ = *copyfrom++;
1325 mcount = copyto - msymbol;
1361 const std::vector<computed_hash_values>& hash_values)
1375 hash_values[i].minsym_hash);
1380 (msym,
objfile, hash_values[i].minsym_demangled_hash);
1412 gdb::unique_xmalloc_ptr<minimal_symbol>
1414 msymbols = msym_holder.get ();
1433 memcpy (&msymbols[mcount], &bunch->
contents[0],
1448 msym_holder.release (),
1464 std::mutex demangled_mutex;
1467 std::vector<computed_hash_values> hash_values (mcount);
1471 gdb::parallel_for_each (10, &msymbols[0], &msymbols[mcount],
1476 size_t idx = msym - msymbols;
1477 hash_values[idx].name_length = strlen (msym->linkage_name ());
1478 if (!msym->name_set)
1481 gdb::unique_xmalloc_ptr<char> demangled_name
1483 msym->set_demangled_name
1484 (demangled_name.release (),
1491 hash_values[idx].mangled_name_hash
1492 = fast_hash (msym->linkage_name (),
1493 hash_values[idx].name_length);
1494 hash_values[idx].minsym_hash
1499 if (msym->search_name () != msym->linkage_name ())
1500 hash_values[idx].minsym_demangled_hash
1507 std::lock_guard<std::mutex> guard (demangled_mutex);
1511 size_t idx = msym - msymbols;
1513 (gdb::string_view (msym->linkage_name (),
1514 hash_values[idx].name_length),
1517 hash_values[idx].mangled_name_hash);
1537 if (msymbol.
minsym != NULL
1558 if (tsymbol != NULL)
1570 && strcmp (msymbol->linkage_name (),
1596 gdb_assert (minsym.
minsym != NULL);
1614 for (iter = msymbol + 1; iter != past_the_end; ++iter)
1623 if (iter != past_the_end
1640 CORE_ADDR *address_p)
1646 bool is_tls = (section != NULL
1681 if (address_p != NULL)
1686 if (address_p != NULL)
bool best_symbol(struct symbol *a, const domain_enum domain)
const std::string & lookup_name() const
unsigned int search_name_hash(language lang) const
const char * c_str() const
const ada_lookup_name_info & ada() const
struct msym_bunch * m_msym_bunch
void record(const char *name, unrelocated_addr address, enum minimal_symbol_type ms_type)
struct objfile * m_objfile
minimal_symbol_reader(struct objfile *)
void record_with_info(const char *name, unrelocated_addr address, enum minimal_symbol_type ms_type, int section)
struct minimal_symbol * record_full(gdb::string_view name, bool copy_name, unrelocated_addr address, enum minimal_symbol_type ms_type, int section)
CORE_ADDR gdbarch_convert_from_func_ptr_addr(struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
struct inferior * current_inferior(void)
const struct language_defn * language_def(enum language lang)
const struct language_defn * current_language
bound_minimal_symbol lookup_minimal_symbol_by_pc_section(CORE_ADDR pc_in, struct obj_section *section, lookup_msym_prefer prefer, bound_minimal_symbol *previous)
static void add_minsym_to_demangled_hash_table(struct minimal_symbol *sym, struct objfile *objfile, unsigned int hash_value)
CORE_ADDR minimal_symbol_upper_bound(struct bound_minimal_symbol minsym)
static void build_minimal_symbol_hash_tables(struct objfile *objfile, const std::vector< computed_hash_values > &hash_values)
static bool minimal_symbol_is_less_than(const minimal_symbol &fn1, const minimal_symbol &fn2)
static const char * mst_str(minimal_symbol_type t)
bound_minimal_symbol lookup_minimal_symbol_linkage(const char *name, struct objfile *objf)
static bool stub_gnu_ifunc_resolve_name(const char *function_name, CORE_ADDR *function_address_p)
static const char * linkage_name_str(const lookup_name_info &lookup_name)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
static struct minimal_symbol * lookup_solib_trampoline_symbol_by_pc(CORE_ADDR pc)
static int get_symbol_leading_char(bfd *abfd)
static void stub_gnu_ifunc_resolver_return_stop(code_breakpoint *b)
static void clear_minimal_symbol_hash_tables(struct objfile *objfile)
static int frob_address(struct objfile *objfile, CORE_ADDR pc, unrelocated_addr *unrel_addr)
CORE_ADDR find_solib_trampoline_target(frame_info_ptr frame, CORE_ADDR pc)
struct bound_minimal_symbol lookup_bound_minimal_symbol(const char *name)
unsigned int msymbol_hash_iw(const char *string)
const struct gnu_ifunc_fns * gnu_ifunc_fns_p
int find_minimal_symbol_address(const char *name, CORE_ADDR *addr, struct objfile *objfile)
static bool msymbol_is_cold_clone(minimal_symbol *minsym)
static CORE_ADDR stub_gnu_ifunc_resolve_addr(struct gdbarch *gdbarch, CORE_ADDR pc)
static int compact_minimal_symbols(struct minimal_symbol *msymbol, int mcount, struct objfile *objfile)
static void stub_gnu_ifunc_resolver_stop(code_breakpoint *b)
type * find_minsym_type_and_address(minimal_symbol *msymbol, struct objfile *objfile, CORE_ADDR *address_p)
static void add_minsym_to_hash_table(struct minimal_symbol *sym, struct minimal_symbol **table, unsigned int hash_value)
unsigned int msymbol_hash(const char *string)
void iterate_over_minimal_symbols(struct objfile *objf, const lookup_name_info &lookup_name, gdb::function_view< bool(struct minimal_symbol *)> callback)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
struct minimal_symbol * lookup_minimal_symbol_by_pc_name(CORE_ADDR pc, const char *name, struct objfile *objf)
struct bound_minimal_symbol lookup_minimal_symbol_text(const char *name, struct objfile *objf)
bool in_gnu_ifunc_stub(CORE_ADDR pc)
static void lookup_minimal_symbol_mangled(const char *lookup_name, const char *sfile, struct objfile *objfile, struct minimal_symbol **table, unsigned int hash, int(*namecmp)(const char *, const char *), found_minimal_symbols &found)
static minimal_symbol_type msym_prefer_to_msym_type(lookup_msym_prefer prefer)
bool msymbol_is_function(struct objfile *objfile, minimal_symbol *minsym, CORE_ADDR *func_address_p)
static const struct gnu_ifunc_fns stub_gnu_ifunc_fns
static void lookup_minimal_symbol_demangled(const lookup_name_info &lookup_name, const char *sfile, struct objfile *objfile, struct minimal_symbol **table, unsigned int hash, symbol_name_matcher_ftype *matcher, found_minimal_symbols &found)
unsigned int msymbol_hash(const char *)
#define SYMBOL_HASH_NEXT(hash, c)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc_section(CORE_ADDR pc_in, struct obj_section *section, lookup_msym_prefer prefer=lookup_msym_prefer::TEXT, bound_minimal_symbol *previous=nullptr)
const char * objfile_debug_name(const struct objfile *objfile)
struct obj_section * find_pc_section(CORE_ADDR pc)
const char * objfile_name(const struct objfile *objfile)
#define MINIMAL_SYMBOL_HASH_SIZE
#define SECT_OFF_BSS(objfile)
#define SECT_OFF_DATA(objfile)
#define SECT_OFF_TEXT(objfile)
std::string copy_name(struct stoken token)
struct program_space * current_program_space
static void set_type(type_object *obj, struct type *type)
void(* func)(remote_target *remote, char *)
CORE_ADDR value_address() const
struct minimal_symbol * minsym
struct obj_section * obj_section() const
struct type * nodebug_text_gnu_ifunc_symbol
struct type * nodebug_tls_symbol
struct type * nodebug_got_plt_symbol
struct type * nodebug_data_symbol
struct type * nodebug_unknown_symbol
struct type * nodebug_text_symbol
unsigned int minsym_demangled_hash
hashval_t mangled_name_hash
bound_minimal_symbol file_symbol
bound_minimal_symbol external_symbol
bool maybe_collect(const char *sfile, objfile *objf, minimal_symbol *msymbol)
bound_minimal_symbol trampoline_symbol
void set_section_index(short idx)
const char * natural_name() const
void compute_and_set_names(gdb::string_view linkage_name, bool copy_name, struct objfile_per_bfd_storage *per_bfd, gdb::optional< hashval_t > hash=gdb::optional< hashval_t >())
const char * search_name() const
void set_unrelocated_address(unrelocated_addr addr)
enum language language() const
void set_language(enum language language, struct obstack *obstack)
short section_index() const
struct obj_section * obj_section(const struct objfile *objfile) const
const char * linkage_name() const
unrelocated_addr unrel_addr
enum language la_language
symbol_name_matcher_ftype * get_symbol_name_matcher(const lookup_name_info &lookup_name) const
void set_type(minimal_symbol_type type)
struct minimal_symbol * hash_next
struct minimal_symbol * demangled_hash_next
unsigned long size() const
minimal_symbol_type type() const
unrelocated_addr unrelocated_end_address() const
CORE_ADDR value_address(objfile *objfile) const
unrelocated_addr unrelocated_address() const
struct minimal_symbol contents[BUNCH_SIZE]
CORE_ADDR endaddr() const
struct bfd_section * the_bfd_section
minimal_symbol * msymbol_hash[MINIMAL_SYMBOL_HASH_SIZE]
auto_obstack storage_obstack
minimal_symbol * msymbol_demangled_hash[MINIMAL_SYMBOL_HASH_SIZE]
std::bitset< nr_languages > demangled_hash_languages
gdb::unique_xmalloc_ptr< minimal_symbol > msymbols
iterator_range< section_iterator > sections()
struct objfile * separate_debug_objfile_backlink
struct gdbarch * arch() const
struct objfile_per_bfd_storage * per_bfd
separate_debug_range separate_debug_objfiles()
msymbols_range msymbols()
objfiles_range objfiles()
struct objfile * symfile_object_file
enum overlay_debugging_state overlay_debugging
CORE_ADDR symbol_overlayed_address(CORE_ADDR address, struct obj_section *section)
gdb::unique_xmalloc_ptr< char > symbol_find_demangled_name(struct general_symbol_info *gsymbol, const char *mangled)
bool matching_obj_sections(struct obj_section *obj_first, struct obj_section *obj_second)
unsigned int symbol_lookup_debug
unsigned int search_name_hash(enum language language, const char *search_name)
#define GCC_COMPILED_FLAG_SYMBOL
#define GCC2_COMPILED_FLAG_SYMBOL
#define symbol_lookup_debug_printf(fmt,...)
bool symbol_name_matcher_ftype(const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res)
#define symtab_create_debug_printf_v(fmt,...)
#define symtab_create_debug_printf(fmt,...)
CORE_ADDR target_translate_tls_address(struct objfile *objfile, CORE_ADDR offset)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)