Skip to content

Fix linetables leak #1176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/include/lldb/Symbol/LineTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class LineTable {

// 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,
Expand Down
17 changes: 10 additions & 7 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,20 +1037,23 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) {
// 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();
std::unique_ptr<LineSequence> sequence =
LineTable::CreateLineSequenceContainer();
std::vector<std::unique_ptr<LineSequence>> sequences;
for (auto &row : line_table->Rows) {
line_table_up->AppendLineEntryToSequence(
sequence, row.Address.Address, row.Line, row.Column, row.File,
LineTable::AppendLineEntryToSequence(
sequence.get(), 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(std::move(sequence));
sequence = LineTable::CreateLineSequenceContainer();
}
}

std::unique_ptr<LineTable> line_table_up =
std::make_unique<LineTable>(&comp_unit, std::move(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
Expand Down