Fix DAC thread context flags (#42744)
authorMike McLaughlin <mikem@microsoft.com>
Sat, 26 Sep 2020 02:20:55 +0000 (19:20 -0700)
committerGitHub <noreply@github.com>
Sat, 26 Sep 2020 02:20:55 +0000 (19:20 -0700)
Fix DAC thread context flags

The CONTEXT_* flags doesn't have the proper architecture specific bit set for the cross-OS/cross-arch DAC/DBI.  This causes the thread contexts not to be copied correctly because of the way CORDbgCopyThreadContext (in coreclr\src\debug\shared\arm64\ primitives.cpp) masks/checks the context flags.

Fix x86 build: missing DT_CONTEXT_ALL

src/coreclr/src/debug/daccess/dacdbiimpl.cpp
src/coreclr/src/debug/daccess/reimpl.cpp
src/coreclr/src/debug/inc/dbgtargetcontext.h

index c0e0a23..5732a33 100644 (file)
@@ -5767,7 +5767,7 @@ void DacDbiInterfaceImpl::GetContext(VMPTR_Thread vmThread, DT_CONTEXT * pContex
     if (pFilterContext == NULL)
     {
         // If the filter context is NULL, then we use the true context of the thread.
-        pContextBuffer->ContextFlags = CONTEXT_ALL;
+        pContextBuffer->ContextFlags = DT_CONTEXT_ALL;
         HRESULT hr = m_pTarget->GetThreadContext(pThread->GetOSThreadId(),
                                                 pContextBuffer->ContextFlags,
                                                 sizeof(*pContextBuffer),
index 832522f..63beae0 100644 (file)
@@ -97,7 +97,7 @@ DacGetThreadContext(Thread* thread, T_CONTEXT* context)
 
     ULONG32 contextFlags;
 
-    contextFlags = CONTEXT_ALL;
+    contextFlags = DT_CONTEXT_ALL;
 
     HRESULT status =
         g_dacImpl->m_pTarget->
index c4640aa..f96a18c 100644 (file)
 #define DT_CONTEXT_SEGMENTS        (DT_CONTEXT_i386 | 0x00000004L)
 #define DT_CONTEXT_FLOATING_POINT  (DT_CONTEXT_i386 | 0x00000008L) // 387 state
 #define DT_CONTEXT_DEBUG_REGISTERS (DT_CONTEXT_i386 | 0x00000010L)
-
-#define DT_CONTEXT_FULL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_SEGMENTS)
 #define DT_CONTEXT_EXTENDED_REGISTERS  (DT_CONTEXT_i386 | 0x00000020L)
 
+#define DT_CONTEXT_FULL     (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_SEGMENTS)
+#define DT_CONTEXT_ALL      (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_SEGMENTS | DT_CONTEXT_FLOATING_POINT | DT_CONTEXT_DEBUG_REGISTERS | DT_CONTEXT_EXTENDED_REGISTERS)
+
 #define DT_MAXIMUM_SUPPORTED_EXTENSION     512
 
 typedef struct {