Skip to content

Commit 23c9717

Browse files
Fix issues are stackwalking, and viewing Exception stack walks in the debugger (#115405)
* Fix issue where SoftwareExceptionFrame on non EH Funclet model X86 was mishandled by the DAC * Fix issue where EH stack traces aren't properly visible in the debugger
1 parent db0da94 commit 23c9717

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/coreclr/vm/excep.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11341,7 +11341,7 @@ void SoftwareExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool u
1134111341
pRD->IsCallerContextValid = FALSE;
1134211342
pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary.
1134311343
#elif defined(TARGET_X86)
11344-
#define CALLEE_SAVED_REGISTER(regname) pRD->Set##regname##Location(m_ContextPointers.regname);
11344+
#define CALLEE_SAVED_REGISTER(regname) pRD->Set##regname##Location(&m_Context.regname);
1134511345
ENUM_CALLEE_SAVED_REGISTERS();
1134611346
#undef CALLEE_SAVED_REGISTER
1134711347

@@ -11366,6 +11366,7 @@ void SoftwareExceptionFrame::UpdateContextFromTransitionBlock(TransitionBlock *p
1136611366
m_Context.Eax = 0;
1136711367
m_Context.Ecx = pTransitionBlock->m_argumentRegisters.ECX;
1136811368
m_Context.Edx = pTransitionBlock->m_argumentRegisters.EDX;
11369+
#ifdef FEATURE_EH_FUNCLETS
1136911370
m_ContextPointers.Ecx = &m_Context.Ecx;
1137011371
m_ContextPointers.Edx = &m_Context.Edx;
1137111372

@@ -11374,6 +11375,12 @@ void SoftwareExceptionFrame::UpdateContextFromTransitionBlock(TransitionBlock *p
1137411375
m_ContextPointers.reg = &m_Context.reg;
1137511376
ENUM_CALLEE_SAVED_REGISTERS();
1137611377
#undef CALLEE_SAVED_REGISTER
11378+
#else // FEATURE_EH_FUNCLETS
11379+
#define CALLEE_SAVED_REGISTER(reg) \
11380+
m_Context.reg = pTransitionBlock->m_calleeSavedRegisters.reg;
11381+
ENUM_CALLEE_SAVED_REGISTERS();
11382+
#undef CALLEE_SAVED_REGISTER
11383+
#endif // FEATURE_EH_FUNCLETS
1137711384

1137811385
m_Context.Esp = (UINT_PTR)(pTransitionBlock + 1);
1137911386
m_Context.Eip = pTransitionBlock->m_ReturnAddress;

src/coreclr/vm/frames.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,9 @@ typedef DPTR(class SoftwareExceptionFrame) PTR_SoftwareExceptionFrame;
10401040
class SoftwareExceptionFrame : public Frame
10411041
{
10421042
TADDR m_ReturnAddress;
1043+
#if !defined(TARGET_X86) || defined(FEATURE_EH_FUNCLETS)
10431044
T_KNONVOLATILE_CONTEXT_POINTERS m_ContextPointers;
1045+
#endif
10441046
// This T_CONTEXT field needs to be the last field in the class because it is a
10451047
// different size between Linux (pal.h) and the Windows cross-DAC (winnt.h).
10461048
T_CONTEXT m_Context;

src/coreclr/vm/object.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,11 @@ class ExceptionObject : public Object
22682268

22692269
void GetStackTrace(StackTraceArray & stackTrace, PTRARRAYREF * outKeepaliveArray = NULL) const
22702270
{
2271+
#ifdef DACCESS_COMPILE
2272+
return GetStackTrace(stackTrace, outKeepaliveArray, NULL);
2273+
#else
22712274
return GetStackTrace(stackTrace, outKeepaliveArray, GetThread());
2275+
#endif // DACCESS_COMPILE
22722276
}
22732277

22742278
private:

0 commit comments

Comments
 (0)