Skip to content

Commit 40fe7cd

Browse files
authored
Merge pull request #1176 from fredriss/fix-linetables-leak
Fix linetables leak
2 parents f962f64 + 8ae23e6 commit 40fe7cd

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

lldb/include/lldb/Symbol/LineTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class LineTable {
7575

7676
// Append an entry to a caller-provided collection that will later be
7777
// inserted in this line table.
78-
void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr,
78+
static void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr,
7979
uint32_t line, uint16_t column,
8080
uint16_t file_idx, bool is_start_of_statement,
8181
bool is_start_of_basic_block,

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

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

1054+
std::unique_ptr<LineTable> line_table_up =
1055+
std::make_unique<LineTable>(&comp_unit, std::move(sequences));
1056+
10541057
if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile()) {
10551058
// We have an object file that has a line table with addresses that are not
10561059
// linked. We need to link the line table and convert the addresses that

0 commit comments

Comments
 (0)