From cd4cc97e4c099f637061afe2b6c546483ffd3073 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Fri, 25 Sep 2020 19:20:55 -0700 Subject: [PATCH] Fix DAC thread context flags (#42744) 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 | 2 +- src/coreclr/src/debug/daccess/reimpl.cpp | 2 +- src/coreclr/src/debug/inc/dbgtargetcontext.h | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/coreclr/src/debug/daccess/dacdbiimpl.cpp b/src/coreclr/src/debug/daccess/dacdbiimpl.cpp index c0e0a23..5732a33 100644 --- a/src/coreclr/src/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/src/debug/daccess/dacdbiimpl.cpp @@ -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), diff --git a/src/coreclr/src/debug/daccess/reimpl.cpp b/src/coreclr/src/debug/daccess/reimpl.cpp index 832522f..63beae0 100644 --- a/src/coreclr/src/debug/daccess/reimpl.cpp +++ b/src/coreclr/src/debug/daccess/reimpl.cpp @@ -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-> diff --git a/src/coreclr/src/debug/inc/dbgtargetcontext.h b/src/coreclr/src/debug/inc/dbgtargetcontext.h index c4640aa..f96a18c 100644 --- a/src/coreclr/src/debug/inc/dbgtargetcontext.h +++ b/src/coreclr/src/debug/inc/dbgtargetcontext.h @@ -60,10 +60,11 @@ #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 { -- 2.7.4