Skip to content

Commit

Permalink
[lldb] Store SupportFile in FileEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
JDevlieghere committed Mar 21, 2024
1 parent b458024 commit 86819e8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
8 changes: 3 additions & 5 deletions lldb/include/lldb/Symbol/LineEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions lldb/source/API/SBLineEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SupportFile>(filespec.ref());
else
ref().SetFile(FileSpec());
ref().file_sp = std::make_shared<SupportFile>();
}
void SBLineEntry::SetLine(uint32_t line) {
LLDB_INSTRUMENT_VA(this, line);
Expand Down
13 changes: 7 additions & 6 deletions lldb/source/Symbol/LineEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SupportFile>();
original_file_sp = std::make_shared<SupportFile>();
line = LLDB_INVALID_LINE_NUMBER;
column = 0;
Expand All @@ -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());
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -103,7 +104,7 @@ bool LineEntry::GetDescription(Stream *s, lldb::DescriptionLevel level,
Address::DumpStyleFileAddress);
}

*s << ": " << file;
*s << ": " << GetFile();

if (line) {
s->Printf(":%u", line);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion lldb/source/Symbol/LineTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SupportFile>(
m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx));
line_entry.original_file_sp =
m_comp_unit->GetSupportFiles().GetSupportFileAtIndex(entry.file_idx);
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Symbol/SymbolContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SupportFile>(
curr_inlined_block_inlined_info->GetCallSite().GetFile());
next_frame_sc.line_entry.original_file_sp =
std::make_shared<SupportFile>(
Expand Down

0 comments on commit 86819e8

Please sign in to comment.