diff options
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 113 |
1 files changed, 65 insertions, 48 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index 41d71be..7b11d43 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -700,15 +700,10 @@ iterate_over_some_symtabs (const char *name, return false; } -/* Check for a symtab of a specific name; first in symtabs, then in - psymtabs. *If* there is no '/' in the name, a match after a '/' - in the symtab filename will also work. - - Calls CALLBACK with each symtab that is found. If CALLBACK returns - true, the search stops. */ +/* See symtab.h. */ void -iterate_over_symtabs (const char *name, +iterate_over_symtabs (program_space *pspace, const char *name, gdb::function_view<bool (symtab *)> callback) { gdb::unique_xmalloc_ptr<char> real_path; @@ -721,34 +716,28 @@ iterate_over_symtabs (const char *name, gdb_assert (IS_ABSOLUTE_PATH (real_path.get ())); } - for (objfile *objfile : current_program_space->objfiles ()) - { - if (iterate_over_some_symtabs (name, real_path.get (), - objfile->compunit_symtabs, NULL, - callback)) + for (objfile *objfile : pspace->objfiles ()) + if (iterate_over_some_symtabs (name, real_path.get (), + objfile->compunit_symtabs, nullptr, + callback)) return; - } - /* Same search rules as above apply here, but now we look thru the + /* Same search rules as above apply here, but now we look through the psymtabs. */ - - for (objfile *objfile : current_program_space->objfiles ()) - { - if (objfile->map_symtabs_matching_filename (name, real_path.get (), - callback)) - return; - } + for (objfile *objfile : pspace->objfiles ()) + if (objfile->map_symtabs_matching_filename (name, real_path.get (), + callback)) + return; } -/* A wrapper for iterate_over_symtabs that returns the first matching - symtab, or NULL. */ +/* See symtab.h. */ -struct symtab * -lookup_symtab (const char *name) +symtab * +lookup_symtab (program_space *pspace, const char *name) { struct symtab *result = NULL; - iterate_over_symtabs (name, [&] (symtab *symtab) + iterate_over_symtabs (pspace, name, [&] (symtab *symtab) { result = symtab; return true; @@ -1563,6 +1552,7 @@ symbol_cache_mark_not_found (struct block_symbol_cache *bsc, static void symbol_cache_flush (struct program_space *pspace) { + ada_clear_symbol_cache (pspace); struct symbol_cache *cache = symbol_cache_key.get (pspace); int pass; @@ -1755,7 +1745,7 @@ maintenance_print_symbol_cache_statistics (const char *args, int from_tty) static void symtab_new_objfile_observer (struct objfile *objfile) { - symbol_cache_flush (objfile->pspace); + symbol_cache_flush (objfile->pspace ()); } /* This module's 'all_objfiles_removed' observer. */ @@ -1766,7 +1756,7 @@ symtab_all_objfiles_removed (program_space *pspace) symbol_cache_flush (pspace); /* Forget everything we know about the main function. */ - set_main_name (pspace, nullptr, language_unknown); + main_progspace_key.clear (pspace); } /* This module's 'free_objfile' observer. */ @@ -1774,7 +1764,7 @@ symtab_all_objfiles_removed (program_space *pspace) static void symtab_free_objfile_observer (struct objfile *objfile) { - symbol_cache_flush (objfile->pspace); + symbol_cache_flush (objfile->pspace ()); } /* See symtab.h. */ @@ -1928,6 +1918,28 @@ lookup_name_info::match_any () return lookup_name; } +/* See symtab.h. */ + +unsigned int +lookup_name_info::search_name_hash (language lang) const +{ + /* This works around an obscure problem. If currently in Ada mode, + and the name is wrapped in '<...>' (indicating verbatim mode), + force the use of the Ada language here so that the '<' and '>' + will be removed. */ + if (current_language->la_language == language_ada && ada ().verbatim_p ()) + lang = language_ada; + + /* Only compute each language's hash once. */ + if (!m_demangled_hashes_p[lang]) + { + m_demangled_hashes[lang] + = ::search_name_hash (lang, language_lookup_name (lang)); + m_demangled_hashes_p[lang] = true; + } + return m_demangled_hashes[lang]; +} + /* Compute the demangled form of NAME as used by the various symbol lookup functions. The result can either be the input NAME directly, or a pointer to a buffer owned by the STORAGE object. @@ -2439,7 +2451,7 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile, /* A helper function that throws an exception when a symbol was found in a psymtab but not in a symtab. */ -static void ATTRIBUTE_NORETURN +[[noreturn]] static void error_in_psymtab_expansion (enum block_enum block_index, const char *name, struct compunit_symtab *cust) { @@ -2892,14 +2904,14 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) { struct compunit_symtab *best_cust = NULL; CORE_ADDR best_cust_range = 0; - struct bound_minimal_symbol msymbol; /* If we know that this is not a text address, return failure. This is necessary because we loop based on the block's high and low code addresses, which do not include the data ranges, and because we call find_pc_sect_psymtab which has a similar restriction based on the partial_symtab's texthigh and textlow. */ - msymbol = lookup_minimal_symbol_by_pc_section (pc, section); + bound_minimal_symbol msymbol + = lookup_minimal_symbol_by_pc_section (pc, section); if (msymbol.minsym && msymbol.minsym->data_p ()) return NULL; @@ -2980,7 +2992,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) section. */ } - /* Cust is best found sofar, save it. */ + /* Cust is best found so far, save it. */ best_cust = cust; best_cust_range = range; } @@ -3091,7 +3103,6 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) int len; const linetable_entry *item; const struct blockvector *bv; - struct bound_minimal_symbol msymbol; /* Info on best line seen so far, and where it starts, and its file. */ @@ -3170,13 +3181,14 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) * check for the address being the same, to avoid an * infinite recursion. */ - msymbol = lookup_minimal_symbol_by_pc (pc); + bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (pc); if (msymbol.minsym != NULL) if (msymbol.minsym->type () == mst_solib_trampoline) { - struct bound_minimal_symbol mfunsym - = lookup_minimal_symbol_text (msymbol.minsym->linkage_name (), - NULL); + bound_minimal_symbol mfunsym + = lookup_minimal_symbol_text (current_program_space, + msymbol.minsym->linkage_name (), + nullptr); if (mfunsym.minsym == NULL) /* I eliminated this warning since it is coming out @@ -3919,7 +3931,7 @@ skip_prologue_sal (struct symtab_and_line *sal) } else { - struct bound_minimal_symbol msymbol + bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc_section (sal->pc, sal->section); if (msymbol.minsym == NULL) @@ -4764,8 +4776,9 @@ info_sources_worker (struct ui_out *uiout, static void info_sources_command (const char *args, int from_tty) { - if (!have_full_symbols () && !have_partial_symbols ()) - error (_("No symbol table is loaded. Use the \"file\" command.")); + if (!have_full_symbols (current_program_space) + && !have_partial_symbols (current_program_space)) + error (_ ("No symbol table is loaded. Use the \"file\" command.")); filename_partial_match_opts match_opts; auto group = make_info_sources_options_def_group (&match_opts); @@ -5289,7 +5302,7 @@ print_symbol_info (struct symbol *sym, int block, const char *last) for non-debugging symbols to gdb_stdout. */ static void -print_msymbol_info (struct bound_minimal_symbol msymbol) +print_msymbol_info (bound_minimal_symbol msymbol) { struct gdbarch *gdbarch = msymbol.objfile->arch (); const char *tmp; @@ -6293,7 +6306,7 @@ collect_file_symbol_completion_matches (completion_tracker &tracker, /* Go through symtabs for SRCFILE and check the externs and statics for symbols which match. */ - iterate_over_symtabs (srcfile, [&] (symtab *s) + iterate_over_symtabs (current_program_space, srcfile, [&] (symtab *s) { add_symtab_completions (s->compunit (), tracker, mode, lookup_name, @@ -6381,7 +6394,8 @@ make_source_files_completion_list (const char *text, const char *word) const char *base_name; struct add_partial_filename_data datum; - if (!have_full_symbols () && !have_partial_symbols ()) + if (!have_full_symbols (current_program_space) + && !have_partial_symbols (current_program_space)) return list; filename_seen_cache filenames_seen; @@ -6775,10 +6789,12 @@ symbol::get_maybe_copied_address () const gdb_assert (this->aclass () == LOC_STATIC); const char *linkage_name = this->linkage_name (); - bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (linkage_name, - false); + bound_minimal_symbol minsym + = lookup_minimal_symbol_linkage (this->objfile ()->pspace (), linkage_name, + false); if (minsym.minsym != nullptr) return minsym.value_address (); + return this->m_value.address; } @@ -6791,10 +6807,11 @@ minimal_symbol::get_maybe_copied_address (objfile *objf) const gdb_assert ((objf->flags & OBJF_MAINLINE) == 0); const char *linkage_name = this->linkage_name (); - bound_minimal_symbol found = lookup_minimal_symbol_linkage (linkage_name, - true); + bound_minimal_symbol found + = lookup_minimal_symbol_linkage (objf->pspace (), linkage_name, true); if (found.minsym != nullptr) return found.value_address (); + return (this->m_value.address + objf->section_offsets[this->section_index ()]); } |