diff options
author | emaste <emaste@FreeBSD.org> | 2014-11-25 21:00:58 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2014-11-25 21:00:58 +0000 |
commit | 01ee1789d6aa7294e5966a97f8d29387f6f81699 (patch) | |
tree | c94307da318be46e5aeea1a325c1e91749506e4f /source/Symbol/LineTable.cpp | |
parent | 788502c6f6261e2d84ef85d1052b41a6c5be31b3 (diff) | |
download | FreeBSD-src-01ee1789d6aa7294e5966a97f8d29387f6f81699.zip FreeBSD-src-01ee1789d6aa7294e5966a97f8d29387f6f81699.tar.gz |
Import LLDB as of upstream SVN r216948 (git 50f7fe44)
This corresponds with the branchpoint for the 3.5 release.
A number of files not required for the FreeBSD build have been removed.
Sponsored by: DARPA, AFRL
Diffstat (limited to 'source/Symbol/LineTable.cpp')
-rw-r--r-- | source/Symbol/LineTable.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/source/Symbol/LineTable.cpp b/source/Symbol/LineTable.cpp index a4aa35d..4b4e33b 100644 --- a/source/Symbol/LineTable.cpp +++ b/source/Symbol/LineTable.cpp @@ -93,16 +93,26 @@ LineTable::AppendLineEntryToSequence bool is_terminal_entry ) { - assert(sequence != NULL); + 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 LineTable::InsertSequence (LineSequence* sequence) { - assert(sequence != NULL); + assert(sequence != nullptr); LineSequenceImpl* seq = reinterpret_cast<LineSequenceImpl*>(sequence); if (seq->m_entries.empty()) return; @@ -183,7 +193,7 @@ LineTable::GetLineEntryAtIndex(uint32_t idx, LineEntry& line_entry) bool LineTable::FindLineEntryByAddress (const Address &so_addr, LineEntry& line_entry, uint32_t *index_ptr) { - if (index_ptr != NULL ) + if (index_ptr != nullptr ) *index_ptr = UINT32_MAX; bool success = false; @@ -247,7 +257,7 @@ LineTable::FindLineEntryByAddress (const Address &so_addr, LineEntry& line_entry { uint32_t match_idx = std::distance (begin_pos, pos); success = ConvertEntryAtIndexToLineEntry(match_idx, line_entry); - if (index_ptr != NULL && success) + if (index_ptr != nullptr && success) *index_ptr = match_idx; } } @@ -493,8 +503,8 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map) LineSequenceImpl sequence; const size_t count = m_entries.size(); LineEntry line_entry; - const FileRangeMap::Entry *file_range_entry = NULL; - const FileRangeMap::Entry *prev_file_range_entry = NULL; + const FileRangeMap::Entry *file_range_entry = nullptr; + const FileRangeMap::Entry *prev_file_range_entry = nullptr; lldb::addr_t prev_file_addr = LLDB_INVALID_ADDRESS; bool prev_entry_was_linked = false; bool range_changed = false; @@ -504,7 +514,7 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map) const bool end_sequence = entry.is_terminal_entry; const lldb::addr_t lookup_file_addr = entry.file_addr - (end_sequence ? 1 : 0); - if (file_range_entry == NULL || !file_range_entry->Contains(lookup_file_addr)) + if (file_range_entry == nullptr || !file_range_entry->Contains(lookup_file_addr)) { prev_file_range_entry = file_range_entry; file_range_entry = file_range_map.FindEntryThatContains(lookup_file_addr); @@ -573,13 +583,13 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map) } else { - prev_entry_was_linked = file_range_entry != NULL; + prev_entry_was_linked = file_range_entry != nullptr; } prev_file_addr = entry.file_addr; range_changed = false; } if (line_table_ap->m_entries.empty()) - return NULL; + return nullptr; return line_table_ap.release(); } |