[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 08:23:27 +01:00
|
|
|
//===-- ThreadPlan.cpp ----------------------------------------------------===//
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2015-12-15 01:33:19 +00:00
|
|
|
#include "lldb/Target/ThreadPlan.h"
|
2010-11-11 19:26:09 +00:00
|
|
|
#include "lldb/Core/Debugger.h"
|
|
|
|
|
#include "lldb/Target/Process.h"
|
2010-09-03 17:10:42 +00:00
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2010-11-11 19:26:09 +00:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-09-03 17:10:42 +00:00
|
|
|
#include "lldb/Target/Thread.h"
|
2022-02-03 13:26:10 +01:00
|
|
|
#include "lldb/Utility/LLDBLog.h"
|
2017-03-03 20:56:28 +00:00
|
|
|
#include "lldb/Utility/Log.h"
|
2018-08-07 11:07:21 +00:00
|
|
|
#include "lldb/Utility/State.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
// ThreadPlan constructor
|
2016-05-18 01:59:10 +00:00
|
|
|
ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
|
2021-02-17 15:09:50 -08:00
|
|
|
Vote report_stop_vote, Vote report_run_vote)
|
2020-03-18 12:05:08 -07:00
|
|
|
: m_process(*thread.GetProcess().get()), m_tid(thread.GetID()),
|
2021-02-17 15:09:50 -08:00
|
|
|
m_report_stop_vote(report_stop_vote), m_report_run_vote(report_run_vote),
|
2018-11-15 01:18:15 +00:00
|
|
|
m_takes_iteration_count(false), m_could_not_resolve_hw_bp(false),
|
2020-04-03 17:58:59 -07:00
|
|
|
m_thread(&thread), m_kind(kind), m_name(name), m_plan_complete_mutex(),
|
2016-05-18 01:59:10 +00:00
|
|
|
m_cached_plan_explains_stop(eLazyBoolCalculate), m_plan_complete(false),
|
2021-11-02 08:58:19 -05:00
|
|
|
m_plan_private(false), m_okay_to_discard(true),
|
|
|
|
|
m_is_controlling_plan(false), m_plan_succeeded(true) {
|
2016-05-18 01:59:10 +00:00
|
|
|
SetID(GetNextID());
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Destructor
|
2015-12-15 01:33:19 +00:00
|
|
|
ThreadPlan::~ThreadPlan() = default;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2020-03-10 16:18:11 -07:00
|
|
|
Target &ThreadPlan::GetTarget() { return m_process.GetTarget(); }
|
|
|
|
|
|
|
|
|
|
const Target &ThreadPlan::GetTarget() const { return m_process.GetTarget(); }
|
|
|
|
|
|
2020-03-10 14:03:53 -07:00
|
|
|
Thread &ThreadPlan::GetThread() {
|
|
|
|
|
if (m_thread)
|
|
|
|
|
return *m_thread;
|
2020-03-18 12:05:08 -07:00
|
|
|
|
2020-03-10 14:03:53 -07:00
|
|
|
ThreadSP thread_sp = m_process.GetThreadList().FindThreadByID(m_tid);
|
|
|
|
|
m_thread = thread_sp.get();
|
|
|
|
|
return *m_thread;
|
|
|
|
|
}
|
|
|
|
|
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 00:35:16 +00:00
|
|
|
bool ThreadPlan::PlanExplainsStop(Event *event_ptr) {
|
|
|
|
|
if (m_cached_plan_explains_stop == eLazyBoolCalculate) {
|
|
|
|
|
bool actual_value = DoPlanExplainsStop(event_ptr);
|
2021-02-07 20:16:48 -08:00
|
|
|
CachePlanExplainsStop(actual_value);
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 00:35:16 +00:00
|
|
|
return actual_value;
|
|
|
|
|
} else {
|
|
|
|
|
return m_cached_plan_explains_stop == eLazyBoolYes;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
bool ThreadPlan::IsPlanComplete() {
|
2016-05-18 01:59:10 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
|
2010-06-08 16:52:24 +00:00
|
|
|
return m_plan_complete;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-01 18:38:37 +00:00
|
|
|
void ThreadPlan::SetPlanComplete(bool success) {
|
2016-05-18 01:59:10 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
|
2010-06-08 16:52:24 +00:00
|
|
|
m_plan_complete = true;
|
2012-05-01 18:38:37 +00:00
|
|
|
m_plan_succeeded = success;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ThreadPlan::MischiefManaged() {
|
2016-05-18 01:59:10 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_plan_complete_mutex);
|
2012-05-10 01:35:39 +00:00
|
|
|
// Mark the plan is complete, but don't override the success flag.
|
2010-06-08 16:52:24 +00:00
|
|
|
m_plan_complete = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vote ThreadPlan::ShouldReportStop(Event *event_ptr) {
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Step);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2021-02-17 15:09:50 -08:00
|
|
|
if (m_report_stop_vote == eVoteNoOpinion) {
|
2010-06-08 16:52:24 +00:00
|
|
|
ThreadPlan *prev_plan = GetPreviousPlan();
|
|
|
|
|
if (prev_plan) {
|
2010-09-03 17:10:42 +00:00
|
|
|
Vote prev_vote = prev_plan->ShouldReportStop(event_ptr);
|
2017-02-03 18:50:45 +00:00
|
|
|
LLDB_LOG(log, "returning previous thread plan vote: {0}", prev_vote);
|
2010-09-03 17:10:42 +00:00
|
|
|
return prev_vote;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2021-02-17 15:09:50 -08:00
|
|
|
LLDB_LOG(log, "Returning vote: {0}", m_report_stop_vote);
|
|
|
|
|
return m_report_stop_vote;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vote ThreadPlan::ShouldReportRun(Event *event_ptr) {
|
2021-02-17 15:09:50 -08:00
|
|
|
if (m_report_run_vote == eVoteNoOpinion) {
|
2010-06-08 16:52:24 +00:00
|
|
|
ThreadPlan *prev_plan = GetPreviousPlan();
|
|
|
|
|
if (prev_plan)
|
|
|
|
|
return prev_plan->ShouldReportRun(event_ptr);
|
|
|
|
|
}
|
2021-02-17 15:09:50 -08:00
|
|
|
return m_report_run_vote;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-22 10:22:26 -08:00
|
|
|
void ThreadPlan::ClearThreadCache() { m_thread = nullptr; }
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
bool ThreadPlan::StopOthers() {
|
|
|
|
|
ThreadPlan *prev_plan;
|
|
|
|
|
prev_plan = GetPreviousPlan();
|
2015-12-15 01:33:19 +00:00
|
|
|
return (prev_plan == nullptr) ? false : prev_plan->StopOthers();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-30 02:22:11 +00:00
|
|
|
void ThreadPlan::SetStopOthers(bool new_value) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// SetStopOthers doesn't work up the hierarchy. You have to set the explicit
|
|
|
|
|
// ThreadPlan you want to affect.
|
2010-11-30 02:22:11 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
bool ThreadPlan::WillResume(StateType resume_state, bool current_plan) {
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 00:35:16 +00:00
|
|
|
m_cached_plan_explains_stop = eLazyBoolCalculate;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
if (current_plan) {
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Step);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
if (log) {
|
2020-03-10 14:03:53 -07:00
|
|
|
RegisterContext *reg_ctx = GetThread().GetRegisterContext().get();
|
2015-02-23 18:12:20 +00:00
|
|
|
assert(reg_ctx);
|
2010-09-03 17:10:42 +00:00
|
|
|
addr_t pc = reg_ctx->GetPC();
|
|
|
|
|
addr_t sp = reg_ctx->GetSP();
|
|
|
|
|
addr_t fp = reg_ctx->GetFP();
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(
|
|
|
|
|
log,
|
2013-06-22 00:27:45 +00:00
|
|
|
"%s Thread #%u (0x%p): tid = 0x%4.4" PRIx64 ", pc = 0x%8.8" PRIx64
|
|
|
|
|
", sp = 0x%8.8" PRIx64 ", fp = 0x%8.8" PRIx64 ", "
|
2012-03-01 00:50:50 +00:00
|
|
|
"plan = '%s', state = %s, stop others = %d",
|
2020-03-18 12:05:08 -07:00
|
|
|
__FUNCTION__, GetThread().GetIndexID(),
|
2020-03-10 14:03:53 -07:00
|
|
|
static_cast<void *>(&GetThread()), m_tid, static_cast<uint64_t>(pc),
|
2014-04-04 04:06:10 +00:00
|
|
|
static_cast<uint64_t>(sp), static_cast<uint64_t>(fp), m_name.c_str(),
|
|
|
|
|
StateAsCString(resume_state), StopOthers());
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2020-03-18 12:05:08 -07:00
|
|
|
bool success = DoWillResume(resume_state, current_plan);
|
2021-01-22 10:22:26 -08:00
|
|
|
ClearThreadCache(); // We don't cache the thread pointer over resumes. This
|
2020-03-18 12:05:08 -07:00
|
|
|
// Thread might go away, and another Thread represent
|
|
|
|
|
// the same underlying object on a later stop.
|
|
|
|
|
return success;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::user_id_t ThreadPlan::GetNextID() {
|
|
|
|
|
static uint32_t g_nextPlanID = 0;
|
|
|
|
|
return ++g_nextPlanID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ThreadPlan::DidPush() {}
|
|
|
|
|
|
2021-07-16 11:04:27 -07:00
|
|
|
void ThreadPlan::DidPop() {}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
bool ThreadPlan::OkayToDiscard() {
|
2021-11-02 08:58:19 -05:00
|
|
|
return IsControllingPlan() ? m_okay_to_discard : true;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-11 19:26:09 +00:00
|
|
|
lldb::StateType ThreadPlan::RunState() {
|
2021-02-13 15:48:05 -08:00
|
|
|
if (m_tracer_sp && m_tracer_sp->TracingEnabled())
|
2010-11-11 19:26:09 +00:00
|
|
|
return eStateStepping;
|
|
|
|
|
else
|
|
|
|
|
return GetPlanRunState();
|
|
|
|
|
}
|
2013-07-30 00:23:06 +00:00
|
|
|
|
2015-07-23 19:55:02 +00:00
|
|
|
bool ThreadPlan::IsUsuallyUnexplainedStopReason(lldb::StopReason reason) {
|
|
|
|
|
switch (reason) {
|
|
|
|
|
case eStopReasonWatchpoint:
|
|
|
|
|
case eStopReasonSignal:
|
|
|
|
|
case eStopReasonException:
|
|
|
|
|
case eStopReasonExec:
|
|
|
|
|
case eStopReasonThreadExiting:
|
|
|
|
|
case eStopReasonInstrumentation:
|
2023-01-12 14:04:57 +01:00
|
|
|
case eStopReasonFork:
|
|
|
|
|
case eStopReasonVFork:
|
|
|
|
|
case eStopReasonVForkDone:
|
New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (#90930)
This PR introduces a new `ThreadPlanSingleThreadTimeout` that will be
used to address potential deadlock during single-thread stepping.
While debugging a target with a non-trivial number of threads (around
5000 threads in one example target), we noticed that a simple step over
can take as long as 10 seconds. Enabling single-thread stepping mode
significantly reduces the stepping time to around 3 seconds. However,
this can introduce deadlock if we try to step over a method that depends
on other threads to release a lock.
To address this issue, we introduce a new
`ThreadPlanSingleThreadTimeout` that can be controlled by the
`target.process.thread.single-thread-plan-timeout` setting during
single-thread stepping mode. The concept involves counting the elapsed
time since the last internal stop to detect overall stepping progress.
Once a timeout occurs, we assume the target is not making progress due
to a potential deadlock, as mentioned above. We then send a new async
interrupt, resume all threads, and `ThreadPlanSingleThreadTimeout`
completes its task.
To support this design, the major changes made in this PR are:
1. `ThreadPlanSingleThreadTimeout` is popped during every internal stop
and reset (re-pushed) to the top of the stack (as a leaf node) during
resume. This is achieved by always returning `true` from
`ThreadPlanSingleThreadTimeout::DoPlanExplainsStop()` and
`ThreadPlanSingleThreadTimeout::MischiefManaged()`.
2. A new thread-specific async interrupt stop is introduced, which can
be detected/consumed by `ThreadPlanSingleThreadTimeout`.
3. The clearing of branch breakpoints in the range thread plan has been
moved from `DoPlanExplainsStop()` to `ShouldStop()`, as it is not
guaranteed that it will be called.
The detailed design is discussed in the RFC below:
[https://discourse.llvm.org/t/improve-single-thread-stepping/74599](https://discourse.llvm.org/t/improve-single-thread-stepping/74599)
---------
Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2024-08-05 17:26:39 -07:00
|
|
|
case eStopReasonInterrupt:
|
2015-07-23 19:55:02 +00:00
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-30 00:23:06 +00:00
|
|
|
// ThreadPlanNull
|
|
|
|
|
|
|
|
|
|
ThreadPlanNull::ThreadPlanNull(Thread &thread)
|
|
|
|
|
: ThreadPlan(ThreadPlan::eKindNull, "Null Thread Plan", thread,
|
|
|
|
|
eVoteNoOpinion, eVoteNoOpinion) {}
|
|
|
|
|
|
2015-12-15 01:33:19 +00:00
|
|
|
ThreadPlanNull::~ThreadPlanNull() = default;
|
2013-07-30 00:23:06 +00:00
|
|
|
|
|
|
|
|
void ThreadPlanNull::GetDescription(Stream *s, lldb::DescriptionLevel level) {
|
|
|
|
|
s->PutCString("Null thread plan - thread has been destroyed.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ThreadPlanNull::ValidatePlan(Stream *error) {
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
2013-08-07 19:05:15 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
|
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#else
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Thread);
|
2013-07-30 00:23:06 +00:00
|
|
|
if (log)
|
2013-08-07 19:05:15 +00:00
|
|
|
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#endif
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ThreadPlanNull::ShouldStop(Event *event_ptr) {
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
2013-08-07 19:05:15 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
|
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#else
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Thread);
|
2013-07-30 00:23:06 +00:00
|
|
|
if (log)
|
2013-08-07 19:05:15 +00:00
|
|
|
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#endif
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ThreadPlanNull::WillStop() {
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
2013-08-07 19:05:15 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
|
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#else
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Thread);
|
2013-07-30 00:23:06 +00:00
|
|
|
if (log)
|
2013-08-07 19:05:15 +00:00
|
|
|
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#endif
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ThreadPlanNull::DoPlanExplainsStop(Event *event_ptr) {
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
2013-08-07 19:05:15 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
|
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-04-03 19:49:07 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, GetThread().GetID(), GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#else
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Thread);
|
2013-07-30 00:23:06 +00:00
|
|
|
if (log)
|
2013-08-07 19:05:15 +00:00
|
|
|
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#endif
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The null plan is never done.
|
|
|
|
|
bool ThreadPlanNull::MischiefManaged() {
|
|
|
|
|
// The null plan is never done.
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
2013-08-07 19:05:15 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
|
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#else
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Thread);
|
2013-07-30 00:23:06 +00:00
|
|
|
if (log)
|
2013-08-07 19:05:15 +00:00
|
|
|
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#endif
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::StateType ThreadPlanNull::GetPlanRunState() {
|
|
|
|
|
// Not sure what to return here. This is a dead thread.
|
|
|
|
|
#ifdef LLDB_CONFIGURATION_DEBUG
|
2013-08-07 19:05:15 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
|
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#else
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Thread);
|
2013-07-30 00:23:06 +00:00
|
|
|
if (log)
|
2013-08-07 19:05:15 +00:00
|
|
|
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
|
|
|
|
|
", ptid = 0x%" PRIx64 ")",
|
2020-03-10 14:03:53 -07:00
|
|
|
LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
|
2013-07-30 00:23:06 +00:00
|
|
|
#endif
|
|
|
|
|
return eStateRunning;
|
|
|
|
|
}
|