[Lldb-commits] [lldb] 4528666 - [lldb][Windows][NFC] Factor out NativeThreadWindows::SetSingleStepFlag (#231488)

via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 14 04:15:41 PDT 2026


Author: Charles Zablit
Date: 2026-10-14T12:15:35+01:00
New Revision: 4528666d710e2315da2604f2fc39f4aa68630557

URL: https://github.com/llvm/llvm-project/commit/4528666d710e2315da2604f2fc39f4aa68630557
DIFF: https://github.com/llvm/llvm-project/commit/4528666d710e2315da2604f2fc39f4aa68630557.diff

LOG: [lldb][Windows][NFC] Factor out NativeThreadWindows::SetSingleStepFlag (#231488)

Move the code that sets the trace flag out of `DoResume` so it can be
reused by llvm#227353.

Added: 
    

Modified: 
    lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
    lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
index f7d2b06f0f58d..eeba7d186e34b 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
@@ -51,31 +51,8 @@ Status NativeThreadWindows::DoResume(lldb::StateType resume_state) {
   if (resume_state == current_state)
     return Status();
 
-  if (resume_state == eStateStepping) {
-    Log *log = GetLog(LLDBLog::Thread);
-
-    uint32_t flags_index =
-        GetRegisterContext().ConvertRegisterKindToRegisterNumber(
-            eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
-    uint64_t flags_value =
-        GetRegisterContext().ReadRegisterAsUnsigned(flags_index, 0);
-    const ArchSpec &arch = GetProcess().GetArchitecture();
-    switch (arch.GetMachine()) {
-    case llvm::Triple::x86:
-    case llvm::Triple::x86_64:
-      flags_value |= 0x100; // Set the trap flag on the CPU
-      break;
-    case llvm::Triple::aarch64:
-    case llvm::Triple::arm:
-    case llvm::Triple::thumb:
-      flags_value |= 0x200000; // The SS bit in PState
-      break;
-    default:
-      LLDB_LOG(log, "single stepping unsupported on this architecture");
-      break;
-    }
-    GetRegisterContext().WriteRegisterFromUnsigned(flags_index, flags_value);
-  }
+  if (resume_state == eStateStepping)
+    SetSingleStepFlag();
 
   if (resume_state == eStateStepping || resume_state == eStateRunning) {
     // Clear any stop info left over from a previous stop.
@@ -101,6 +78,32 @@ Status NativeThreadWindows::DoResume(lldb::StateType resume_state) {
   return Status();
 }
 
+void NativeThreadWindows::SetSingleStepFlag() {
+  Log *log = GetLog(LLDBLog::Thread);
+
+  uint32_t flags_index =
+      GetRegisterContext().ConvertRegisterKindToRegisterNumber(
+          eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
+  uint64_t flags_value =
+      GetRegisterContext().ReadRegisterAsUnsigned(flags_index, 0);
+  const ArchSpec &arch = GetProcess().GetArchitecture();
+  switch (arch.GetMachine()) {
+  case llvm::Triple::x86:
+  case llvm::Triple::x86_64:
+    flags_value |= 0x100; // Set the trap flag on the CPU
+    break;
+  case llvm::Triple::aarch64:
+  case llvm::Triple::arm:
+  case llvm::Triple::thumb:
+    flags_value |= 0x200000; // The SS bit in PState
+    break;
+  default:
+    LLDB_LOG(log, "single stepping unsupported on this architecture");
+    break;
+  }
+  GetRegisterContext().WriteRegisterFromUnsigned(flags_index, flags_value);
+}
+
 std::string NativeThreadWindows::GetName() {
   Log *log = GetLog(LLDBLog::Thread);
   static LazyImport<HRESULT(WINAPI *)(HANDLE, PWSTR *)>

diff  --git a/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.h b/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.h
index 536ace3384c72..c594ae0363741 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.h
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.h
@@ -33,6 +33,8 @@ class NativeThreadWindows : public NativeThreadProtocol {
 
   void ClearSingleStepping() { m_single_stepping = false; }
 
+  void SetSingleStepFlag();
+
   std::string GetName() override;
 
   lldb::StateType GetState() override { return m_state; }


        


More information about the lldb-commits mailing list