34 : m_thread_wp(thread.shared_from_this()),
35 m_stop_id(thread.GetProcess()->GetStopID()),
36 m_resume_id(thread.GetProcess()->GetResumeID()), m_value(value),
43 return thread_sp->GetProcess()->GetStopID() ==
m_stop_id;
50 m_stop_id = thread_sp->GetProcess()->GetStopID();
51 m_resume_id = thread_sp->GetProcess()->GetResumeID();
71 uint32_t curr_resume_id = thread_sp->GetProcess()->GetResumeID();
72 uint32_t last_user_expression_id =
73 thread_sp->GetProcess()->GetLastUserExpressionResumeID();
76 }
else if (curr_resume_id > last_user_expression_id) {
111 thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(
m_value));
113 uint32_t num_constituents = bp_site_sp->GetNumberOfConstituents();
114 if (num_constituents == 1) {
117 Breakpoint & bkpt = bp_loc_sp->GetBreakpoint();
124 for (uint32_t i = 0; i < num_constituents; i++) {
125 if (!bp_site_sp->GetConstituentAtIndex(i)
133 m_address = bp_site_sp->GetLoadAddress();
142 process_sp->GetBreakpointSiteList().FindByID(
m_value));
144 return bp_site_sp->ValidForThisThread(thread);
157 thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(
m_value));
161 bp_site_sp->BumpHitCounts();
167 "Process::%s could not find breakpoint site id: %" PRId64
189 thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(
m_value));
194 if (bp_site_sp->IsInternal()) {
195 size_t num_constituents = bp_site_sp->GetNumberOfConstituents();
196 for (
size_t idx = 0; idx < num_constituents; idx++) {
197 const char *kind = bp_site_sp->GetConstituentAtIndex(idx)
199 .GetBreakpointKind();
200 if (kind !=
nullptr) {
207 strm.
Printf(
"breakpoint ");
214 thread_sp->GetProcess()->GetTarget().GetBreakpointByID(
217 if (break_sp->IsInternal()) {
218 const char *kind = break_sp->GetBreakpointKind();
230 strm.
Printf(
"breakpoint %d which has been deleted.",
234 strm.
Printf(
"breakpoint site %" PRIi64
235 " which has been deleted - unknown address",
238 strm.
Printf(
"breakpoint site %" PRIi64
239 " which has been deleted - was at 0x%" PRIx64,
262 bool all_stopping_locs_internal =
true;
269 if (!thread_sp->IsValid()) {
272 LLDB_LOGF(log,
"PerformAction got called with an invalid thread.");
280 thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(
m_value));
281 std::unordered_set<break_id_t> precondition_breakpoints;
288 bool actually_hit_any_locations =
false;
294 size_t num_constituents =
295 bp_site_sp->CopyConstituentsList(site_locations);
297 if (num_constituents == 0) {
299 actually_hit_any_locations =
true;
325 bool async_should_stop =
false;
328 bool actually_said_continue =
false;
358 if (thread_sp->CompletedPlanOverridesBreakpoint()) {
360 thread_sp->ResetStopInfo();
364 LLDB_LOGF(log,
"StopInfoBreakpoint::PerformAction - Hit a "
365 "breakpoint while running an expression,"
366 " not running commands to avoid recursion.");
367 bool ignoring_breakpoints =
375 "StopInfoBreakpoint::PerformAction - in expression, "
379 "hit breakpoint while running function, skipping commands "
380 "and conditions to prevent recursion",
395 std::vector<lldb::BreakpointSP> location_constituents;
397 for (
size_t j = 0; j < num_constituents; j++) {
399 location_constituents.push_back(
400 loc->GetBreakpoint().shared_from_this());
403 for (
size_t j = 0; j < num_constituents; j++) {
411 if (!bp_loc_sp->IsEnabled() ||
412 !bp_loc_sp->GetBreakpoint().IsEnabled())
418 if (!bp_loc_sp->ValidForThisThread(*thread_sp)) {
421 "Breakpoint %s hit on thread 0x%llx but it was not "
422 "for this thread, continuing.",
424 static_cast<unsigned long long>(thread_sp->GetID()));
431 std::pair<std::unordered_set<break_id_t>::iterator,
bool> result =
432 precondition_breakpoints.insert(
433 bp_loc_sp->GetBreakpoint().GetID());
437 bool precondition_result =
438 bp_loc_sp->GetBreakpoint().EvaluatePrecondition(context);
439 if (!precondition_result) {
440 actually_said_continue =
true;
447 if (bp_loc_sp->GetConditionText() ==
nullptr)
448 actually_hit_any_locations =
true;
451 bool condition_says_stop =
452 bp_loc_sp->ConditionSaysStop(exe_ctx, condition_error);
454 if (!condition_error.
Success()) {
457 actually_hit_any_locations =
true;
458 const char *err_str =
459 condition_error.
AsCString(
"<unknown error>");
460 LLDB_LOGF(log,
"Error evaluating condition: \"%s\"\n", err_str);
463 strm <<
"stopped due to an error evaluating condition of "
466 strm <<
": \"" << bp_loc_sp->GetConditionText() <<
"\"\n";
474 "Condition evaluated for breakpoint %s on thread "
475 "0x%llx condition_says_stop: %i.",
477 static_cast<unsigned long long>(thread_sp->GetID()),
478 condition_says_stop);
479 if (condition_says_stop)
480 actually_hit_any_locations =
true;
485 bp_loc_sp->UndoBumpHitCount();
486 actually_said_continue =
true;
496 if (!bp_loc_sp->IgnoreCountShouldStop()) {
497 actually_said_continue =
true;
507 bool auto_continue_says_stop =
true;
508 if (bp_loc_sp->IsAutoContinue())
511 "Continuing breakpoint %s as AutoContinue was set.",
515 if (!bp_loc_sp->GetBreakpoint().IsInternal())
516 thread_sp->SetShouldReportStop(
eVoteYes);
517 auto_continue_says_stop =
false;
520 bool callback_says_stop =
true;
530 if (!bp_loc_sp->IsCallbackSynchronous()) {
531 Debugger &debugger = thread_sp->CalculateTarget()->GetDebugger();
535 callback_says_stop = bp_loc_sp->InvokeCallback(&context);
539 if (callback_says_stop && auto_continue_says_stop)
542 actually_said_continue =
true;
545 if (
m_should_stop && !bp_loc_sp->GetBreakpoint().IsInternal())
546 all_stopping_locs_internal =
false;
550 if (callback_says_stop && bp_loc_sp &&
551 bp_loc_sp->GetBreakpoint().IsOneShot()) {
552 thread_sp->GetProcess()->GetTarget().RemoveBreakpointByID(
553 bp_loc_sp->GetBreakpoint().GetID());
560 actually_said_continue =
true;
576 actually_hit_any_locations =
true;
580 "Process::%s could not find breakpoint site id: %" PRId64
586 thread_sp->CompletedPlanOverridesBreakpoint()) {
595 thread_sp->CalculatePublicStopInfo();
596 }
else if (!actually_hit_any_locations) {
600 LLDB_LOGF(log,
"Process::%s all locations failed condition checks.",
605 "Process::%s returning from action with m_should_stop: %d.",
637 const bool notify =
false;
646 bool was_disabled =
watchpoint_sp->IsDisabledDuringEphemeralMode();
648 const bool notify =
false;
710 bool current_plan)
override {
786 LLDB_LOG(log,
"We didn't run but stopped with a StopInfoWatchpoint, we "
787 "have already handled this one, don't do it again.");
794 thread_sp->CalculateTarget()->GetWatchpointList().FindByID(
GetValue()));
799 "Process::%s could not find watchpoint location id: %" PRId64
827 bool wp_triggers_after = process_sp->GetWatchpointReportedAfter();
829 if (!wp_triggers_after) {
832 = std::static_pointer_cast<StopInfoWatchpoint>(shared_from_this());
834 *(thread_sp.get()), me_as_siwp_sp, wp_sp));
837 step_over_wp_sp->SetIsControllingPlan(
true);
838 step_over_wp_sp->SetOkayToDiscard(
false);
841 error = thread_sp->QueueThreadPlan(step_over_wp_sp,
false);
843 if (!
error.Success()) {
844 LLDB_LOGF(log,
"Could not push our step over watchpoint plan: %s",
853 thread_sp->SetShouldRunBeforePublicStop(
true);
886 thread_sp->CalculateTarget()->GetWatchpointList().FindByID(
899 wp_sp->UndoHitCount();
902 if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount()) {
920 exe_ctx, expr_options, wp_sp->GetConditionText(),
921 llvm::StringRef(), result_value_sp,
error);
924 if (result_value_sp) {
926 if (result_value_sp->ResolveValue(scalar_value)) {
930 wp_sp->UndoHitCount();
935 "Condition successfully evaluated, result is %s.\n",
941 "Failed to get an integer result from the expression.");
945 const char *err_str =
error.AsCString(
"<unknown error>");
946 LLDB_LOGF(log,
"Error evaluating condition: \"%s\"\n", err_str);
949 strm <<
"stopped due to an error evaluating condition of "
952 strm <<
": \"" << wp_sp->GetConditionText() <<
"\"\n";
973 bool stop_requested = wp_sp->InvokeCallback(&context);
990 if (
m_should_stop && !wp_sp->WatchedValueReportable(exe_ctx)) {
991 wp_sp->UndoHitCount();
997 wp_sp->CaptureWatchedValue(exe_ctx);
1001 if (wp_sp->DumpSnapshots(output_sp.get())) {
1011 "Process::%s could not find watchpoint id: %" PRId64
"...",
1015 "Process::%s returning from action with m_should_stop: %d.",
1050 std::optional<int> code)
1062 return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(
m_value);
1069 return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(
m_value);
1077 bool should_notify =
1078 thread_sp->GetProcess()->GetUnixSignals()->GetShouldNotify(
m_value);
1079 if (should_notify) {
1082 "thread {0:d} received signal: {1}", thread_sp->GetIndexID(),
1083 thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsStringRef(
1088 return should_notify;
1096 if (!thread_sp->GetProcess()->GetUnixSignals()->GetShouldSuppress(
1098 thread_sp->SetResumeSignal(
m_value);
1106 UnixSignalsSP unix_signals = thread_sp->GetProcess()->GetUnixSignals();
1110 std::string signal_name =
1112 if (signal_name.size())
1113 strm << signal_name;
1209 return "processor trace event";
1247 return m_plan_sp->ShouldStop(event_ptr);
1269 return thread_sp->GetProcess()->GetStopOnExec();
1285 thread_sp->GetProcess()->DidExec();
1381 thread_sp->GetProcess()->DidVForkDone();
1404 bool silently_continue) {
1410 const char *description,
1411 std::optional<int> code) {
1412 thread.
GetProcess()->GetUnixSignals()->IncrementSignalHitCount(signo);
1417 const char *description) {
1429 expression_variable_sp));
1433 const char *description) {
1438 const char *description) {
1486 if (!stop_info_sp) {
1490 const char *description = stop_info_sp->GetDescription();
1495 ThreadSP thread_sp = stop_info_sp->GetThread();
1507 const char address_string[] =
"address=";
1509 const char *address_loc = strstr(description, address_string);
1514 address_loc += (
sizeof(address_string) - 1);
1516 uint64_t address = strtoull(address_loc,
nullptr, 0);
1517 if (crashing_address) {
1518 *crashing_address = address;
1521 return frame_sp->GuessValueForAddress(address);
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
lldb::BreakpointLocationSP GetByIndex(size_t i)
Returns a shared pointer to the breakpoint location with index i.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
bool IsOneShot() const
Check the OneShot state.
bool IsInternal() const
Tell whether this breakpoint is an "internal" breakpoint.
A class to manage flag bits.
lldb::StreamSP GetAsyncOutputStream()
void SetAsyncExecution(bool async)
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
void SetUnwindOnError(bool unwind=false)
void SetIgnoreBreakpoints(bool ignore=false)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
Target & GetTargetRef() const
Returns a reference to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
bool IsRunningExpression() const
bool GetIgnoreBreakpointsInExpressions() const
static void AddRestartedReason(Event *event_ptr, const char *reason)
A plug-in interface definition class for debugging a process.
const ProcessModID & GetModIDRef() const
Target & GetTarget()
Get the target object pointer for this module.
unsigned long long ULongLong(unsigned long long fail_value=0) const
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
bool Success() const
Test for success condition.
void PerformAction(Event *event_ptr) override
const char * GetDescription() override
bool ShouldStopSynchronous(Event *event_ptr) override
bool IsValidForOperatingSystemThread(Thread &thread) override
bool DoShouldNotify(Event *event_ptr) override
~StopInfoBreakpoint() override=default
StopInfoBreakpoint(Thread &thread, break_id_t break_id, bool should_stop)
bool m_should_perform_action
lldb::break_id_t m_break_id
StopInfoBreakpoint(Thread &thread, break_id_t break_id)
bool ShouldStop(Event *event_ptr) override
bool m_should_stop_is_valid
StopReason GetStopReason() const override
const char * GetDescription() override
~StopInfoException() override=default
StopInfoException(Thread &thread, const char *description)
StopReason GetStopReason() const override
~StopInfoExec() override=default
StopInfoExec(Thread &thread)
const char * GetDescription() override
StopReason GetStopReason() const override
void PerformAction(Event *event_ptr) override
bool ShouldStop(Event *event_ptr) override
void PerformAction(Event *event_ptr) override
bool ShouldStop(Event *event_ptr) override
StopReason GetStopReason() const override
StopInfoFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
~StopInfoFork() override=default
const char * GetDescription() override
StopInfoInterrupt(Thread &thread, int signo, const char *description)
const char * GetDescription() override
StopReason GetStopReason() const override
~StopInfoInterrupt() override=default
StopInfoProcessorTrace(Thread &thread, const char *description)
~StopInfoProcessorTrace() override=default
const char * GetDescription() override
StopReason GetStopReason() const override
ValueObjectSP m_return_valobj_sp
bool ShouldStop(Event *event_ptr) override
~StopInfoThreadPlan() override=default
ExpressionVariableSP m_expression_variable_sp
ExpressionVariableSP GetExpressionVariable()
const char * GetDescription() override
StopReason GetStopReason() const override
ValueObjectSP GetReturnValueObject()
StopInfoThreadPlan(ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ExpressionVariableSP &expression_variable_sp)
const char * GetDescription() override
~StopInfoTrace() override=default
StopReason GetStopReason() const override
StopInfoTrace(Thread &thread)
StopInfoUnixSignal(Thread &thread, int signo, const char *description, std::optional< int > code)
void WillResume(lldb::StateType resume_state) override
bool DoShouldNotify(Event *event_ptr) override
~StopInfoUnixSignal() override=default
const char * GetDescription() override
std::optional< int > m_code
bool ShouldStopSynchronous(Event *event_ptr) override
bool ShouldStop(Event *event_ptr) override
StopReason GetStopReason() const override
const char * GetDescription() override
~StopInfoVForkDone() override=default
bool ShouldStop(Event *event_ptr) override
StopInfoVForkDone(Thread &thread)
StopReason GetStopReason() const override
void PerformAction(Event *event_ptr) override
bool ShouldStop(Event *event_ptr) override
StopReason GetStopReason() const override
void PerformAction(Event *event_ptr) override
~StopInfoVFork() override=default
StopInfoVFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
const char * GetDescription() override
ThreadPlanStepOverWatchpoint(Thread &thread, StopInfoWatchpointSP stop_info_sp, WatchpointSP watch_sp)
StopInfoWatchpointSP m_stop_info_sp
bool DoPlanExplainsStop(Event *event_ptr) override
bool ShouldStop(Event *event_ptr) override
bool ShouldRunBeforePublicStop() override
bool DoWillResume(lldb::StateType resume_state, bool current_plan) override
WatchpointSP watchpoint_sp
WatchpointSentry(ProcessSP p_sp, WatchpointSP w_sp)
static bool SentryPreResumeAction(void *sentry_void)
~StopInfoWatchpoint() override=default
std::shared_ptr< StopInfoWatchpoint > StopInfoWatchpointSP
StopInfoWatchpoint(Thread &thread, break_id_t watch_id, bool silently_skip_wp)
const char * GetDescription() override
void PerformAction(Event *event_ptr) override
void SetStepOverPlanComplete()
bool ShouldStop(Event *event_ptr) override
bool m_using_step_over_plan
bool m_should_stop_is_valid
bool ShouldStopSynchronous(Event *event_ptr) override
bool m_step_over_plan_complete
StopReason GetStopReason() const override
std::string m_description
static lldb::StopInfoSP CreateStopReasonWithPlan(lldb::ThreadPlanSP &plan, lldb::ValueObjectSP return_valobj_sp, lldb::ExpressionVariableSP expression_variable_sp)
uint64_t GetValue() const
static lldb::ExpressionVariableSP GetExpressionVariable(lldb::StopInfoSP &stop_info_sp)
static lldb::ValueObjectSP GetReturnValueObject(lldb::StopInfoSP &stop_info_sp)
static lldb::StopInfoSP CreateStopReasonToTrace(Thread &thread)
static lldb::StopInfoSP CreateStopReasonVFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
static lldb::StopInfoSP CreateStopReasonWithInterrupt(Thread &thread, int signo, const char *description)
static lldb::StopInfoSP CreateStopReasonWithSignal(Thread &thread, int signo, const char *description=nullptr, std::optional< int > code=std::nullopt)
lldb::ThreadSP GetThread() const
static lldb::StopInfoSP CreateStopReasonFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
static lldb::StopInfoSP CreateStopReasonVForkDone(Thread &thread)
static lldb::StopInfoSP CreateStopReasonWithWatchpointID(Thread &thread, lldb::break_id_t watch_id, bool silently_continue=false)
virtual void SetDescription(const char *desc_cstr)
static lldb::StopInfoSP CreateStopReasonWithException(Thread &thread, const char *description)
static lldb::StopInfoSP CreateStopReasonWithBreakpointSiteID(Thread &thread, lldb::break_id_t break_id)
static lldb::ValueObjectSP GetCrashingDereference(lldb::StopInfoSP &stop_info_sp, lldb::addr_t *crashing_address=nullptr)
static lldb::StopInfoSP CreateStopReasonProcessorTrace(Thread &thread, const char *description)
static lldb::StopInfoSP CreateStopReasonWithExec(Thread &thread)
bool HasTargetRunSinceMe()
StopInfo(Thread &thread, uint64_t value)
lldb::ThreadWP m_thread_wp
virtual bool ShouldStop(Event *event_ptr)
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
lldb::break_id_t GetID() const
const char * GetData() const
llvm::StringRef GetString() const
void Format(const char *format, Args &&... args)
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
bool DoPlanExplainsStop(Event *event_ptr) override
bool MischiefManaged() override
bool ShouldStop(Event *event_ptr) override
Thread & GetThread()
Returns the Thread that is using this thread plan.
virtual lldb::StopInfoSP GetPrivateStopInfo(bool calculate=true)
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
lldb::ProcessSP GetProcess() const
static lldb::ExpressionResults Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, llvm::StringRef expr_cstr, llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp, Status &error, std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Evaluate one expression in the scratch context of the target passed in the exe_ctx and return its res...
#define LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_ADDRESS
@ DoNoSelectMostRelevantFrame
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
StateType
Process and Thread States.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
std::shared_ptr< lldb_private::Stream > StreamSP
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
ExpressionResults
The results of expression evaluation.
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
StopReason
Thread stop reasons.
@ eStopReasonPlanComplete
@ eStopReasonExec
Program was re-exec'ed.
@ eStopReasonInterrupt
Thread requested interrupt.
@ eStopReasonProcessorTrace
lldb::user_id_t GetID() const
Get accessor for the user ID.