Skip to content

Commit 86819e8

Browse files
committed
[lldb] Store SupportFile in FileEntry
1 parent b458024 commit 86819e8

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

lldb/include/lldb/Symbol/LineEntry.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,15 @@ struct LineEntry {
130130
/// Shared pointer to the target this LineEntry belongs to.
131131
void ApplyFileMappings(lldb::TargetSP target_sp);
132132

133-
const FileSpec &GetFile() const { return file; }
134-
void SetFile(const FileSpec &file_spec) { file = file_spec; }
133+
/// Helper to access the file.
134+
const FileSpec &GetFile() const { return file_sp->GetSpecOnly(); }
135135

136136
/// The section offset address range for this line entry.
137137
AddressRange range;
138138

139-
private:
140139
/// The source file, possibly mapped by the target.source-map setting.
141-
FileSpec file;
140+
lldb::SupportFileSP file_sp;
142141

143-
public:
144142
/// The original source file, from debug info.
145143
lldb::SupportFileSP original_file_sp;
146144

lldb/source/API/SBLineEntry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ void SBLineEntry::SetFileSpec(lldb::SBFileSpec filespec) {
109109
LLDB_INSTRUMENT_VA(this, filespec);
110110

111111
if (filespec.IsValid())
112-
ref().SetFile(filespec.ref());
112+
ref().file_sp = std::make_shared<SupportFile>(filespec.ref());
113113
else
114-
ref().SetFile(FileSpec());
114+
ref().file_sp = std::make_shared<SupportFile>();
115115
}
116116
void SBLineEntry::SetLine(uint32_t line) {
117117
LLDB_INSTRUMENT_VA(this, line);

lldb/source/Symbol/LineEntry.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
using namespace lldb_private;
1515

1616
LineEntry::LineEntry()
17-
: range(), file(), is_start_of_statement(0), is_start_of_basic_block(0),
17+
: range(), is_start_of_statement(0), is_start_of_basic_block(0),
1818
is_prologue_end(0), is_epilogue_begin(0), is_terminal_entry(0) {}
1919

2020
void LineEntry::Clear() {
2121
range.Clear();
22-
file.Clear();
22+
file_sp = std::make_shared<SupportFile>();
2323
original_file_sp = std::make_shared<SupportFile>();
2424
line = LLDB_INVALID_LINE_NUMBER;
2525
column = 0;
@@ -35,6 +35,7 @@ bool LineEntry::IsValid() const {
3535
}
3636

3737
bool LineEntry::DumpStopContext(Stream *s, bool show_fullpaths) const {
38+
const FileSpec &file = file_sp->GetSpecOnly();
3839
if (file) {
3940
if (show_fullpaths)
4041
file.Dump(s->AsRawOstream());
@@ -67,7 +68,7 @@ bool LineEntry::Dump(Stream *s, Target *target, bool show_file,
6768
return false;
6869
}
6970
if (show_file)
70-
*s << ", file = " << file;
71+
*s << ", file = " << GetFile();
7172
if (line)
7273
s->Printf(", line = %u", line);
7374
if (column)
@@ -103,7 +104,7 @@ bool LineEntry::GetDescription(Stream *s, lldb::DescriptionLevel level,
103104
Address::DumpStyleFileAddress);
104105
}
105106

106-
*s << ": " << file;
107+
*s << ": " << GetFile();
107108

108109
if (line) {
109110
s->Printf(":%u", line);
@@ -173,7 +174,7 @@ int LineEntry::Compare(const LineEntry &a, const LineEntry &b) {
173174
if (a.column > b.column)
174175
return +1;
175176

176-
return FileSpec::Compare(a.file, b.file, true);
177+
return FileSpec::Compare(a.GetFile(), b.GetFile(), true);
177178
}
178179

179180
AddressRange LineEntry::GetSameLineContiguousAddressRange(
@@ -242,6 +243,6 @@ void LineEntry::ApplyFileMappings(lldb::TargetSP target_sp) {
242243
// Apply any file remappings to our file.
243244
if (auto new_file_spec = target_sp->GetSourcePathMap().FindFile(
244245
original_file_sp->GetSpecOnly()))
245-
file = *new_file_spec;
246+
file_sp->Update(*new_file_spec);
246247
}
247248
}

lldb/source/Symbol/LineTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ bool LineTable::ConvertEntryAtIndexToLineEntry(uint32_t idx,
288288
else
289289
line_entry.range.SetByteSize(0);
290290

291-
line_entry.SetFile(
291+
line_entry.file_sp = std::make_shared<SupportFile>(
292292
m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx));
293293
line_entry.original_file_sp =
294294
m_comp_unit->GetSupportFiles().GetSupportFileAtIndex(entry.file_idx);

lldb/source/Symbol/SymbolContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ bool SymbolContext::GetParentOfInlinedScope(const Address &curr_frame_pc,
472472
curr_inlined_block->GetInlinedFunctionInfo();
473473
next_frame_pc = range.GetBaseAddress();
474474
next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc;
475-
next_frame_sc.line_entry.SetFile(
475+
next_frame_sc.line_entry.file_sp = std::make_shared<SupportFile>(
476476
curr_inlined_block_inlined_info->GetCallSite().GetFile());
477477
next_frame_sc.line_entry.original_file_sp =
478478
std::make_shared<SupportFile>(

0 commit comments

Comments
 (0)