aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Target/ThreadPlanStack.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-03-20 11:40:34 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-05-14 11:43:05 +0000
commit349cc55c9796c4596a5b9904cd3281af295f878f (patch)
tree410c5a785075730a35f1272ca6a7adf72222ad03 /contrib/llvm-project/lldb/source/Target/ThreadPlanStack.cpp
parentcb2ae6163174b90e999326ecec3699ee093a5d43 (diff)
parentc0981da47d5696fe36474fcf86b4ce03ae3ff818 (diff)
Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-14-init-10186-gff7f2cfa959b. PR: 261742 MFC after: 2 weeks
Diffstat (limited to 'contrib/llvm-project/lldb/source/Target/ThreadPlanStack.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Target/ThreadPlanStack.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/contrib/llvm-project/lldb/source/Target/ThreadPlanStack.cpp b/contrib/llvm-project/lldb/source/Target/ThreadPlanStack.cpp
index d25602d25b91..f09583cc50cc 100644
--- a/contrib/llvm-project/lldb/source/Target/ThreadPlanStack.cpp
+++ b/contrib/llvm-project/lldb/source/Target/ThreadPlanStack.cpp
@@ -150,10 +150,13 @@ lldb::ThreadPlanSP ThreadPlanStack::PopPlan() {
std::lock_guard<std::recursive_mutex> guard(m_stack_mutex);
assert(m_plans.size() > 1 && "Can't pop the base thread plan");
- lldb::ThreadPlanSP plan_sp = std::move(m_plans.back());
- m_completed_plans.push_back(plan_sp);
- plan_sp->WillPop();
+ // Note that moving the top element of the vector would leave it in an
+ // undefined state, and break the guarantee that the stack's thread plans are
+ // all valid.
+ lldb::ThreadPlanSP plan_sp = m_plans.back();
m_plans.pop_back();
+ m_completed_plans.push_back(plan_sp);
+ plan_sp->DidPop();
return plan_sp;
}
@@ -161,10 +164,13 @@ lldb::ThreadPlanSP ThreadPlanStack::DiscardPlan() {
std::lock_guard<std::recursive_mutex> guard(m_stack_mutex);
assert(m_plans.size() > 1 && "Can't discard the base thread plan");
- lldb::ThreadPlanSP plan_sp = std::move(m_plans.back());
- m_discarded_plans.push_back(plan_sp);
- plan_sp->WillPop();
+ // Note that moving the top element of the vector would leave it in an
+ // undefined state, and break the guarantee that the stack's thread plans are
+ // all valid.
+ lldb::ThreadPlanSP plan_sp = m_plans.back();
m_plans.pop_back();
+ m_discarded_plans.push_back(plan_sp);
+ plan_sp->DidPop();
return plan_sp;
}
@@ -207,35 +213,35 @@ void ThreadPlanStack::DiscardAllPlans() {
return;
}
-void ThreadPlanStack::DiscardConsultingMasterPlans() {
+void ThreadPlanStack::DiscardConsultingControllingPlans() {
std::lock_guard<std::recursive_mutex> guard(m_stack_mutex);
while (true) {
- int master_plan_idx;
+ int controlling_plan_idx;
bool discard = true;
- // Find the first master plan, see if it wants discarding, and if yes
+ // Find the first controlling plan, see if it wants discarding, and if yes
// discard up to it.
- for (master_plan_idx = m_plans.size() - 1; master_plan_idx >= 0;
- master_plan_idx--) {
- if (m_plans[master_plan_idx]->IsMasterPlan()) {
- discard = m_plans[master_plan_idx]->OkayToDiscard();
+ for (controlling_plan_idx = m_plans.size() - 1; controlling_plan_idx >= 0;
+ controlling_plan_idx--) {
+ if (m_plans[controlling_plan_idx]->IsControllingPlan()) {
+ discard = m_plans[controlling_plan_idx]->OkayToDiscard();
break;
}
}
- // If the master plan doesn't want to get discarded, then we're done.
+ // If the controlling plan doesn't want to get discarded, then we're done.
if (!discard)
return;
// First pop all the dependent plans:
- for (int i = m_plans.size() - 1; i > master_plan_idx; i--) {
+ for (int i = m_plans.size() - 1; i > controlling_plan_idx; i--) {
DiscardPlan();
}
- // Now discard the master plan itself.
+ // Now discard the controlling plan itself.
// The bottom-most plan never gets discarded. "OkayToDiscard" for it
// means discard it's dependent plans, but not it...
- if (master_plan_idx > 0) {
+ if (controlling_plan_idx > 0) {
DiscardPlan();
}
}