From 86819e84e75303a21c1692d3db66a83baebec316 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 19 Mar 2024 21:22:19 -0700 Subject: [PATCH] [lldb] Store SupportFile in FileEntry --- lldb/include/lldb/Symbol/LineEntry.h | 8 +++----- lldb/source/API/SBLineEntry.cpp | 4 ++-- lldb/source/Symbol/LineEntry.cpp | 13 +++++++------ lldb/source/Symbol/LineTable.cpp | 2 +- lldb/source/Symbol/SymbolContext.cpp | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lldb/include/lldb/Symbol/LineEntry.h b/lldb/include/lldb/Symbol/LineEntry.h index a8c8fa716df2d5..8da59cf0bd24aa 100644 --- a/lldb/include/lldb/Symbol/LineEntry.h +++ b/lldb/include/lldb/Symbol/LineEntry.h @@ -130,17 +130,15 @@ struct LineEntry { /// Shared pointer to the target this LineEntry belongs to. void ApplyFileMappings(lldb::TargetSP target_sp); - const FileSpec &GetFile() const { return file; } - void SetFile(const FileSpec &file_spec) { file = file_spec; } + /// Helper to access the file. + const FileSpec &GetFile() const { return file_sp->GetSpecOnly(); } /// The section offset address range for this line entry. AddressRange range; -private: /// The source file, possibly mapped by the target.source-map setting. - FileSpec file; + lldb::SupportFileSP file_sp; -public: /// The original source file, from debug info. lldb::SupportFileSP original_file_sp; diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp index 0941ef20d0ff3b..99a7b8fe644cb5 100644 --- a/lldb/source/API/SBLineEntry.cpp +++ b/lldb/source/API/SBLineEntry.cpp @@ -109,9 +109,9 @@ void SBLineEntry::SetFileSpec(lldb::SBFileSpec filespec) { LLDB_INSTRUMENT_VA(this, filespec); if (filespec.IsValid()) - ref().SetFile(filespec.ref()); + ref().file_sp = std::make_shared(filespec.ref()); else - ref().SetFile(FileSpec()); + ref().file_sp = std::make_shared(); } void SBLineEntry::SetLine(uint32_t line) { LLDB_INSTRUMENT_VA(this, line); diff --git a/lldb/source/Symbol/LineEntry.cpp b/lldb/source/Symbol/LineEntry.cpp index 389f8dcb65d8d8..9e0c06b6ff73ec 100644 --- a/lldb/source/Symbol/LineEntry.cpp +++ b/lldb/source/Symbol/LineEntry.cpp @@ -14,12 +14,12 @@ using namespace lldb_private; LineEntry::LineEntry() - : range(), file(), is_start_of_statement(0), is_start_of_basic_block(0), + : range(), is_start_of_statement(0), is_start_of_basic_block(0), is_prologue_end(0), is_epilogue_begin(0), is_terminal_entry(0) {} void LineEntry::Clear() { range.Clear(); - file.Clear(); + file_sp = std::make_shared(); original_file_sp = std::make_shared(); line = LLDB_INVALID_LINE_NUMBER; column = 0; @@ -35,6 +35,7 @@ bool LineEntry::IsValid() const { } bool LineEntry::DumpStopContext(Stream *s, bool show_fullpaths) const { + const FileSpec &file = file_sp->GetSpecOnly(); if (file) { if (show_fullpaths) file.Dump(s->AsRawOstream()); @@ -67,7 +68,7 @@ bool LineEntry::Dump(Stream *s, Target *target, bool show_file, return false; } if (show_file) - *s << ", file = " << file; + *s << ", file = " << GetFile(); if (line) s->Printf(", line = %u", line); if (column) @@ -103,7 +104,7 @@ bool LineEntry::GetDescription(Stream *s, lldb::DescriptionLevel level, Address::DumpStyleFileAddress); } - *s << ": " << file; + *s << ": " << GetFile(); if (line) { s->Printf(":%u", line); @@ -173,7 +174,7 @@ int LineEntry::Compare(const LineEntry &a, const LineEntry &b) { if (a.column > b.column) return +1; - return FileSpec::Compare(a.file, b.file, true); + return FileSpec::Compare(a.GetFile(), b.GetFile(), true); } AddressRange LineEntry::GetSameLineContiguousAddressRange( @@ -242,6 +243,6 @@ void LineEntry::ApplyFileMappings(lldb::TargetSP target_sp) { // Apply any file remappings to our file. if (auto new_file_spec = target_sp->GetSourcePathMap().FindFile( original_file_sp->GetSpecOnly())) - file = *new_file_spec; + file_sp->Update(*new_file_spec); } } diff --git a/lldb/source/Symbol/LineTable.cpp b/lldb/source/Symbol/LineTable.cpp index 890e822ba257a3..06cf4f698316c6 100644 --- a/lldb/source/Symbol/LineTable.cpp +++ b/lldb/source/Symbol/LineTable.cpp @@ -288,7 +288,7 @@ bool LineTable::ConvertEntryAtIndexToLineEntry(uint32_t idx, else line_entry.range.SetByteSize(0); - line_entry.SetFile( + line_entry.file_sp = std::make_shared( m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx)); line_entry.original_file_sp = m_comp_unit->GetSupportFiles().GetSupportFileAtIndex(entry.file_idx); diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index c90601630a26a2..f368896fbad490 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -472,7 +472,7 @@ bool SymbolContext::GetParentOfInlinedScope(const Address &curr_frame_pc, curr_inlined_block->GetInlinedFunctionInfo(); next_frame_pc = range.GetBaseAddress(); next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc; - next_frame_sc.line_entry.SetFile( + next_frame_sc.line_entry.file_sp = std::make_shared( curr_inlined_block_inlined_info->GetCallSite().GetFile()); next_frame_sc.line_entry.original_file_sp = std::make_shared(