[Lldb-commits] [lldb] [lldb][Windows] Read/Write PC after suspending thread (PR #191371)
Ayush Sahay via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 10 03:00:15 PDT 2026
ayushsahay1837 wrote:
> I guess that we get away with it 99% of the time because the thread is stopped at the breakpoint, but Windows itself could still be updating things in the thread context?
>
> Which also implies that this is not something we can trigger in a test. It comes down to what the OS decides to do, and it seems like most of the time it lets us get away with this.
That's correct. Per Microsoft's documentation, we can't get a valid context for a running thread and must suspend the thread before calling [GetThreadContext](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreadcontext)/[SetThreadContext](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadcontext).
This was discovered while implementing support for caching the thread context in _NativeRegisterContextWindows_arm64_ to improve read performance. Currently, we retrieve the thread context for each read or write operation.
https://github.com/llvm/llvm-project/pull/191371
More information about the lldb-commits
mailing list