31 StopInfo::StopInfo(
Thread &thread, uint64_t value)
32 : m_thread_wp(thread.shared_from_this()),
33 m_stop_id(thread.GetProcess()->GetStopID()),
34 m_resume_id(thread.GetProcess()->GetResumeID()), m_value(value),
41 return thread_sp->GetProcess()->GetStopID() ==
m_stop_id;
48 m_stop_id = thread_sp->GetProcess()->GetStopID();
49 m_resume_id = thread_sp->GetProcess()->GetResumeID();
69 uint32_t curr_resume_id = thread_sp->GetProcess()->GetResumeID();
71 thread_sp->GetProcess()->GetLastUserExpressionResumeID();
74 }
else if (curr_resume_id > last_user_expression_id) {
108 BreakpointSiteSP bp_site_sp(
109 thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(
m_value));
111 uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
112 if (num_owners == 1) {
113 BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(0);
115 Breakpoint & bkpt = bp_loc_sp->GetBreakpoint();
122 for (
uint32_t i = 0; i < num_owners; i++) {
123 if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal()) {
129 m_address = bp_site_sp->GetLoadAddress();
137 BreakpointSiteSP bp_site_sp(
138 process_sp->GetBreakpointSiteList().FindByID(
m_value));
140 return bp_site_sp->ValidForThisThread(thread);
152 BreakpointSiteSP bp_site_sp(
153 thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(
m_value));
157 bp_site_sp->BumpHitCounts();
163 "Process::%s could not find breakpoint site id: %" PRId64
184 BreakpointSiteSP bp_site_sp(
185 thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(
m_value));
190 if (bp_site_sp->IsInternal()) {
191 size_t num_owners = bp_site_sp->GetNumberOfOwners();
192 for (
size_t idx = 0; idx < num_owners; idx++) {
193 const char *kind = bp_site_sp->GetOwnerAtIndex(idx)
195 .GetBreakpointKind();
196 if (kind !=
nullptr) {
203 strm.
Printf(
"breakpoint ");
209 BreakpointSP break_sp =
210 thread_sp->GetProcess()->GetTarget().GetBreakpointByID(
213 if (break_sp->IsInternal()) {
214 const char *kind = break_sp->GetBreakpointKind();
226 strm.
Printf(
"breakpoint %d which has been deleted.",
230 strm.
Printf(
"breakpoint site %" PRIi64
231 " which has been deleted - unknown address",
234 strm.
Printf(
"breakpoint site %" PRIi64
235 " which has been deleted - was at 0x%" PRIx64,
258 bool internal_breakpoint =
true;
265 if (!thread_sp->IsValid()) {
268 LLDB_LOGF(log,
"PerformAction got called with an invalid thread.");
275 BreakpointSiteSP bp_site_sp(
276 thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(
m_value));
277 std::unordered_set<break_id_t> precondition_breakpoints;
284 size_t num_owners = bp_site_sp->CopyOwnersList(site_locations);
286 if (num_owners == 0) {
312 bool async_should_stop =
false;
315 bool actually_said_continue =
false;
345 if (thread_sp->CompletedPlanOverridesBreakpoint()) {
347 thread_sp->ResetStopInfo();
351 LLDB_LOGF(log,
"StopInfoBreakpoint::PerformAction - Hit a "
352 "breakpoint while running an expression,"
353 " not running commands to avoid recursion.");
354 bool ignoring_breakpoints =
356 if (ignoring_breakpoints) {
359 for (
size_t j = 0; j < num_owners; j++) {
360 lldb::BreakpointLocationSP bp_loc_sp =
361 bp_site_sp->GetOwnerAtIndex(j);
362 if (bp_loc_sp->GetBreakpoint().IsInternal()) {
371 "StopInfoBreakpoint::PerformAction - in expression, "
375 "hit breakpoint while running function, skipping commands and "
376 "conditions to prevent recursion",
390 std::vector<lldb::BreakpointSP> location_owners;
392 for (
size_t j = 0; j < num_owners; j++) {
393 BreakpointLocationSP loc(site_locations.
GetByIndex(j));
394 location_owners.push_back(loc->GetBreakpoint().shared_from_this());
397 for (
size_t j = 0; j < num_owners; j++) {
398 lldb::BreakpointLocationSP bp_loc_sp = site_locations.
GetByIndex(j);
405 if (!bp_loc_sp->IsEnabled() ||
406 !bp_loc_sp->GetBreakpoint().IsEnabled())
412 if (!bp_loc_sp->ValidForThisThread(*thread_sp)) {
415 "Breakpoint %s hit on thread 0x%llx but it was not "
416 "for this thread, continuing.",
418 static_cast<unsigned long long>(thread_sp->GetID()));
423 internal_breakpoint = bp_loc_sp->GetBreakpoint().IsInternal();
427 std::pair<std::unordered_set<break_id_t>::iterator,
bool> result =
428 precondition_breakpoints.insert(
429 bp_loc_sp->GetBreakpoint().GetID());
433 bool precondition_result =
434 bp_loc_sp->GetBreakpoint().EvaluatePrecondition(context);
435 if (!precondition_result) {
436 actually_said_continue =
true;
443 if (bp_loc_sp->GetConditionText() !=
nullptr) {
445 bool condition_says_stop =
446 bp_loc_sp->ConditionSaysStop(exe_ctx, condition_error);
448 if (!condition_error.
Success()) {
449 const char *err_str =
450 condition_error.
AsCString(
"<unknown error>");
451 LLDB_LOGF(log,
"Error evaluating condition: \"%s\"\n", err_str);
454 strm <<
"stopped due to an error evaluating condition of "
457 strm <<
": \"" << bp_loc_sp->GetConditionText() <<
"\"\n";
465 "Condition evaluated for breakpoint %s on thread "
466 "0x%llx condition_says_stop: %i.",
468 static_cast<unsigned long long>(thread_sp->GetID()),
469 condition_says_stop);
470 if (!condition_says_stop) {
474 bp_loc_sp->UndoBumpHitCount();
475 actually_said_continue =
true;
485 if (!bp_loc_sp->IgnoreCountShouldStop()) {
486 actually_said_continue =
true;
496 bool auto_continue_says_stop =
true;
497 if (bp_loc_sp->IsAutoContinue())
500 "Continuing breakpoint %s as AutoContinue was set.",
504 if (!internal_breakpoint)
505 thread_sp->SetShouldReportStop(
eVoteYes);
506 auto_continue_says_stop =
false;
509 bool callback_says_stop =
true;
519 if (!bp_loc_sp->IsCallbackSynchronous()) {
520 Debugger &debugger = thread_sp->CalculateTarget()->GetDebugger();
524 callback_says_stop = bp_loc_sp->InvokeCallback(&context);
528 if (callback_says_stop && auto_continue_says_stop)
531 actually_said_continue =
true;
536 if (callback_says_stop && bp_loc_sp &&
537 bp_loc_sp->GetBreakpoint().IsOneShot()) {
538 thread_sp->GetProcess()->GetTarget().RemoveBreakpointByID(
539 bp_loc_sp->GetBreakpoint().GetID());
546 actually_said_continue =
true;
565 "Process::%s could not find breakpoint site id: %" PRId64
571 thread_sp->CompletedPlanOverridesBreakpoint()) {
580 thread_sp->CalculatePublicStopInfo();
584 "Process::%s returning from action with m_should_stop: %d.",
616 const bool notify =
false;
625 bool was_disabled =
watchpoint_sp->IsDisabledDuringEphemeralMode();
627 const bool notify =
false;
685 thread_sp->CalculateTarget()->GetWatchpointList().FindByID(
696 "Process::%s could not find watchpoint location id: %" PRId64
727 thread_sp->CalculateTarget()->GetWatchpointList().FindByID(
739 bool wp_triggers_after;
741 if (process_sp->GetWatchpointSupportInfo(num, wp_triggers_after)
743 if (!wp_triggers_after) {
749 process_sp->DisableWatchpoint(wp,
false);
750 StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
751 assert(stored_stop_info_sp.get() ==
this);
754 ThreadPlanSP new_plan_sp(
755 thread_sp->QueueThreadPlanForStepSingleInstruction(
760 if (new_plan_sp && new_plan_status.
Success()) {
761 new_plan_sp->SetIsControllingPlan(
true);
762 new_plan_sp->SetOkayToDiscard(
false);
763 new_plan_sp->SetPrivate(
true);
765 process_sp->GetThreadList().SetSelectedThreadByID(
767 process_sp->ResumeSynchronous(
nullptr);
768 process_sp->GetThreadList().SetSelectedThreadByID(
770 thread_sp->SetStopInfo(stored_stop_info_sp);
771 process_sp->EnableWatchpoint(wp,
false);
797 WatchpointSP wp_hit_sp =
798 thread_sp->CalculateTarget()->GetWatchpointList().FindByAddress(
802 wp_sp->IncrementFalseAlarmsAndReviseHitCount();
816 if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount())
829 ValueObjectSP result_value_sp;
832 exe_ctx, expr_options, wp_sp->GetConditionText(),
833 llvm::StringRef(), result_value_sp,
error);
836 if (result_value_sp) {
838 if (result_value_sp->ResolveValue(scalar_value)) {
848 "Condition successfully evaluated, result is %s.\n",
854 "Failed to get an integer result from the expression.");
858 const char *err_str =
error.AsCString(
"<unknown error>");
859 LLDB_LOGF(log,
"Error evaluating condition: \"%s\"\n", err_str);
862 strm <<
"stopped due to an error evaluating condition of "
865 strm <<
": \"" << wp_sp->GetConditionText() <<
"\"\n";
886 bool stop_requested = wp_sp->InvokeCallback(&context);
902 wp_sp->CaptureWatchedValue(exe_ctx);
906 wp_sp->DumpSnapshots(output_sp.get());
915 "Process::%s could not find watchpoint id: %" PRId64
"...",
919 "Process::%s returning from action with m_should_stop: %d.",
948 return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(
m_value);
955 return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(
m_value);
964 thread_sp->GetProcess()->GetUnixSignals()->GetShouldNotify(
m_value);
968 "thread %d received signal: %s", thread_sp->GetIndexID(),
969 thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsCString(
974 return should_notify;
982 if (!thread_sp->GetProcess()->GetUnixSignals()->GetShouldSuppress(
984 thread_sp->SetResumeSignal(
m_value);
993 const char *signal_name =
994 thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsCString(
997 strm.
Printf(
"signal %s", signal_name);
1065 return "processor trace event";
1076 ExpressionVariableSP &expression_variable_sp)
1103 return m_plan_sp->ShouldStop(event_ptr);
1125 return thread_sp->GetProcess()->GetStopOnExec();
1141 thread_sp->GetProcess()->DidExec();
1237 thread_sp->GetProcess()->DidVForkDone();
1263 const char *description) {
1264 thread.
GetProcess()->GetUnixSignals()->IncrementSignalHitCount(signo);
1273 ThreadPlanSP &plan_sp, ValueObjectSP return_valobj_sp,
1274 ExpressionVariableSP expression_variable_sp) {
1276 expression_variable_sp));
1280 const char *description) {
1285 const char *description) {
1296 return StopInfoSP(
new StopInfoFork(thread, child_pid, child_tid));
1303 return StopInfoSP(
new StopInfoVFork(thread, child_pid, child_tid));
1317 return ValueObjectSP();
1327 return ExpressionVariableSP();
1333 if (!stop_info_sp) {
1334 return ValueObjectSP();
1337 const char *description = stop_info_sp->GetDescription();
1339 return ValueObjectSP();
1342 ThreadSP thread_sp = stop_info_sp->GetThread();
1344 return ValueObjectSP();
1347 StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
1350 return ValueObjectSP();
1353 const char address_string[] =
"address=";
1355 const char *address_loc = strstr(description, address_string);
1357 return ValueObjectSP();
1360 address_loc += (
sizeof(address_string) - 1);
1362 uint64_t address = strtoull(address_loc,
nullptr, 0);
1363 if (crashing_address) {
1364 *crashing_address = address;
1367 return frame_sp->GuessValueForAddress(address);