[Lldb-commits] [lldb] 83be200 - [NFC][lldb] move m_stop_info and m_stop_description up a class (#201858)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 8 04:45:48 PDT 2026
Author: Charles Zablit
Date: 2026-06-08T12:45:43+01:00
New Revision: 83be200f418f8581f30415b0315d105965a63727
URL: https://github.com/llvm/llvm-project/commit/83be200f418f8581f30415b0315d105965a63727
DIFF: https://github.com/llvm/llvm-project/commit/83be200f418f8581f30415b0315d105965a63727.diff
LOG: [NFC][lldb] move m_stop_info and m_stop_description up a class (#201858)
Now that Windows also clears stale thread info on resume
(https://github.com/llvm/llvm-project/pull/201595), `m_stop_description`
and `m_stop_info` can be moved into `NativeThreadProtocol`.
rdar://178725507
Added:
Modified:
lldb/include/lldb/Host/common/NativeThreadProtocol.h
lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp
lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h
lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.h
Removed:
################################################################################
diff --git a/lldb/include/lldb/Host/common/NativeThreadProtocol.h b/lldb/include/lldb/Host/common/NativeThreadProtocol.h
index 35ccc48d62d8f..1bd16cfa26c1e 100644
--- a/lldb/include/lldb/Host/common/NativeThreadProtocol.h
+++ b/lldb/include/lldb/Host/common/NativeThreadProtocol.h
@@ -10,6 +10,7 @@
#define LLDB_HOST_COMMON_NATIVETHREADPROTOCOL_H
#include <memory>
+#include <string>
#include "lldb/Host/Debug.h"
#include "lldb/Utility/UnimplementedError.h"
@@ -57,8 +58,15 @@ class NativeThreadProtocol {
}
protected:
+ void ClearStopInfo() {
+ m_stop_info = ThreadStopInfo();
+ m_stop_description.clear();
+ }
+
NativeProcessProtocol &m_process;
lldb::tid_t m_tid;
+ ThreadStopInfo m_stop_info = {};
+ std::string m_stop_description;
};
}
diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp
index b50fc2509796e..9f7126de38363 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.cpp
@@ -35,11 +35,9 @@ using namespace lldb_private::process_freebsd;
NativeThreadFreeBSD::NativeThreadFreeBSD(NativeProcessFreeBSD &process,
lldb::tid_t tid)
: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
- m_stop_info(),
m_reg_context_up(
NativeRegisterContextFreeBSD::CreateHostNativeRegisterContextFreeBSD(
- process.GetArchitecture(), *this)),
- m_stop_description() {}
+ process.GetArchitecture(), *this)) {}
Status NativeThreadFreeBSD::Resume() {
Status ret = NativeProcessFreeBSD::PtraceWrapper(PT_RESUME, GetID());
@@ -171,12 +169,12 @@ void NativeThreadFreeBSD::SetStopped() {
void NativeThreadFreeBSD::SetRunning() {
m_state = StateType::eStateRunning;
- m_stop_info.reason = StopReason::eStopReasonNone;
+ ClearStopInfo();
}
void NativeThreadFreeBSD::SetStepping() {
m_state = StateType::eStateStepping;
- m_stop_info.reason = StopReason::eStopReasonNone;
+ ClearStopInfo();
}
std::string NativeThreadFreeBSD::GetName() {
diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h b/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h
index edfb07658e19c..12699da9e15d4 100644
--- a/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h
+++ b/lldb/source/Plugins/Process/FreeBSD/NativeThreadFreeBSD.h
@@ -76,9 +76,7 @@ class NativeThreadFreeBSD : public NativeThreadProtocol {
// Member Variables
lldb::StateType m_state;
- ThreadStopInfo m_stop_info;
std::unique_ptr<NativeRegisterContextFreeBSD> m_reg_context_up;
- std::string m_stop_description;
using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
WatchpointIndexMap m_watchpoint_index_map;
WatchpointIndexMap m_hw_break_index_map;
diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
index 96f54d63bc2a8..4c167fda2748b 100644
--- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -95,11 +95,9 @@ void LogThreadStopInfo(Log &log, const ThreadStopInfo &stop_info,
NativeThreadLinux::NativeThreadLinux(NativeProcessLinux &process,
lldb::tid_t tid)
: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
- m_stop_info(),
m_reg_context_up(
NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
- process.GetArchitecture(), *this)),
- m_stop_description() {}
+ process.GetArchitecture(), *this)) {}
std::string NativeThreadLinux::GetName() {
NativeProcessLinux &process = GetProcess();
@@ -214,8 +212,7 @@ Status NativeThreadLinux::Resume(uint32_t signo) {
MaybeLogStateChange(new_state);
m_state = new_state;
- m_stop_info.reason = StopReason::eStopReasonNone;
- m_stop_description.clear();
+ ClearStopInfo();
// If watchpoints have been set, but none on this thread, then this is a new
// thread. So set all existing watchpoints.
@@ -255,7 +252,7 @@ Status NativeThreadLinux::SingleStep(uint32_t signo) {
const StateType new_state = StateType::eStateStepping;
MaybeLogStateChange(new_state);
m_state = new_state;
- m_stop_info.reason = StopReason::eStopReasonNone;
+ ClearStopInfo();
if(!m_step_workaround) {
// If we already hava a workaround inplace, don't reset it. Otherwise, the
diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
index 1051c3ab68bf1..10036d5317a34 100644
--- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
+++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
@@ -114,9 +114,7 @@ class NativeThreadLinux : public NativeThreadProtocol {
// Member Variables
lldb::StateType m_state;
- ThreadStopInfo m_stop_info;
std::unique_ptr<NativeRegisterContextLinux> m_reg_context_up;
- std::string m_stop_description;
using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
WatchpointIndexMap m_watchpoint_index_map;
WatchpointIndexMap m_hw_break_index_map;
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
index e8c53714ec0c7..08e874ab90b73 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -36,9 +36,9 @@ using namespace lldb_private::process_netbsd;
NativeThreadNetBSD::NativeThreadNetBSD(NativeProcessNetBSD &process,
lldb::tid_t tid)
: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
- m_stop_info(), m_reg_context_up(
-NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD(process.GetArchitecture(), *this)
-), m_stop_description() {}
+ m_reg_context_up(
+ NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD(
+ process.GetArchitecture(), *this)) {}
Status NativeThreadNetBSD::Resume() {
Status ret = NativeProcessNetBSD::PtraceWrapper(PT_RESUME, m_process.GetID(),
@@ -170,12 +170,12 @@ void NativeThreadNetBSD::SetStopped() {
void NativeThreadNetBSD::SetRunning() {
m_state = StateType::eStateRunning;
- m_stop_info.reason = StopReason::eStopReasonNone;
+ ClearStopInfo();
}
void NativeThreadNetBSD::SetStepping() {
m_state = StateType::eStateStepping;
- m_stop_info.reason = StopReason::eStopReasonNone;
+ ClearStopInfo();
}
std::string NativeThreadNetBSD::GetName() {
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
index ee9305337fda9..2a518c3e12100 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
+++ b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
@@ -71,9 +71,7 @@ class NativeThreadNetBSD : public NativeThreadProtocol {
// Member Variables
lldb::StateType m_state;
- ThreadStopInfo m_stop_info;
std::unique_ptr<NativeRegisterContextNetBSD> m_reg_context_up;
- std::string m_stop_description;
using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
WatchpointIndexMap m_watchpoint_index_map;
WatchpointIndexMap m_hw_break_index_map;
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
index f021d435efa9b..be2a557bfa27a 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
@@ -27,7 +27,7 @@ using namespace lldb_private;
NativeThreadWindows::NativeThreadWindows(NativeProcessWindows &process,
const HostThread &thread)
: NativeThreadProtocol(process, thread.GetNativeThread().GetThreadId()),
- m_stop_info(), m_stop_description(), m_host_thread(thread) {
+ m_host_thread(thread) {
m_reg_context_up =
(NativeRegisterContextWindows::CreateHostNativeRegisterContextWindows(
process.GetArchitecture(), *this));
@@ -82,9 +82,7 @@ Status NativeThreadWindows::DoResume(lldb::StateType resume_state) {
if (resume_state == eStateStepping || resume_state == eStateRunning) {
// Clear any stop info left over from a previous stop.
- m_stop_info = ThreadStopInfo();
- m_stop_info.reason = lldb::eStopReasonNone;
- m_stop_description.clear();
+ ClearStopInfo();
DWORD previous_suspend_count = 0;
HANDLE thread_handle = m_host_thread.GetNativeThread().GetSystemHandle();
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.h b/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.h
index 0c965665227db..392a5b9a2a7d4 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.h
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.h
@@ -55,8 +55,6 @@ class NativeThreadWindows : public NativeThreadProtocol {
protected:
lldb::StateType m_state = lldb::StateType::eStateInvalid;
std::string m_name;
- ThreadStopInfo m_stop_info;
- std::string m_stop_description;
std::unique_ptr<NativeRegisterContextWindows> m_reg_context_up;
// Cache address and index of the watchpoints and hardware breakpoints since
// the register context does not.
More information about the lldb-commits
mailing list