unnar updated this revision to Diff 238771. unnar added a comment. Switched back to std::vector and uploaded the full diff.
I don't have commit access so it would be appreciated if you could land this for me, thanks! CHANGES SINCE LAST ACTION https://reviews.llvm.org/D72909/new/ 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 @@ -21,6 +21,17 @@ LineTable::LineTable(CompileUnit *comp_unit) : m_comp_unit(comp_unit), m_entries() {} +LineTable::LineTable(CompileUnit *comp_unit, std::vector<LineSequence *> &sequences) + : m_comp_unit(comp_unit), m_entries() { + 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()); + } +} + // Destructor LineTable::~LineTable() {} @@ -154,6 +165,13 @@ #undef LT_COMPARE } +bool LineTable::Entry::LessThanBinaryPredicate:: +operator()(const LineSequence *sequence_a, const LineSequence *sequence_b) const { + auto *seq_a = static_cast<const LineSequenceImpl *>(sequence_a); + auto *seq_b = static_cast<const 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 @@ -1015,20 +1015,22 @@ // FIXME: Rather than parsing the whole line table and then copying it over // into LLDB, we should explore using a callback to populate the line table // while we parse to reduce memory usage. - std::unique_ptr<LineTable> line_table_up = - std::make_unique<LineTable>(&comp_unit); - LineSequence *sequence = line_table_up->CreateLineSequenceContainer(); + LineSequence *sequence = LineTable::CreateLineSequenceContainer(); + std::vector<LineSequence *> sequences; for (auto &row : line_table->Rows) { - line_table_up->AppendLineEntryToSequence( + LineTable::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); - sequence = line_table_up->CreateLineSequenceContainer(); + sequences.push_back(sequence); + sequence = LineTable::CreateLineSequenceContainer(); } } + std::unique_ptr<LineTable> line_table_up = + std::make_unique<LineTable>(&comp_unit, 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 @@ -42,6 +42,12 @@ /// The compile unit to which this line table belongs. LineTable(CompileUnit *comp_unit); + /// Construct with entries found in \a sequences. + /// + /// \param[in] sequences + /// Unsorted list of line sequences. + LineTable(CompileUnit *comp_unit, std::vector<LineSequence *> &sequences); + /// Destructor. ~LineTable(); @@ -64,11 +70,11 @@ bool is_epilogue_begin, bool is_terminal_entry); // Used to instantiate the LineSequence helper class - LineSequence *CreateLineSequenceContainer(); + static LineSequence *CreateLineSequenceContainer(); // Append an entry to a caller-provided collection that will later be // inserted in this line table. - void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr, + static void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr, uint32_t line, uint16_t column, uint16_t file_idx, bool is_start_of_statement, bool is_start_of_basic_block, @@ -259,6 +265,7 @@ public: LessThanBinaryPredicate(LineTable *line_table); bool operator()(const LineTable::Entry &, const LineTable::Entry &) const; + bool operator()(const LineSequence*, const LineSequence*) const; protected: LineTable *m_line_table;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits