diff --git a/lldb/include/lldb/Symbol/LineTable.h b/lldb/include/lldb/Symbol/LineTable.h --- a/lldb/include/lldb/Symbol/LineTable.h +++ b/lldb/include/lldb/Symbol/LineTable.h @@ -71,7 +71,8 @@ void InsertLineEntry(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, bool is_prologue_end, - bool is_epilogue_begin, bool is_terminal_entry); + bool is_epilogue_begin, bool is_terminal_entry, + bool overwrite_existing = false); // Used to instantiate the LineSequence helper class static std::unique_ptr CreateLineSequenceContainer(); diff --git a/lldb/source/Symbol/LineTable.cpp b/lldb/source/Symbol/LineTable.cpp --- a/lldb/source/Symbol/LineTable.cpp +++ b/lldb/source/Symbol/LineTable.cpp @@ -41,7 +41,8 @@ bool is_start_of_statement, bool is_start_of_basic_block, bool is_prologue_end, bool is_epilogue_begin, - bool is_terminal_entry) { + bool is_terminal_entry, + bool overwrite_existing) { 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); @@ -49,7 +50,14 @@ LineTable::Entry::LessThanBinaryPredicate less_than_bp(this); entry_collection::iterator pos = llvm::upper_bound(m_entries, entry, less_than_bp); - + if (overwrite_existing && pos != m_entries.begin()) { + --pos; + if (pos->file_addr == file_addr) { + uint32_t idx = std::distance(m_entries.begin(), pos); + m_entries[idx] = entry; + return; + } + } // Stream s(stdout); // s << "\n\nBefore:\n"; // Dump (&s, Address::DumpStyleFileAddress);