From 9e42e92e43df3787a7162c066cb55ba097e9175c Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Wed, 18 Jun 2014 19:55:34 +0000 Subject: [PATCH] Don't allow multiple line entries with the same address to exist sequentially. The compiler, when JIT'ing code, can emit illegal DWARF line tables (address is line table sequences must increase). This changes fixes that issue by replacing previous line entries whose start address is the same with the new line entry to avoid having multiple line entries with the same address. Since the address range of lines entries is determined by the delta between the current and next line entry, this shouldn't cause any issues. llvm-svn: 211212 --- lldb/source/Symbol/LineTable.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lldb/source/Symbol/LineTable.cpp b/lldb/source/Symbol/LineTable.cpp index 3d7bf46..4b4e33b 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(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 -- 2.7.4