Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/coreclr/debug/di/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13377,7 +13377,11 @@ void CordbProcess::HandleDebugEventForInteropDebugging(const DEBUG_EVENT * pEven
{
LOG((LF_CORDB, LL_INFO100000, "W32ET::W32EL: hijack complete will restore context...\n"));
DT_CONTEXT tempContext = { 0 };
#ifdef TARGET_X86
tempContext.ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;
#else
tempContext.ContextFlags = DT_CONTEXT_FULL;
#endif
HRESULT hr = pUnmanagedThread->GetThreadContext(&tempContext);
_ASSERTE(SUCCEEDED(hr));

Expand Down
13 changes: 12 additions & 1 deletion src/coreclr/debug/di/rsthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3721,9 +3721,15 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync()
LOG((LF_CORDB, LL_INFO10000, "CUT::SFCHFS: hijackCtx started as:\n"));
LogContext(GetHijackCtx());

// Save the thread's full context.
// Save the thread's full context for all platforms except for x86 because we need the
// DT_CONTEXT_EXTENDED_REGISTERS to avoid getting incomplete information and corrupt the thread context
DT_CONTEXT context;
#ifdef TARGET_X86
context.ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;
#else
context.ContextFlags = DT_CONTEXT_FULL;
#endif

BOOL succ = DbiGetThreadContext(m_handle, &context);
_ASSERTE(succ);
// for debugging when GetThreadContext fails
Expand All @@ -3733,7 +3739,12 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync()
LOG((LF_CORDB, LL_ERROR, "CUT::SFCHFS: DbiGetThreadContext error=0x%x\n", error));
}

#ifdef TARGET_X86
GetHijackCtx()->ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;
#else
GetHijackCtx()->ContextFlags = DT_CONTEXT_FULL;
#endif

CORDbgCopyThreadContext(GetHijackCtx(), &context);
LOG((LF_CORDB, LL_INFO10000, "CUT::SFCHFS: thread=0x%x Hijacking for sync. Original context is:\n", this));
LogContext(GetHijackCtx());
Expand Down
Loading