void ThreadPlanRunToAddress::SetInitialBreakpoints() { size_t num_addresses = m_addresses.size(); m_break_ids.resize(num_addresses); for (size_t i = 0; i < num_addresses; i++) { Breakpoint *breakpoint; breakpoint = m_thread.CalculateTarget() ->CreateBreakpoint(m_addresses[i], true, false) .get(); if (breakpoint != nullptr) { m_break_ids[i] = breakpoint->GetID(); breakpoint->SetThreadID(m_thread.GetID()); breakpoint->SetBreakpointKind("run-to-address"); } } }
void ThreadPlanRunToAddress::SetInitialBreakpoints () { size_t num_addresses = m_addresses.size(); m_break_ids.resize(num_addresses); for (size_t i = 0; i < num_addresses; i++) { Breakpoint *breakpoint; breakpoint = m_thread.GetProcess().GetTarget().CreateBreakpoint (m_addresses[i], true).get(); if (breakpoint != NULL) { m_break_ids[i] = breakpoint->GetID(); breakpoint->SetThreadID(m_thread.GetID()); } } }
void ThreadPlanRunToAddress::SetInitialBreakpoints() { size_t num_addresses = m_addresses.size(); m_break_ids.resize(num_addresses); for (size_t i = 0; i < num_addresses; i++) { Breakpoint *breakpoint; breakpoint = m_thread.CalculateTarget() ->CreateBreakpoint(m_addresses[i], true, false) .get(); if (breakpoint != nullptr) { if (breakpoint->IsHardware() && !breakpoint->HasResolvedLocations()) m_could_not_resolve_hw_bp = true; m_break_ids[i] = breakpoint->GetID(); breakpoint->SetThreadID(m_thread.GetID()); breakpoint->SetBreakpointKind("run-to-address"); } } }
//------------------------------------------------------------------ // Setup the JIT Breakpoint //------------------------------------------------------------------ void JITLoaderGDB::SetJITBreakpoint(lldb_private::ModuleList &module_list) { if (!GetGlobalPluginProperties()->GetEnableJITBreakpoint()) return; if ( DidSetJITBreakpoint() ) return; Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER)); if (log) log->Printf("JITLoaderGDB::%s looking for JIT register hook", __FUNCTION__); addr_t jit_addr = GetSymbolAddress(module_list, ConstString("__jit_debug_register_code"), eSymbolTypeAny); if (jit_addr == LLDB_INVALID_ADDRESS) return; m_jit_descriptor_addr = GetSymbolAddress(module_list, ConstString("__jit_debug_descriptor"), eSymbolTypeData); if (m_jit_descriptor_addr == LLDB_INVALID_ADDRESS) { if (log) log->Printf( "JITLoaderGDB::%s failed to find JIT descriptor address", __FUNCTION__); return; } if (log) log->Printf("JITLoaderGDB::%s setting JIT breakpoint", __FUNCTION__); Breakpoint *bp = m_process->GetTarget().CreateBreakpoint(jit_addr, true, false).get(); bp->SetCallback(JITDebugBreakpointHit, this, true); bp->SetBreakpointKind("jit-debug-register"); m_jit_break_id = bp->GetID(); ReadJITDescriptor(true); }
void DynamicLoaderDarwinKernel::SetNotificationBreakpointIfNeeded () { if (m_break_id == LLDB_INVALID_BREAK_ID && m_kernel.module_sp) { DEBUG_PRINTF("DynamicLoaderDarwinKernel::%s() process state = %s\n", __FUNCTION__, StateAsCString(m_process->GetState())); const bool internal_bp = true; const LazyBool skip_prologue = eLazyBoolNo; FileSpecList module_spec_list; module_spec_list.Append (m_kernel.module_sp->GetFileSpec()); Breakpoint *bp = m_process->GetTarget().CreateBreakpoint (&module_spec_list, NULL, "OSKextLoadedKextSummariesUpdated", eFunctionNameTypeFull, skip_prologue, internal_bp).get(); bp->SetCallback (DynamicLoaderDarwinKernel::BreakpointHitCallback, this, true); m_break_id = bp->GetID(); } }
void BreakpointIDList::FindAndReplaceIDRanges (Args &old_args, Target *target, CommandReturnObject &result, Args &new_args) { std::string range_start; const char *range_end; const char *current_arg; const size_t num_old_args = old_args.GetArgumentCount(); for (size_t i = 0; i < num_old_args; ++i) { bool is_range = false; current_arg = old_args.GetArgumentAtIndex (i); uint32_t range_start_len = 0; uint32_t range_end_pos = 0; if (BreakpointIDList::StringContainsIDRangeExpression (current_arg, &range_start_len, &range_end_pos)) { is_range = true; range_start = (char *) malloc (range_start_len + 1); range_start.assign (current_arg, range_start_len); range_end = current_arg + range_end_pos; } else if ((i + 2 < num_old_args) && BreakpointID::IsRangeIdentifier (old_args.GetArgumentAtIndex (i+1)) && BreakpointID::IsValidIDExpression (current_arg) && BreakpointID::IsValidIDExpression (old_args.GetArgumentAtIndex (i+2))) { range_start.assign (current_arg); range_end = old_args.GetArgumentAtIndex (i+2); is_range = true; i = i+2; } if (is_range) { break_id_t start_bp_id; break_id_t end_bp_id; break_id_t start_loc_id; break_id_t end_loc_id; BreakpointID::ParseCanonicalReference (range_start.c_str(), &start_bp_id, &start_loc_id); BreakpointID::ParseCanonicalReference (range_end, &end_bp_id, &end_loc_id); if ((start_bp_id == LLDB_INVALID_BREAK_ID) || (! target->GetBreakpointByID (start_bp_id))) { new_args.Clear(); result.AppendErrorWithFormat ("'%s' is not a valid breakpoint ID.\n", range_start.c_str()); result.SetStatus (eReturnStatusFailed); return; } if ((end_bp_id == LLDB_INVALID_BREAK_ID) || (! target->GetBreakpointByID (end_bp_id))) { new_args.Clear(); result.AppendErrorWithFormat ("'%s' is not a valid breakpoint ID.\n", range_end); result.SetStatus (eReturnStatusFailed); return; } // We have valid range starting & ending breakpoint IDs. Go through all the breakpoints in the // target and find all the breakpoints that fit into this range, and add them to new_args. const BreakpointList& breakpoints = target->GetBreakpointList(); const size_t num_breakpoints = breakpoints.GetSize(); for (size_t j = 0; j < num_breakpoints; ++j) { Breakpoint *breakpoint = breakpoints.GetBreakpointByIndex (j).get(); break_id_t cur_bp_id = breakpoint->GetID(); if ((cur_bp_id < start_bp_id) || (cur_bp_id > end_bp_id)) continue; const size_t num_locations = breakpoint->GetNumLocations(); if ((cur_bp_id == start_bp_id) && (start_loc_id != LLDB_INVALID_BREAK_ID)) { for (size_t k = 0; k < num_locations; ++k) { BreakpointLocation * bp_loc = breakpoint->GetLocationAtIndex(k).get(); if (bp_loc->GetID() >= start_loc_id) { StreamString canonical_id_str; BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, bp_loc->GetID()); new_args.AppendArgument (canonical_id_str.GetData()); } } } else if ((cur_bp_id == end_bp_id) && (end_loc_id != LLDB_INVALID_BREAK_ID)) { for (size_t k = 0; k < num_locations; ++k) { BreakpointLocation * bp_loc = breakpoint->GetLocationAtIndex(k).get(); if (bp_loc->GetID() <= end_loc_id) { StreamString canonical_id_str; BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, bp_loc->GetID()); new_args.AppendArgument (canonical_id_str.GetData()); } } } else { StreamString canonical_id_str; BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, LLDB_INVALID_BREAK_ID); new_args.AppendArgument (canonical_id_str.GetData()); } } } else // else is_range was false { new_args.AppendArgument (current_arg); } } result.SetStatus (eReturnStatusSuccessFinishNoResult); return; }