Skip to content

Commit 6c12ce6

Browse files
author
git apple-llvm automerger
committed
Merge commit 'c4e83390dbea' from swift/release/5.3 into swift/master
2 parents 98f0954 + c4e8339 commit 6c12ce6

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

lldb/include/lldb/Symbol/LineTable.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ class LineTable {
4242
/// The compile unit to which this line table belongs.
4343
LineTable(CompileUnit *comp_unit);
4444

45+
/// Construct with entries found in \a sequences.
46+
///
47+
/// \param[in] sequences
48+
/// Unsorted list of line sequences.
49+
LineTable(CompileUnit *comp_unit,
50+
std::vector<std::unique_ptr<LineSequence>> &&sequences);
51+
4552
/// Destructor.
4653
~LineTable();
4754

@@ -64,11 +71,11 @@ class LineTable {
6471
bool is_epilogue_begin, bool is_terminal_entry);
6572

6673
// Used to instantiate the LineSequence helper class
67-
LineSequence *CreateLineSequenceContainer();
74+
static std::unique_ptr<LineSequence> CreateLineSequenceContainer();
6875

6976
// Append an entry to a caller-provided collection that will later be
7077
// inserted in this line table.
71-
void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr,
78+
static void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr,
7279
uint32_t line, uint16_t column,
7380
uint16_t file_idx, bool is_start_of_statement,
7481
bool is_start_of_basic_block,
@@ -259,6 +266,8 @@ class LineTable {
259266
public:
260267
LessThanBinaryPredicate(LineTable *line_table);
261268
bool operator()(const LineTable::Entry &, const LineTable::Entry &) const;
269+
bool operator()(const std::unique_ptr<LineSequence> &,
270+
const std::unique_ptr<LineSequence> &) const;
262271

263272
protected:
264273
LineTable *m_line_table;

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,20 +1045,23 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) {
10451045
// FIXME: Rather than parsing the whole line table and then copying it over
10461046
// into LLDB, we should explore using a callback to populate the line table
10471047
// while we parse to reduce memory usage.
1048-
std::unique_ptr<LineTable> line_table_up =
1049-
std::make_unique<LineTable>(&comp_unit);
1050-
LineSequence *sequence = line_table_up->CreateLineSequenceContainer();
1048+
std::unique_ptr<LineSequence> sequence =
1049+
LineTable::CreateLineSequenceContainer();
1050+
std::vector<std::unique_ptr<LineSequence>> sequences;
10511051
for (auto &row : line_table->Rows) {
1052-
line_table_up->AppendLineEntryToSequence(
1053-
sequence, row.Address.Address, row.Line, row.Column, row.File,
1052+
LineTable::AppendLineEntryToSequence(
1053+
sequence.get(), row.Address.Address, row.Line, row.Column, row.File,
10541054
row.IsStmt, row.BasicBlock, row.PrologueEnd, row.EpilogueBegin,
10551055
row.EndSequence);
10561056
if (row.EndSequence) {
1057-
line_table_up->InsertSequence(sequence);
1058-
sequence = line_table_up->CreateLineSequenceContainer();
1057+
sequences.push_back(std::move(sequence));
1058+
sequence = LineTable::CreateLineSequenceContainer();
10591059
}
10601060
}
10611061

1062+
std::unique_ptr<LineTable> line_table_up =
1063+
std::make_unique<LineTable>(&comp_unit, std::move(sequences));
1064+
10621065
if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile()) {
10631066
// We have an object file that has a line table with addresses that are not
10641067
// linked. We need to link the line table and convert the addresses that

lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit &comp_unit,
18181818
prev_source_idx, false, false, false, false, true);
18191819

18201820
line_table->InsertSequence(sequence.release());
1821-
sequence.reset(line_table->CreateLineSequenceContainer());
1821+
sequence = line_table->CreateLineSequenceContainer();
18221822
}
18231823

18241824
if (ShouldAddLine(match_line, lno, length)) {
@@ -1855,7 +1855,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit &comp_unit,
18551855
prev_source_idx, false, false, false, false, true);
18561856
}
18571857

1858-
line_table->InsertSequence(sequence.release());
1858+
line_table->InsertSequence(sequence.get());
18591859
}
18601860

18611861
if (line_table->GetSize()) {

lldb/source/Symbol/LineTable.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ using namespace lldb_private;
2121
LineTable::LineTable(CompileUnit *comp_unit)
2222
: m_comp_unit(comp_unit), m_entries() {}
2323

24+
LineTable::LineTable(CompileUnit *comp_unit,
25+
std::vector<std::unique_ptr<LineSequence>> &&sequences)
26+
: m_comp_unit(comp_unit), m_entries() {
27+
LineTable::Entry::LessThanBinaryPredicate less_than_bp(this);
28+
llvm::stable_sort(sequences, less_than_bp);
29+
for (const auto &sequence : sequences) {
30+
LineSequenceImpl *seq = static_cast<LineSequenceImpl *>(sequence.get());
31+
m_entries.insert(m_entries.end(), seq->m_entries.begin(),
32+
seq->m_entries.end());
33+
}
34+
}
35+
2436
// Destructor
2537
LineTable::~LineTable() {}
2638

@@ -50,8 +62,8 @@ LineSequence::LineSequence() {}
5062

5163
void LineTable::LineSequenceImpl::Clear() { m_entries.clear(); }
5264

53-
LineSequence *LineTable::CreateLineSequenceContainer() {
54-
return new LineTable::LineSequenceImpl();
65+
std::unique_ptr<LineSequence> LineTable::CreateLineSequenceContainer() {
66+
return std::make_unique<LineTable::LineSequenceImpl>();
5567
}
5668

5769
void LineTable::AppendLineEntryToSequence(
@@ -154,6 +166,14 @@ operator()(const LineTable::Entry &a, const LineTable::Entry &b) const {
154166
#undef LT_COMPARE
155167
}
156168

169+
bool LineTable::Entry::LessThanBinaryPredicate::
170+
operator()(const std::unique_ptr<LineSequence> &sequence_a,
171+
const std::unique_ptr<LineSequence> &sequence_b) const {
172+
auto *seq_a = static_cast<const LineSequenceImpl *>(sequence_a.get());
173+
auto *seq_b = static_cast<const LineSequenceImpl *>(sequence_b.get());
174+
return (*this)(seq_a->m_entries.front(), seq_b->m_entries.front());
175+
}
176+
157177
uint32_t LineTable::GetSize() const { return m_entries.size(); }
158178

159179
bool LineTable::GetLineEntryAtIndex(uint32_t idx, LineEntry &line_entry) {

0 commit comments

Comments
 (0)