From 364f1167cb94de337f56f115e07335ac28bf213a Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 6 Jul 2010 23:34:08 +0000 Subject: [PATCH] Fixed an issue with looking up line table entries by address where internal line table entries that were termination entries (ones that define the bounds of the previous entry) could be found when looking up line table entries. We now properly skip these termination entries and check the next entry to try for a match. llvm-svn: 107729 --- lldb/source/Symbol/LineTable.cpp | 50 +++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/lldb/source/Symbol/LineTable.cpp b/lldb/source/Symbol/LineTable.cpp index cd83665cf4a2..c029208a833c 100644 --- a/lldb/source/Symbol/LineTable.cpp +++ b/lldb/source/Symbol/LineTable.cpp @@ -194,22 +194,50 @@ LineTable::FindLineEntryByAddress (const Address &so_addr, LineEntry& line_entry --pos; else if (pos->sect_offset == search_entry.sect_offset) { - while (pos != begin_pos) + // If this is a termination entry, it should't match since + // entries with the "is_terminal_entry" member set to true + // are termination entries that define the range for the + // previous entry. + if (pos->is_terminal_entry) { - entry_collection::const_iterator prev_pos = pos - 1; - if (prev_pos->sect_idx == search_entry.sect_idx && - prev_pos->sect_offset == search_entry.sect_offset) - --pos; - else - break; + // The matching entry is a terminal entry, so we skip + // ahead to the next entry to see if there is another + // entry following this one whose section/offset matches. + ++pos; + if (pos != end_pos) + { + if (pos->sect_offset != search_entry.sect_offset) + pos = end_pos; + } + } + + if (pos != end_pos) + { + // While in the same section/offset backup to find the first + // line entry that matches the address in case there are + // multiple + while (pos != begin_pos) + { + entry_collection::const_iterator prev_pos = pos - 1; + if (prev_pos->sect_idx == search_entry.sect_idx && + prev_pos->sect_offset == search_entry.sect_offset && + prev_pos->is_terminal_entry == false) + --pos; + else + break; + } } } } - uint32_t match_idx = std::distance (begin_pos, pos); - success = ConvertEntryAtIndexToLineEntry(match_idx, line_entry); - if (index_ptr != NULL && success) - *index_ptr = match_idx; + + if (pos != end_pos) + { + uint32_t match_idx = std::distance (begin_pos, pos); + success = ConvertEntryAtIndexToLineEntry(match_idx, line_entry); + if (index_ptr != NULL && success) + *index_ptr = match_idx; + } } } return success;