Skip to content

Commit b2c8247

Browse files
[release/9.0-staging] [debugger] Fix debugging a x86 app in mixed mode (#114077)
* Fixing get incomplete context information and assigning invalid information to the context later. * Fixing the copy and paste. * remove extra ; --------- Co-authored-by: Thays Grazia <[email protected]>
1 parent 703efd5 commit b2c8247

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/coreclr/debug/di/process.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13377,7 +13377,11 @@ void CordbProcess::HandleDebugEventForInteropDebugging(const DEBUG_EVENT * pEven
1337713377
{
1337813378
LOG((LF_CORDB, LL_INFO100000, "W32ET::W32EL: hijack complete will restore context...\n"));
1337913379
DT_CONTEXT tempContext = { 0 };
13380+
#ifdef TARGET_X86
13381+
tempContext.ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;
13382+
#else
1338013383
tempContext.ContextFlags = DT_CONTEXT_FULL;
13384+
#endif
1338113385
HRESULT hr = pUnmanagedThread->GetThreadContext(&tempContext);
1338213386
_ASSERTE(SUCCEEDED(hr));
1338313387

src/coreclr/debug/di/rsthread.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3721,9 +3721,15 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync()
37213721
LOG((LF_CORDB, LL_INFO10000, "CUT::SFCHFS: hijackCtx started as:\n"));
37223722
LogContext(GetHijackCtx());
37233723

3724-
// Save the thread's full context.
3724+
// Save the thread's full context for all platforms except for x86 because we need the
3725+
// DT_CONTEXT_EXTENDED_REGISTERS to avoid getting incomplete information and corrupt the thread context
37253726
DT_CONTEXT context;
3727+
#ifdef TARGET_X86
3728+
context.ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;
3729+
#else
37263730
context.ContextFlags = DT_CONTEXT_FULL;
3731+
#endif
3732+
37273733
BOOL succ = DbiGetThreadContext(m_handle, &context);
37283734
_ASSERTE(succ);
37293735
// for debugging when GetThreadContext fails
@@ -3733,7 +3739,12 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync()
37333739
LOG((LF_CORDB, LL_ERROR, "CUT::SFCHFS: DbiGetThreadContext error=0x%x\n", error));
37343740
}
37353741

3742+
#ifdef TARGET_X86
3743+
GetHijackCtx()->ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;
3744+
#else
37363745
GetHijackCtx()->ContextFlags = DT_CONTEXT_FULL;
3746+
#endif
3747+
37373748
CORDbgCopyThreadContext(GetHijackCtx(), &context);
37383749
LOG((LF_CORDB, LL_INFO10000, "CUT::SFCHFS: thread=0x%x Hijacking for sync. Original context is:\n", this));
37393750
LogContext(GetHijackCtx());

0 commit comments

Comments
 (0)