[Lldb-commits] [lldb] [LLDB] Use shared_ptr for m_current_private_state_thread (PR #188542)
Anshul Nigham via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 25 09:57:49 PDT 2026
https://github.com/nigham created https://github.com/llvm/llvm-project/pull/188542
None
>From 333d427672667cd31757ff462243ba48113a1378 Mon Sep 17 00:00:00 2001
From: Anshul Nigham <nigham at google.com>
Date: Wed, 25 Mar 2026 09:57:05 -0700
Subject: [PATCH] [LLDB] Use shared_ptr for m_current_private_state_thread
---
lldb/include/lldb/Target/Process.h | 2 +-
lldb/source/Target/Process.cpp | 11 ++++-------
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index e3ce5cd7c16ee..f751ceeea026a 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -3360,7 +3360,7 @@ void PruneThreadPlans();
///< state thread until you call StartupThread. This needs to be a pointer
///< so I can transparently swap it out for the modal one, but there will
///< always be a private state thread in this slot.
- PrivateStateThread *m_current_private_state_thread;
+ std::shared_ptr<PrivateStateThread> m_current_private_state_thread;
ProcessModID m_mod_id; ///< Tracks the state of the process over stops and
///other alterations.
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 587d9f6408ae4..f5fc02bdb204b 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -522,8 +522,6 @@ Process::~Process() {
// explicitly clear the thread list here to ensure that the mutex is not
// destroyed before the thread list.
m_thread_list.Clear();
- delete m_current_private_state_thread;
- m_current_private_state_thread = nullptr;
}
ProcessProperties &Process::GetGlobalProperties() {
@@ -3934,12 +3932,11 @@ bool Process::StartPrivateStateThread(lldb::StateType state,
}
if (is_secondary_thread) {
- PrivateStateThread *new_private_state_thread =
- new PrivateStateThread(*this, GetPublicState(), GetPrivateState(),
- is_secondary_thread, thread_name);
// StartupThread expects the m_current_private_state_thread to be in place
// already, so do that first:
- m_current_private_state_thread = new_private_state_thread;
+ m_current_private_state_thread.reset(
+ new PrivateStateThread(*this, GetPublicState(), GetPrivateState(),
+ is_secondary_thread, thread_name));
} else
m_current_private_state_thread->SetThreadName(thread_name);
@@ -5205,7 +5202,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
selected_tid = LLDB_INVALID_THREAD_ID;
}
- PrivateStateThread *backup_private_state_thread = nullptr;
+ std::shared_ptr<PrivateStateThread> backup_private_state_thread;
lldb::StateType old_state = eStateInvalid;
lldb::ThreadPlanSP stopper_base_plan_sp;
More information about the lldb-commits
mailing list