Bug #: 8408441
Fixed an issue where LLDB would fail to set a breakpoint by
file and line if the DWARF line table has multiple file entries
in the support files for a source file.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113721 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Symbol/LineTable.cpp b/source/Symbol/LineTable.cpp
index c029208..6b11f24 100644
--- a/source/Symbol/LineTable.cpp
+++ b/source/Symbol/LineTable.cpp
@@ -281,6 +281,64 @@
}
uint32_t
+LineTable::FindLineEntryIndexByFileIndex
+(
+ uint32_t start_idx,
+ const std::vector<uint32_t> &file_indexes,
+ uint32_t line,
+ bool exact,
+ LineEntry* line_entry_ptr
+)
+{
+
+ const size_t count = m_entries.size();
+ std::vector<uint32_t>::const_iterator begin_pos = file_indexes.begin();
+ std::vector<uint32_t>::const_iterator end_pos = file_indexes.end();
+ size_t best_match = UINT_MAX;
+
+ for (size_t idx = start_idx; idx < count; ++idx)
+ {
+ // Skip line table rows that terminate the previous row (is_terminal_entry is non-zero)
+ if (m_entries[idx].is_terminal_entry)
+ continue;
+
+ if (find (begin_pos, end_pos, m_entries[idx].file_idx) == end_pos)
+ continue;
+
+ // Exact match always wins. Otherwise try to find the closest line > the desired
+ // line.
+ // FIXME: Maybe want to find the line closest before and the line closest after and
+ // if they're not in the same function, don't return a match.
+
+ if (m_entries[idx].line < line)
+ {
+ continue;
+ }
+ else if (m_entries[idx].line == line)
+ {
+ if (line_entry_ptr)
+ ConvertEntryAtIndexToLineEntry (idx, *line_entry_ptr);
+ return idx;
+ }
+ else if (!exact)
+ {
+ if (best_match == UINT32_MAX)
+ best_match = idx;
+ else if (m_entries[idx].line < m_entries[best_match].line)
+ best_match = idx;
+ }
+ }
+
+ if (best_match != UINT_MAX)
+ {
+ if (line_entry_ptr)
+ ConvertEntryAtIndexToLineEntry (best_match, *line_entry_ptr);
+ return best_match;
+ }
+ return UINT_MAX;
+}
+
+uint32_t
LineTable::FindLineEntryIndexByFileIndex (uint32_t start_idx, uint32_t file_idx, uint32_t line, bool exact, LineEntry* line_entry_ptr)
{
const size_t count = m_entries.size();