diff options
Diffstat (limited to 'lldb/source/Breakpoint/BreakpointResolverFileLine.cpp')
-rw-r--r-- | lldb/source/Breakpoint/BreakpointResolverFileLine.cpp | 118 |
1 files changed, 67 insertions, 51 deletions
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp index 84db721d13b..56859875224 100644 --- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp @@ -123,85 +123,101 @@ BreakpointResolverFileLine::SearchCallback current_idx++; } - // Okay, we've found the closest line number match, now throw away all the others, + // Okay, we've found the closest line number match, now throw away all the others: + + current_idx = 0; + while (current_idx < tmp_sc_list.GetSize()) + { + if (tmp_sc_list.GetContextAtIndex(current_idx, sc)) + { + if (sc.line_entry.line != closest_line_number) + tmp_sc_list.RemoveContextAtIndex(current_idx); + else + current_idx++; + } + } + + // Next go through and see if there are line table entries that are contiguous, and if so keep only the + // first of the contiguous range: + + lldb::addr_t last_end_addr = LLDB_INVALID_ADDRESS; + current_idx = 0; + while (current_idx < tmp_sc_list.GetSize()) + { + if (tmp_sc_list.GetContextAtIndex(current_idx, sc)) + { + lldb::addr_t start_file_addr = sc.line_entry.range.GetBaseAddress().GetFileAddress(); + lldb::addr_t end_file_addr = start_file_addr + sc.line_entry.range.GetByteSize(); + + if (start_file_addr == last_end_addr) + tmp_sc_list.RemoveContextAtIndex(current_idx); + else + current_idx++; + + last_end_addr = end_file_addr; + } + } + // and make breakpoints out of the closest line number match. uint32_t tmp_sc_list_size = tmp_sc_list.GetSize(); for (uint32_t i = 0; i < tmp_sc_list_size; i++) { - SymbolContext sc; if (tmp_sc_list.GetContextAtIndex(i, sc)) { - if (sc.line_entry.line == closest_line_number) + Address line_start = sc.line_entry.range.GetBaseAddress(); + if (line_start.IsValid()) { - Address line_start = sc.line_entry.range.GetBaseAddress(); - if (line_start.IsValid()) + if (filter.AddressPasses(line_start)) { - if (filter.AddressPasses(line_start)) + // If the line number is before the prologue end, move it there... + bool skipped_prologue = false; + if (m_skip_prologue) { - // If the line number is before the prologue end, move it there... - bool skipped_prologue = false; - if (m_skip_prologue) + if (sc.function) { - if (sc.function) + Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress()); + if (prologue_addr.IsValid() && (line_start == prologue_addr)) { - Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress()); - if (prologue_addr.IsValid() && (line_start == prologue_addr)) + const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize(); + if (prologue_byte_size) { - const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize(); - if (prologue_byte_size) + prologue_addr.Slide(prologue_byte_size); + + if (filter.AddressPasses(prologue_addr)) { - prologue_addr.Slide(prologue_byte_size); - - if (filter.AddressPasses(prologue_addr)) - { - skipped_prologue = true; - line_start = prologue_addr; - } + skipped_prologue = true; + line_start = prologue_addr; } } } } - - BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start)); - if (log && bp_loc_sp && !m_breakpoint->IsInternal()) - { - StreamString s; - bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose); - log->Printf ("Added location (skipped prologue: %s): %s \n", skipped_prologue ? "yes" : "no", s.GetData()); - } } - else if (log) + + BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start)); + if (log && bp_loc_sp && !m_breakpoint->IsInternal()) { - log->Printf ("Breakpoint at file address 0x%" PRIx64 " for %s:%d didn't pass the filter.\n", - line_start.GetFileAddress(), - m_file_spec.GetFilename().AsCString("<Unknown>"), - m_line_number); + StreamString s; + bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose); + log->Printf ("Added location (skipped prologue: %s): %s \n", skipped_prologue ? "yes" : "no", s.GetData()); } } - else + else if (log) { - if (log) - log->Printf ("error: Unable to set breakpoint at file address 0x%" PRIx64 " for %s:%d\n", - line_start.GetFileAddress(), - m_file_spec.GetFilename().AsCString("<Unknown>"), - m_line_number); + log->Printf ("Breakpoint at file address 0x%" PRIx64 " for %s:%d didn't pass the filter.\n", + line_start.GetFileAddress(), + m_file_spec.GetFilename().AsCString("<Unknown>"), + m_line_number); } } else { - #if 0 - s << "error: Breakpoint at '" << pos->c_str() << "' isn't resolved yet: \n"; - if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionNameOffset)) - s.EOL(); - if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionPointerOffset)) - s.EOL(); - if (sc.line_entry.address.Dump(&s, Address::DumpStyleFileAddress)) - s.EOL(); - if (sc.line_entry.address.Dump(&s, Address::DumpStyleLoadAddress)) - s.EOL(); - #endif + if (log) + log->Printf ("error: Unable to set breakpoint at file address 0x%" PRIx64 " for %s:%d\n", + line_start.GetFileAddress(), + m_file_spec.GetFilename().AsCString("<Unknown>"), + m_line_number); } } } |