diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Breakpoint')
9 files changed, 187 insertions, 204 deletions
diff --git a/contrib/llvm/tools/lldb/source/Breakpoint/Breakpoint.cpp b/contrib/llvm/tools/lldb/source/Breakpoint/Breakpoint.cpp index 9bc4381..e07205e 100644 --- a/contrib/llvm/tools/lldb/source/Breakpoint/Breakpoint.cpp +++ b/contrib/llvm/tools/lldb/source/Breakpoint/Breakpoint.cpp @@ -45,8 +45,9 @@ Breakpoint::GetEventIdentifier () //---------------------------------------------------------------------- // Breakpoint constructor //---------------------------------------------------------------------- -Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp) : +Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool hardware) : m_being_created(true), + m_hardware(hardware), m_target (target), m_filter_sp (filter_sp), m_resolver_sp (resolver_sp), @@ -558,7 +559,7 @@ Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_l { s->Printf(", locations = %" PRIu64, (uint64_t)num_locations); if (num_resolved_locations > 0) - s->Printf(", resolved = %" PRIu64, (uint64_t)num_resolved_locations); + s->Printf(", resolved = %" PRIu64 ", hit count = %d", (uint64_t)num_resolved_locations, GetHitCount()); } else { diff --git a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointList.cpp b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointList.cpp index 5926663..c6030d6 100644 --- a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointList.cpp +++ b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointList.cpp @@ -204,13 +204,13 @@ BreakpointList::GetBreakpointAtIndex (size_t i) const } void -BreakpointList::UpdateBreakpoints (ModuleList& module_list, bool added) +BreakpointList::UpdateBreakpoints (ModuleList& module_list, bool added, bool delete_locations) { Mutex::Locker locker(m_mutex); bp_collection::iterator end = m_breakpoints.end(); bp_collection::iterator pos; for (pos = m_breakpoints.begin(); pos != end; ++pos) - (*pos)->ModulesChanged (module_list, added); + (*pos)->ModulesChanged (module_list, added, delete_locations); } diff --git a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocation.cpp b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocation.cpp index 1ec726d..17568c2 100644 --- a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -291,9 +291,11 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) // constructor errors up to the debugger's Async I/O. ValueObjectSP result_value_sp; - const bool unwind_on_error = true; - const bool ignore_breakpoints = true; - const bool try_all_threads = true; + + EvaluateExpressionOptions options; + options.SetUnwindOnError(true); + options.SetIgnoreBreakpoints(true); + options.SetRunOthers(true); Error expr_error; @@ -304,12 +306,9 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) ExecutionResults result_code = m_user_expression_sp->Execute(execution_errors, exe_ctx, - unwind_on_error, - ignore_breakpoints, + options, m_user_expression_sp, - result_variable_sp, - try_all_threads, - ClangUserExpression::kDefaultTimeout); + result_variable_sp); bool ret; @@ -484,7 +483,7 @@ BreakpointLocation::ResolveBreakpointSite () if (process == NULL) return false; - lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), false); + lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), m_owner.IsHardware()); if (new_id == LLDB_INVALID_BREAK_ID) { diff --git a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp index 22a4ff0..341b097 100644 --- a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp +++ b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointLocationList.cpp @@ -41,7 +41,7 @@ BreakpointLocationList::Create (const Address &addr) Mutex::Locker locker (m_mutex); // The location ID is just the size of the location list + 1 lldb::break_id_t bp_loc_id = ++m_next_id; - BreakpointLocationSP bp_loc_sp (new BreakpointLocation (bp_loc_id, m_owner, addr)); + BreakpointLocationSP bp_loc_sp (new BreakpointLocation (bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID, m_owner.IsHardware())); m_locations.push_back (bp_loc_sp); m_address_to_location[addr] = bp_loc_sp; return bp_loc_sp; diff --git a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolver.cpp b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolver.cpp index b22fa1e..33b0ff4 100644 --- a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolver.cpp +++ b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolver.cpp @@ -23,9 +23,12 @@ #include "lldb/Core/StreamString.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/Target.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/Function.h" #include "lldb/lldb-private-log.h" using namespace lldb_private; +using namespace lldb; //---------------------------------------------------------------------- // BreakpointResolver: @@ -59,3 +62,144 @@ BreakpointResolver::ResolveBreakpoint (SearchFilter &filter) filter.Search (*this); } +void +BreakpointResolver::SetSCMatchesByLine (SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, const char *log_ident) +{ + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); + + while (sc_list.GetSize() > 0) + { + SymbolContextList tmp_sc_list; + unsigned current_idx = 0; + SymbolContext sc; + bool first_entry = true; + + FileSpec match_file_spec; + uint32_t closest_line_number = UINT32_MAX; + + // Pull out the first entry, and all the others that match its file spec, and stuff them in the tmp list. + while (current_idx < sc_list.GetSize()) + { + bool matches; + + sc_list.GetContextAtIndex (current_idx, sc); + if (first_entry) + { + match_file_spec = sc.line_entry.file; + matches = true; + first_entry = false; + } + else + matches = (sc.line_entry.file == match_file_spec); + + if (matches) + { + tmp_sc_list.Append (sc); + sc_list.RemoveContextAtIndex(current_idx); + + // ResolveSymbolContext will always return a number that is >= the line number you pass in. + // So the smaller line number is always better. + if (sc.line_entry.line < closest_line_number) + closest_line_number = sc.line_entry.line; + } + else + current_idx++; + } + + // 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: + + current_idx = 0; + std::map<Block *, lldb::addr_t> blocks_with_breakpoints; + + while (current_idx < tmp_sc_list.GetSize()) + { + if (tmp_sc_list.GetContextAtIndex(current_idx, sc)) + { + if (blocks_with_breakpoints.find (sc.block) != blocks_with_breakpoints.end()) + tmp_sc_list.RemoveContextAtIndex(current_idx); + else + { + blocks_with_breakpoints.insert (std::pair<Block *, lldb::addr_t>(sc.block, sc.line_entry.range.GetBaseAddress().GetFileAddress())); + current_idx++; + } + } + } + + // 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++) + { + if (tmp_sc_list.GetContextAtIndex(i, sc)) + { + Address line_start = sc.line_entry.range.GetBaseAddress(); + if (line_start.IsValid()) + { + if (filter.AddressPasses(line_start)) + { + // If the line number is before the prologue end, move it there... + bool skipped_prologue = false; + if (skip_prologue) + { + if (sc.function) + { + 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) + { + prologue_addr.Slide(prologue_byte_size); + + if (filter.AddressPasses(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) + { + log->Printf ("Breakpoint %s at file address 0x%" PRIx64 " didn't pass the filter.\n", + log_ident ? log_ident : "", + line_start.GetFileAddress()); + } + } + else + { + if (log) + log->Printf ("error: Unable to set breakpoint %s at file address 0x%" PRIx64 "\n", + log_ident ? log_ident : "", + line_start.GetFileAddress()); + } + } + } + } +} diff --git a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp index 91a218f..dcee2fd 100644 --- a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp +++ b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp @@ -59,7 +59,6 @@ BreakpointResolverFileLine::SearchCallback SymbolContextList sc_list; assert (m_breakpoint != NULL); - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); // There is a tricky bit here. You can have two compilation units that #include the same file, and // in one of them the function at m_line_number is used (and so code and a line entry for it is generated) but in the @@ -83,146 +82,13 @@ BreakpointResolverFileLine::SearchCallback cu_sp->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything, sc_list); } } - - while (sc_list.GetSize() > 0) - { - SymbolContextList tmp_sc_list; - unsigned current_idx = 0; - SymbolContext sc; - bool first_entry = true; - - FileSpec match_file_spec; - uint32_t closest_line_number = UINT32_MAX; + StreamString s; + s.Printf ("for %s:%d ", + m_file_spec.GetFilename().AsCString("<Unknown>"), + m_line_number); - // Pull out the first entry, and all the others that match its file spec, and stuff them in the tmp list. - while (current_idx < sc_list.GetSize()) - { - bool matches; - - sc_list.GetContextAtIndex (current_idx, sc); - if (first_entry) - { - match_file_spec = sc.line_entry.file; - matches = true; - first_entry = false; - } - else - matches = (sc.line_entry.file == match_file_spec); - - if (matches) - { - tmp_sc_list.Append (sc); - sc_list.RemoveContextAtIndex(current_idx); - - // ResolveSymbolContext will always return a number that is >= the line number you pass in. - // So the smaller line number is always better. - if (sc.line_entry.line < closest_line_number) - closest_line_number = sc.line_entry.line; - } - else - current_idx++; - } - - // 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++; + SetSCMatchesByLine (filter, sc_list, m_skip_prologue, s.GetData()); - 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++) - { - if (tmp_sc_list.GetContextAtIndex(i, sc)) - { - Address line_start = sc.line_entry.range.GetBaseAddress(); - if (line_start.IsValid()) - { - 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 (sc.function) - { - 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) - { - prologue_addr.Slide(prologue_byte_size); - - if (filter.AddressPasses(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) - { - 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 (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); - } - } - } - } - return Searcher::eCallbackReturnContinue; } diff --git a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp index de974d0..01aecee 100644 --- a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp +++ b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp @@ -54,60 +54,23 @@ BreakpointResolverFileRegex::SearchCallback assert (m_breakpoint != NULL); if (!context.target_sp) return eCallbackReturnContinue; - - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); CompileUnit *cu = context.comp_unit; FileSpec cu_file_spec = *(static_cast<FileSpec *>(cu)); std::vector<uint32_t> line_matches; - context.target_sp->GetSourceManager().FindLinesMatchingRegex(cu_file_spec, m_regex, 1, UINT32_MAX, line_matches); + context.target_sp->GetSourceManager().FindLinesMatchingRegex(cu_file_spec, m_regex, 1, UINT32_MAX, line_matches); + uint32_t num_matches = line_matches.size(); for (uint32_t i = 0; i < num_matches; i++) { - uint32_t start_idx = 0; - bool exact = false; - while (1) - { - LineEntry line_entry; + SymbolContextList sc_list; + const bool search_inlines = false; + const bool exact = false; - // Cycle through all the line entries that might match this one: - start_idx = cu->FindLineEntry (start_idx, line_matches[i], NULL, exact, &line_entry); - if (start_idx == UINT32_MAX) - break; - exact = true; - start_idx++; - - Address line_start = line_entry.range.GetBaseAddress(); - if (line_start.IsValid()) - { - if (filter.AddressPasses(line_start)) - { - 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: %s\n", s.GetData()); - } - } - else if (log) - { - log->Printf ("Breakpoint at file address 0x%" PRIx64 " for %s:%d didn't pass filter.\n", - line_start.GetFileAddress(), - cu_file_spec.GetFilename().AsCString("<Unknown>"), - line_matches[i]); - } - } - else - { - if (log) - log->Printf ("error: Unable to set breakpoint at file address 0x%" PRIx64 " for %s:%d\n", - line_start.GetFileAddress(), - cu_file_spec.GetFilename().AsCString("<Unknown>"), - line_matches[i]); - } - - } + cu->ResolveSymbolContext (cu_file_spec, line_matches[i], search_inlines, exact, eSymbolContextEverything, sc_list); + const bool skip_prologue = true; + + BreakpointResolver::SetSCMatchesByLine (filter, sc_list, skip_prologue, m_regex.GetText()); } assert (m_breakpoint != NULL); diff --git a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverName.cpp b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverName.cpp index 27f8565..c82dd5e 100644 --- a/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverName.cpp +++ b/contrib/llvm/tools/lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -289,7 +289,17 @@ BreakpointResolverName::SearchCallback } else if (sc.symbol) { - break_addr = sc.symbol->GetAddress(); + if (sc.symbol->GetType() == eSymbolTypeReExported) + { + const Symbol *actual_symbol = sc.symbol->ResolveReExportedSymbol(m_breakpoint->GetTarget()); + if (actual_symbol) + break_addr = actual_symbol->GetAddress(); + } + else + { + break_addr = sc.symbol->GetAddress(); + } + if (m_skip_prologue && break_addr.IsValid()) { const uint32_t prologue_byte_size = sc.symbol->GetPrologueByteSize(); diff --git a/contrib/llvm/tools/lldb/source/Breakpoint/StoppointLocation.cpp b/contrib/llvm/tools/lldb/source/Breakpoint/StoppointLocation.cpp index 092caa5..9d8d924 100644 --- a/contrib/llvm/tools/lldb/source/Breakpoint/StoppointLocation.cpp +++ b/contrib/llvm/tools/lldb/source/Breakpoint/StoppointLocation.cpp @@ -23,8 +23,8 @@ using namespace lldb_private; StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, bool hardware) : m_loc_id(bid), m_addr(addr), - m_hw_preferred(hardware), - m_hw_index(LLDB_INVALID_INDEX32), + m_hardware(hardware), + m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(0), m_hit_count(0) { @@ -33,8 +33,8 @@ StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, bool hardware StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, uint32_t byte_size, bool hardware) : m_loc_id(bid), m_addr(addr), - m_hw_preferred(hardware), - m_hw_index(LLDB_INVALID_INDEX32), + m_hardware(hardware), + m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(byte_size), m_hit_count(0) { |