[Lldb-commits] [lldb] [lldb][Windows] Invalidate cached register values on thread stop (PR #192430)

via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 16 04:00:43 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Ayush Sahay (ayushsahay1837)

<details>
<summary>Changes</summary>

Invalidate cached values in register context data structures on every thread stop.

_NativeRegisterContextWindows::InvalidateAllRegisters_ performs no operation by default. Subclasses may override it to clear cached values within their register context data structures whenever a thread stops.

This change intends to set up the necessary infrastructure to support caching of the thread context in _NativeRegisterContextWindows_arm64_, which will improve read performance. Currently, the thread context is retrieved for every read or write operation.

---
Full diff: https://github.com/llvm/llvm-project/pull/192430.diff


2 Files Affected:

- (modified) lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h (+3) 
- (modified) lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp (+3) 


``````````diff
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
index 2b71f639d562e..d7d8a3a4d9c18 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
@@ -28,6 +28,9 @@ class NativeRegisterContextWindows
   // Explicitly defining it ensures the class remains constructible.
   NativeRegisterContextWindows() {}
 
+  // Invalidate cached values in register context data structures.
+  virtual void InvalidateAllRegisters() {}
+
 protected:
   lldb::thread_t GetThreadHandle() const;
 };
diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
index 8ad59cd1ece88..d76e9a51fdace 100644
--- a/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/NativeThreadWindows.cpp
@@ -38,6 +38,9 @@ Status NativeThreadWindows::DoStop() {
     if (previous_suspend_count == (DWORD)-1)
       return Status(::GetLastError(), eErrorTypeWin32);
 
+    // Invalidate cached register values on every stop.
+    GetRegisterContext().InvalidateAllRegisters();
+
     m_state = eStateStopped;
   }
   return Status();

``````````

</details>


https://github.com/llvm/llvm-project/pull/192430


More information about the lldb-commits mailing list