diff options
Diffstat (limited to 'gdb/dwarf2/read-gdb-index.c')
-rw-r--r-- | gdb/dwarf2/read-gdb-index.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index dc45219..14be695 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -131,6 +131,9 @@ struct mapped_gdb_index final : public mapped_index_base } }; +struct mapped_debug_line; +typedef std::unique_ptr<mapped_debug_line> mapped_debug_line_up; + struct dwarf2_gdb_index : public dwarf2_base_index_functions { /* This dumps minimal information about the index. @@ -160,6 +163,15 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions block_search_flags search_flags, domain_search_flags domain); + /* If OBJFILE's debuginfo download has been deferred, use a mapped_debug_line + to generate filenames. + + Otherwise call dwarf2_base_index_functions::map_symbol_filenames. */ + + void map_symbol_filenames (struct objfile *objfile, + gdb::function_view<symbol_filename_ftype> fun, + bool need_fullname) override; + /* Calls dwarf2_base_index_functions::expand_all_symtabs and downloads debuginfo if necessary. */ void expand_all_symtabs (struct objfile *objfile) override; @@ -167,6 +179,15 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions /* Calls dwarf2_base_index_functions::find_last_source_symtab and downloads debuginfo if necessary. */ struct symtab *find_last_source_symtab (struct objfile *objfile) override; + + /* Filename information related to this .gdb_index. */ + mapped_debug_line_up mdl; + + /* Return true if any of the filenames in this .gdb_index's .debug_line + mapping match FILE_MATCHER. Initializes the mapping if necessary. */ + bool filename_in_debug_line + (objfile *objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher); }; void @@ -202,6 +223,30 @@ dwarf2_gdb_index::find_last_source_symtab (struct objfile *objfile) } } +void +dwarf2_gdb_index::map_symbol_filenames + (struct objfile *objfile, + gdb::function_view<symbol_filename_ftype> fun, + bool need_fullname) +{ + try + { + dwarf2_base_index_functions::map_symbol_filenames (objfile, fun, + need_fullname); + } + catch (const gdb_exception &e) + { + if ((objfile->flags & OBJF_DOWNLOAD_DEFERRED) == 0) + exception_print (gdb_stderr, e); + else + { + if (mdl == nullptr) + mdl.reset (new mapped_debug_line (objfile)); + mdl->map_filenames (fun, need_fullname); + } + } +} + /* This dumps minimal information about the index. It is called via "mt print objfiles". One use is to verify .gdb_index has been loaded by the @@ -366,6 +411,17 @@ dwarf2_gdb_index::do_expand_symtabs_matching } bool +dwarf2_gdb_index::filename_in_debug_line + (objfile *objfile, + gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher) +{ + if (mdl == nullptr) + mdl.reset (new mapped_debug_line (objfile)); + + return mdl->contains_matching_filename (file_matcher); +} + +bool dwarf2_gdb_index::expand_symtabs_matching (struct objfile *objfile, gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, @@ -392,6 +448,10 @@ dwarf2_gdb_index::expand_symtabs_matching return false; } + if (file_matcher != nullptr + && !filename_in_debug_line (objfile, file_matcher)) + return true; + read_full_dwarf_from_debuginfod (objfile, this); return true; } |