diff options
-rw-r--r-- | lldb/source/Symbol/LineTable.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lldb/source/Symbol/LineTable.cpp b/lldb/source/Symbol/LineTable.cpp index 3d7bf4640e7..4b4e33b2b0e 100644 --- a/lldb/source/Symbol/LineTable.cpp +++ b/lldb/source/Symbol/LineTable.cpp @@ -96,7 +96,17 @@ LineTable::AppendLineEntryToSequence assert(sequence != nullptr); LineSequenceImpl* seq = reinterpret_cast<LineSequenceImpl*>(sequence); Entry entry(file_addr, line, column, file_idx, is_start_of_statement, is_start_of_basic_block, is_prologue_end, is_epilogue_begin, is_terminal_entry); - seq->m_entries.push_back (entry); + entry_collection &entries = seq->m_entries; + // Replace the last entry if the address is the same, otherwise append it. If we have multiple + // line entries at the same address, this indicates illegal DWARF so this "fixes" the line table + // to be correct. If not fixed this can cause a line entry's address that when resolved back to + // a symbol context, could resolve to a different line entry. We really want a 1 to 1 mapping + // here to avoid these kinds of inconsistencies. We will need tor revisit this if the DWARF line + // tables are updated to allow multiple entries at the same address legally. + if (!entries.empty() && entries.back().file_addr == file_addr) + entries.back() = entry; + else + entries.push_back (entry); } void |