25 #include "filenames.h" 32 #include "readline/readline.h" 116 #define ALL_OBJFILE_PSYMTABS_REQUIRED(objfile, p) \ 117 for ((p) = require_partial_symbols (objfile, 1)->psymtabs; \ 123 #undef ALL_OBJFILE_PSYMTABS 127 #define ALL_PSYMTABS(objfile, p) \ 128 ALL_OBJFILES (objfile) \ 129 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p) 137 const char *real_path,
156 last_made, callback);
166 const char *real_path,
170 const char *name_basename = lbasename (
name);
176 if (pst->
user != NULL)
194 && FILENAME_CMP (name_basename, lbasename (pst->
filename)) != 0)
207 if (real_path != NULL)
247 if (msymbol.
minsym == NULL)
257 for (tpst = pst; tpst != NULL; tpst = tpst->
next)
293 if (this_addr > best_addr)
295 best_addr = this_addr;
365 && pc >= pst->
textlow && pc < pst->texthigh)
371 if (best_pst != NULL)
392 if (warn_if_readin &&
ps->readin)
397 (Internal error: pc %s in read in psymtab, but not in symtab.)\n"),
400 return ps->compunit_symtab;
507 int block_index,
const char *
name,
511 const int psymtab_index = (block_index ==
GLOBAL_BLOCK ? 1 : 0);
519 psymtab_index, domain))
521 struct symbol *sym, *with_opaque = NULL;
540 if (with_opaque != NULL
581 int do_linear_search = 1;
592 if (
global && ordered_compare)
594 do_linear_search = 0;
603 top = start + length - 1;
607 center = bottom + (top - bottom) / 2;
621 while (top <= real_top
634 if (do_linear_search)
636 for (psym = start; psym < start + length; psym++)
661 if (strchr (
name,
'('))
689 int do_linear_search = 1;
704 do_linear_search = 0;
713 top = start + length - 1;
717 center = bottom + (top - bottom) / 2;
720 _(
"failed internal consistency check"));
722 search_name.get ()) >= 0)
731 if (!(top == bottom))
733 _(
"failed internal consistency check"));
755 if (do_linear_search)
757 for (psym = start; psym < start + length; psym++)
780 while (pst->
user != NULL)
841 const char *
name =
ps->filename;
842 int len = strlen (
name);
844 if (!(len > 2 && (strcmp (&
name[len - 2],
".h") == 0
845 || strcmp (
name,
"<<C++-namespaces>>") == 0)))
854 _(
"select_source_symtab: " 855 "readin pst found and no symtabs."));
1006 " Full symtab was read (at ");
1029 if (psymtab->
user != NULL)
1062 if (
ps->readin == 0)
1081 psymtab = psymtab->
next)
1098 const char *func_name)
1172 if (
ps->user != NULL)
1204 if (
ps->fullname == NULL)
1217 if (
ps->dirname == NULL || IS_ABSOLUTE_PATH (
ps->filename))
1221 ps->filename, (
char *) NULL));
1224 if (
ps->fullname == NULL)
1229 return ps->fullname;
1240 int (*callback) (
struct block *,
struct symbol *,
void *),
1255 if (callback (
block, sym, data))
1270 int (*callback) (
struct block *,
1271 struct symbol *,
void *),
1293 callback, data, match))
1295 if (callback (
block, NULL, data))
1321 for (i = 0; i <
ps->number_of_dependencies; ++i)
1326 if (
ps->dependencies[i]->user == NULL)
1352 if (bound == gbound &&
ps->n_static_syms != 0)
1384 ps->searched_flag = result;
1419 if (
ps->user != NULL)
1429 match = file_matcher (
ps->filename,
false);
1435 || file_matcher (lbasename (
ps->filename),
true))
1443 lookup_name, symbol_matcher))
1448 if (expansion_notify != NULL)
1449 expansion_notify (
symtab);
1469 std::set<CORE_ADDR> *seen_addrs,
1470 const std::vector<partial_symbol *> &symbols,
1474 for (
int i = 0; i < length; ++i)
1481 if (seen_addrs->find (addr) == seen_addrs->end ())
1483 seen_addrs->insert (addr);
1501 std::set<CORE_ADDR> seen_addrs;
1520 [] (
const std::pair<CORE_ADDR, partial_symtab *> &a,
1521 const std::pair<CORE_ADDR, partial_symtab *> &b)
1523 return a.first < b.first;
1527 auto iter = std::lower_bound
1529 [] (
const std::pair<CORE_ADDR, partial_symtab *> &a,
1590 std::vector<partial_symbol *> &global_psymbols,
1591 std::vector<partial_symbol *> &static_psymbols)
1619 static unsigned long 1622 unsigned long h = 0;
1725 memset (&psymbol, 0,
sizeof (psymbol));
1746 list->push_back (psym);
1760 std::vector<partial_symbol *> *list,
1829 static char *last_objfile_name = NULL;
1831 if (last_objfile_name == NULL
1834 xfree (last_objfile_name);
1837 "Creating one or more psymtabs for objfile %s ...\n",
1841 "Created psymtab %s for module %s.\n",
1863 while ((*prev_pst) != pst)
1864 prev_pst = &((*prev_pst)->next);
1865 (*prev_pst) = pst->
next;
1899 const char *psymtab_address_or_end = NULL;
1904 || data->
psymtab == addrmap_psymtab)
1907 psymtab_address_or_end =
"<ends here>";
1910 || data->
psymtab == addrmap_psymtab
1914 data->
psymtab != NULL ?
" " :
"",
1916 psymtab_address_or_end);
1920 || data->
psymtab == addrmap_psymtab);
1943 psymtab == NULL ?
"Entire a" :
" A");
1945 &addrmap_dump_data);
1953 char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL;
1956 int i, outfile_idx, found;
1964 for (i = 0;
argv != NULL &&
argv[i] != NULL; ++i)
1966 if (strcmp (
argv[i],
"-pc") == 0)
1968 if (
argv[i + 1] == NULL)
1969 error (
_(
"Missing pc value"));
1970 address_arg =
argv[++i];
1972 else if (strcmp (
argv[i],
"-source") == 0)
1974 if (
argv[i + 1] == NULL)
1975 error (
_(
"Missing source file"));
1976 source_arg =
argv[++i];
1978 else if (strcmp (
argv[i],
"-objfile") == 0)
1980 if (
argv[i + 1] == NULL)
1981 error (
_(
"Missing objfile name"));
1982 objfile_arg =
argv[++i];
1984 else if (strcmp (
argv[i],
"--") == 0)
1990 else if (
argv[i][0] ==
'-')
2000 if (address_arg != NULL && source_arg != NULL)
2001 error (
_(
"Must specify at most one of -pc and -source"));
2005 if (
argv != NULL &&
argv[outfile_idx] != NULL)
2007 if (
argv[outfile_idx + 1] != NULL)
2008 error (
_(
"Junk at end of command"));
2010 (tilde_expand (
argv[outfile_idx]));
2011 if (!arg_outfile.
open (outfile_name.get (), FOPEN_WT))
2013 outfile = &arg_outfile;
2016 if (address_arg != NULL)
2026 int printed_objfile_header = 0;
2027 int print_for_objfile = 1;
2030 if (objfile_arg != NULL)
2034 if (!print_for_objfile)
2037 if (address_arg != NULL)
2046 if (!printed_objfile_header)
2048 outfile->
printf (
"\nPartial symtabs for objfile %s\n",
2050 printed_objfile_header = 1;
2061 int print_for_source = 0;
2064 if (source_arg != NULL)
2070 if (source_arg == NULL
2071 || print_for_source)
2073 if (!printed_objfile_header)
2075 outfile->
printf (
"\nPartial symtabs for objfile %s\n",
2077 printed_objfile_header = 1;
2087 if (address_arg == NULL
2088 && source_arg == NULL
2091 outfile->
puts (
"\n");
2098 if (address_arg != NULL)
2099 error (
_(
"No partial symtab for address: %s"), address_arg);
2100 if (source_arg != NULL)
2101 error (
_(
"No partial symtab for source file: %s"), source_arg);
2124 int printed_objfile_start = 0;
2133 if (! printed_objfile_start)
2139 printed_objfile_start = 1;
2148 psymtab->
readin ?
"yes" :
"no");
2196 "((struct partial_symtab *) %s)\n",
2208 if (printed_objfile_start)
2233 cust =
ps->compunit_symtab;
2236 if (
ps->texthigh <
ps->textlow)
2254 length =
ps->n_static_syms;
2272 length =
ps->n_global_syms;
2288 if (
ps->texthigh != 0
2310 Print dump of current partial symbol definitions.\n\ 2311 Usage: mt print psymbols [-objfile objfile] [-pc address] [--] [outfile]\n\ 2312 mt print psymbols [-objfile objfile] [-source source] [--] [outfile]\n\ 2313 Entries in the partial symbol table are dumped to file OUTFILE,\n\ 2314 or the terminal if OUTFILE is unspecified.\n\ 2315 If ADDRESS is provided, dump only the file for that address.\n\ 2316 If SOURCE is provided, dump only that file's symbols.\n\ 2317 If OBJFILE is provided, dump only that file's minimal symbols."),
2321 List the partial symbol tables for all object files.\n\ 2322 This does not include information about individual partial symbols,\n\ 2323 just the symbol table structures themselves."),
2328 Check consistency of currently expanded psymtabs versus symtabs."),
static void psym_expand_all_symtabs(struct objfile *objfile)
const void * bcache(const void *addr, int length, struct bcache *cache)
unsigned long hash_continue(const void *addr, int length, unsigned long h)
#define SECT_OFF_TEXT(objfile)
struct psymbol_bcache * psymbol_bcache_init(void)
int block_find_non_opaque_type_preferred(struct symbol *sym, void *data)
static struct compunit_symtab * psym_find_pc_sect_compunit_symtab(struct objfile *objfile, struct bound_minimal_symbol msymbol, CORE_ADDR pc, struct obj_section *section, int warn_if_readin)
static struct partial_symtab * find_pc_sect_psymtab(struct objfile *objfile, CORE_ADDR pc, struct obj_section *section, struct bound_minimal_symbol msymbol)
struct bcache * psymbol_bcache_get_bcache(struct psymbol_bcache *bcache)
void psymbol_bcache_free(struct psymbol_bcache *bcache)
int find_and_open_source(const char *filename, const char *dirname, char **fullname)
#define BMSYMBOL_VALUE_ADDRESS(symbol)
static struct partial_symbol * psymbol_bcache_full(struct partial_symbol *sym, struct psymbol_bcache *bcache, int *added)
void warning(const char *fmt,...)
#define ALL_OBJFILE_PSYMTABS_REQUIRED(objfile, p)
int objfile_has_symbols(struct objfile *objfile)
struct program_space * pspace
static bool partial_map_expand_apply(struct objfile *objfile, const char *name, const char *real_path, struct partial_symtab *pst, gdb::function_view< bool(symtab *)> callback)
struct partial_symtab * allocate_psymtab(const char *filename, struct objfile *objfile)
symbol_name_matcher_ftype * get_symbol_name_matcher(const language_defn *lang, const lookup_name_info &lookup_name)
static int psym_has_symbols(struct objfile *objfile)
static int psymbol_compare(const void *addr1, const void *addr2, int length)
struct cmd_list_element * maintenanceinfolist
static struct partial_symtab * find_pc_sect_psymtab_closer(struct objfile *objfile, CORE_ADDR pc, struct obj_section *section, struct partial_symtab *pst, struct bound_minimal_symbol msymbol)
enum domain_enum_tag domain_enum
int compare_filenames_for_search(const char *filename, const char *search_name)
#define PSYMBOL_DOMAIN(psymbol)
void * memset(T *s, int c, size_t n)=delete
void internal_error(const char *file, int line, const char *fmt,...)
scoped_restore_tmpl< int > increment_reading_symtab(void)
const struct language_defn * language_def(enum language lang)
union general_symbol_info::@171 value
bool() symbol_name_matcher_ftype(const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
int addrmap_foreach(struct addrmap *map, addrmap_foreach_fn fn, void *data)
enum language la_language
static void psym_relocate(struct objfile *objfile, const struct section_offsets *new_offsets, const struct section_offsets *delta)
#define BLOCKVECTOR_BLOCK(blocklist, n)
static void keep_going(struct execution_control_state *ecs)
const void * bcache_full(const void *addr, int length, struct bcache *bcache, int *added)
static compunit_symtab * psym_find_compunit_symtab_by_address(struct objfile *objfile, CORE_ADDR address)
struct symbol * block_iter_match_first(const struct block *block, const lookup_name_info &name, struct block_iterator *iterator)
struct general_symbol_info ginfo
static bool recursively_search_psymtabs(struct partial_symtab *ps, struct objfile *objfile, enum search_domain domain, const lookup_name_info &lookup_name, gdb::function_view< expand_symtabs_symbol_matcher_ftype > sym_matcher)
__extension__ enum domain_enum_tag domain
int() symbol_compare_ftype(const char *string1, const char *string2)
struct objfile_per_bfd_storage * per_bfd
static bool psymbol_name_matches(partial_symbol *psym, const lookup_name_info &lookup_name)
void printf_filtered(const char *format,...)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
#define host_address_to_string(ADDR)
#define SYMBOL_OBJ_SECTION(objfile, symbol)
void end_psymtab_common(struct objfile *objfile, struct partial_symtab *pst)
static void psym_fill_psymbol_map(struct objfile *objfile, struct partial_symtab *psymtab, std::set< CORE_ADDR > *seen_addrs, const std::vector< partial_symbol *> &symbols, int start, int length)
static unsigned long psymbol_hash(const void *addr, int length)
#define PSYMBOL_CLASS(psymbol)
#define ALL_PSYMTABS(objfile, p)
#define SYMBOL_VALUE_ADDRESS(symbol)
struct symbol * block_iter_match_next(const lookup_name_info &name, struct block_iterator *iterator)
std::vector< std::pair< CORE_ADDR, partial_symtab * > > psymbol_map
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
static void psym_forget_cached_source_info(struct objfile *objfile)
#define SYMBOL_DOMAIN(symbol)
objfile(bfd *, const char *, objfile_flags)
static void fixup_psymbol_section(struct partial_symbol *psym, struct objfile *objfile)
#define SYMBOL_MATCHES_SEARCH_NAME(symbol, name)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
static void psym_dump(struct objfile *objfile)
#define SYMBOL_DEMANGLED_NAME(symbol)
#define SYMBOL_SET_LANGUAGE(symbol, language, obstack)
static struct partial_symbol * lookup_partial_symbol(struct objfile *, struct partial_symtab *, const char *, int, domain_enum)
bool iterate_over_some_symtabs(const char *name, const char *real_path, struct compunit_symtab *first, struct compunit_symtab *after_last, gdb::function_view< bool(symtab *)> callback)
static struct partial_symbol * find_pc_sect_psymbol(struct objfile *, struct partial_symtab *, CORE_ADDR, struct obj_section *)
static void maintenance_check_psymtabs(const char *ignore, int from_tty)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
struct symtab * compunit_primary_filetab(const struct compunit_symtab *cust)
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
void puts_filtered(const char *string)
const struct sym_fns * sf
static void psym_map_symbol_filenames(struct objfile *objfile, symbol_filename_ftype *fun, void *data, int need_fullname)
static struct partial_symbol * add_psymbol_to_bcache(const char *name, int namelength, int copy_name, domain_enum domain, enum address_class theclass, CORE_ADDR coreaddr, enum language language, struct objfile *objfile, int *added)
#define ANOFFSET(secoff, whichone)
struct gdbarch * get_objfile_arch(const struct objfile *objfile)
static void psym_expand_symtabs_matching(struct objfile *objfile, gdb::function_view< expand_symtabs_file_matcher_ftype > file_matcher, const lookup_name_info &lookup_name_in, gdb::function_view< expand_symtabs_symbol_matcher_ftype > symbol_matcher, gdb::function_view< expand_symtabs_exp_notify_ftype > expansion_notify, enum search_domain domain)
struct bcache * bcache_xmalloc(unsigned long(*hash_function)(const void *, int length), int(*compare_function)(const void *, const void *, int length))
static void psym_expand_symtabs_for_function(struct objfile *objfile, const char *func_name)
#define SYMBOL_LINKAGE_NAME(symbol)
struct compunit_symtab * compunit_symtabs
static void dump_psymtab(struct objfile *objfile, struct partial_symtab *psymtab, struct ui_file *outfile)
struct partial_symtab * psymtab
static bool psym_map_symtabs_matching_filename(struct objfile *objfile, const char *name, const char *real_path, gdb::function_view< bool(symtab *)> callback)
void printf_unfiltered(const char *format,...)
int number_of_dependencies
virtual void puts(const char *str)
struct obj_section * find_pc_section(CORE_ADDR pc)
unsigned char psymtabs_addrmap_supported
const char * objfile_name(const struct objfile *objfile)
#define gdb_print_host_address(ADDR, STREAM)
static void sort_pst_symbols(struct objfile *objfile, struct partial_symtab *pst)
struct partial_symtab * user
struct cmd_list_element * maintenanceprintlist
void(* sym_read_psymbols)(struct objfile *)
std::vector< partial_symbol * > static_psymbols
static struct symtab * psym_find_last_source_symtab(struct objfile *ofp)
void wrap_here(const char *indent)
gdb::unique_xmalloc_ptr< char > rewrite_source_path(const char *path)
const std::string & language_lookup_name(language lang) const
struct partial_symtab * start_psymtab_common(struct objfile *objfile, const char *filename, CORE_ADDR textlow, std::vector< partial_symbol *> &global_psymbols, std::vector< partial_symbol *> &static_psymbols)
void printf(const char *,...) ATTRIBUTE_PRINTF(2
#define COMPUNIT_BLOCKVECTOR(cust)
#define SYMBOL_SET_NAMES(symbol, linkage_name, len, copy_name, objfile)
static void dump_psymtab_addrmap(struct objfile *objfile, struct partial_symtab *psymtab, struct ui_file *outfile)
static void psym_map_matching_symbols(struct objfile *objfile, const char *name, domain_enum domain, int global, int(*callback)(struct block *, struct symbol *, void *), void *data, symbol_name_match_type match, symbol_compare_ftype *ordered_compare)
struct symbol * block_find_symbol(const struct block *block, const char *name, const domain_enum domain, block_symbol_matcher_ftype *matcher, void *data)
void discard_psymtab(struct objfile *objfile, struct partial_symtab *pst)
int strcmp_iw_ordered(const char *string1, const char *string2)
lookup_name_info make_ignore_params() const
const struct language_defn * current_language
static void maintenance_info_psymtabs(const char *regexp, int from_tty)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
static int dump_psymtab_addrmap_1(void *datap, CORE_ADDR start_addr, void *obj)
#define ALL_PSPACES(pspace)
static void psym_expand_symtabs_with_fullname(struct objfile *objfile, const char *fullname)
struct partial_symtab * next
CORE_ADDR parse_and_eval_address(const char *exp)
static void print_partial_symbols(struct gdbarch *gdbarch, struct partial_symbol **p, int count, const char *what, struct ui_file *outfile)
std::vector< partial_symbol * > global_psymbols
bool open(const char *name, const char *mode)
struct partial_symtab ** dependencies
static struct partial_symbol * match_partial_symbol(struct objfile *, struct partial_symtab *, int, const char *, domain_enum, symbol_name_match_type, symbol_compare_ftype *)
struct minimal_symbol * minsym
__extension__ enum language language
const struct quick_symbol_functions psym_functions
#define OBJSTAT(objfile, expr)
static const char * psymtab_to_fullname(struct partial_symtab *ps)
#define SYMBOL_LANGUAGE(symbol)
void add_psymbol_to_list(const char *name, int namelength, int copy_name, domain_enum domain, enum address_class theclass, std::vector< partial_symbol *> *list, CORE_ADDR coreaddr, enum language language, struct objfile *objfile)
static void psym_print_stats(struct objfile *objfile)
struct partial_symtab * free_psymtabs
int symbol_matches_domain(enum language symbol_language, domain_enum symbol_domain, domain_enum domain)
static void append_psymbol_to_list(std::vector< partial_symbol *> *list, struct partial_symbol *psym, struct objfile *objfile)
void bcache_xfree(struct bcache *bcache)
void fixup_section(struct general_symbol_info *ginfo, CORE_ADDR addr, struct objfile *objfile)
enum overlay_debugging_state overlay_debugging
EXTERN_C char * re_comp(const char *)
void(* read_symtab)(struct partial_symtab *, struct objfile *)
unsigned int symtab_create_debug
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
static struct compunit_symtab * psym_lookup_symbol(struct objfile *objfile, int block_index, const char *name, const domain_enum domain)
struct addrmap * psymtabs_addrmap
#define SYMBOL_SEARCH_NAME(symbol)
static int map_block(const char *name, domain_enum domain, struct objfile *objfile, struct block *block, int(*callback)(struct block *, struct symbol *, void *), void *data, symbol_name_match_type match)
struct cmd_list_element * maintenancelist
void * addrmap_find(struct addrmap *map, CORE_ADDR addr)
void _initialize_psymtab(void)
int matching_obj_sections(struct obj_section *obj_first, struct obj_section *obj_second)
#define SYMBOL_SECTION(symbol)
static struct compunit_symtab * psymtab_to_symtab(struct objfile *objfile, struct partial_symtab *pst)
struct compunit_symtab * compunit_symtab
void gdb_flush(struct ui_file *file)
#define ALL_OBJFILES(obj)
static gdb::unique_xmalloc_ptr< char > psymtab_search_name(const char *name)
static void maintenance_print_psymbols(const char *args, int from_tty)
struct symbol * block_lookup_symbol(const struct block *block, const char *name, symbol_name_match_type match_type, const domain_enum domain)
void init_psymbol_list(struct objfile *objfile, int total_symbols)
#define ALL_PSPACE_OBJFILES(ss, obj)
struct psymbol_bcache * psymbol_cache
void error(const char *fmt,...)
struct objfile * require_partial_symbols(struct objfile *objfile, int verbose)
char * copy_name(struct stoken token)
struct partial_symtab * psymtabs
__extension__ enum domain_enum_tag domain
gdb::unique_xmalloc_ptr< char > cp_remove_params(const char *demangled_name)
void() symbol_filename_ftype(const char *filename, const char *fullname, void *data)