[Lldb-commits] [PATCH] D72909: Make SymbolFileDWARF::ParseLineTable use std::sort instead of insertion sort
Unnar Freyr Erlendsson via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Jan 17 02:43:22 PST 2020
unnar created this revision.
unnar added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere, mgrang.
Motivation: When setting breakpoints in certain projects line sequences are frequently being inserted out of order.
Rather than inserting sequences one at a time into a sorted line table, store all the line sequences as we're building them up and sort and flatten afterwards.
Repository:
rLLDB LLDB
https://reviews.llvm.org/D72909
Files:
lldb/include/lldb/Symbol/LineTable.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Symbol/LineTable.cpp
Index: lldb/source/Symbol/LineTable.cpp
===================================================================
--- lldb/source/Symbol/LineTable.cpp
+++ lldb/source/Symbol/LineTable.cpp
@@ -130,6 +130,17 @@
m_entries.insert(pos, seq->m_entries.begin(), seq->m_entries.end());
}
+void LineTable::ReplaceLineTableWithSequences(std::vector<LineSequence*> &sequences) {
+ m_entries.clear();
+ LineTable::Entry::LessThanBinaryPredicate less_than_bp(this);
+ std::sort(sequences.begin(), sequences.end(), less_than_bp);
+ for (auto *sequence : sequences) {
+ LineSequenceImpl *seq = reinterpret_cast<LineSequenceImpl *>(sequence);
+ m_entries.insert(m_entries.end(), seq->m_entries.begin(),
+ seq->m_entries.end());
+ }
+}
+
LineTable::Entry::LessThanBinaryPredicate::LessThanBinaryPredicate(
LineTable *line_table)
: m_line_table(line_table) {}
@@ -154,6 +165,13 @@
#undef LT_COMPARE
}
+bool LineTable::Entry::LessThanBinaryPredicate::
+operator()(LineSequence *sequence_a, LineSequence *sequence_b) const {
+ LineSequenceImpl *seq_a = reinterpret_cast<LineSequenceImpl *>(sequence_a);
+ LineSequenceImpl *seq_b = reinterpret_cast<LineSequenceImpl *>(sequence_b);
+ return (*this)(seq_a->m_entries.front(), seq_b->m_entries.front());
+}
+
uint32_t LineTable::GetSize() const { return m_entries.size(); }
bool LineTable::GetLineEntryAtIndex(uint32_t idx, LineEntry &line_entry) {
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1018,17 +1018,20 @@
std::unique_ptr<LineTable> line_table_up =
std::make_unique<LineTable>(&comp_unit);
LineSequence *sequence = line_table_up->CreateLineSequenceContainer();
+ std::vector<LineSequence*> sequences;
for (auto &row : line_table->Rows) {
line_table_up->AppendLineEntryToSequence(
sequence, row.Address.Address, row.Line, row.Column, row.File,
row.IsStmt, row.BasicBlock, row.PrologueEnd, row.EpilogueBegin,
row.EndSequence);
if (row.EndSequence) {
- line_table_up->InsertSequence(sequence);
+ sequences.push_back(sequence);
sequence = line_table_up->CreateLineSequenceContainer();
}
}
+ line_table_up->ReplaceLineTableWithSequences(sequences);
+
if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile()) {
// We have an object file that has a line table with addresses that are not
// linked. We need to link the line table and convert the addresses that
Index: lldb/include/lldb/Symbol/LineTable.h
===================================================================
--- lldb/include/lldb/Symbol/LineTable.h
+++ lldb/include/lldb/Symbol/LineTable.h
@@ -78,6 +78,12 @@
// Insert a sequence of entries into this line table.
void InsertSequence(LineSequence *sequence);
+ /// Replace the current line table with entries found in \a sequences.
+ ///
+ /// \param[in] sequences
+ /// Unsorted list of line sequences.
+ void ReplaceLineTableWithSequences(std::vector<LineSequence*> &sequences);
+
/// Dump all line entries in this line table to the stream \a s.
///
/// \param[in] s
@@ -259,6 +265,7 @@
public:
LessThanBinaryPredicate(LineTable *line_table);
bool operator()(const LineTable::Entry &, const LineTable::Entry &) const;
+ bool operator()(LineSequence*, LineSequence*) const;
protected:
LineTable *m_line_table;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72909.238719.patch
Type: text/x-patch
Size: 3577 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200117/4e3033c7/attachment-0001.bin>
More information about the lldb-commits
mailing list