From d75f0ee1a0c01becba48c87168607a4d44abaa68 Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Thu, 25 Apr 2024 18:56:26 +0200 Subject: [PATCH] Store last OSR transition context in static memory in DEBUG builds (#101537) Hopefully will help with diagnosing #101060 once we get a new dump. --- src/coreclr/vm/jithelpers.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 7400708001589f..98d6780258a6c6 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -5144,7 +5144,7 @@ void JIT_Patchpoint(int* counter, int ilOffset) const int counterBump = g_pConfig->OSR_CounterBump(); *counter = counterBump; -#if _DEBUG +#ifdef _DEBUG const int ppId = ppInfo->m_patchpointId; #endif @@ -5389,6 +5389,12 @@ void JIT_Patchpoint(int* counter, int ilOffset) // Install new entry point as IP SetIP(pFrameContext, osrMethodCode); +#ifdef _DEBUG + // Keep this context around to aid in debugging OSR transition problems + static CONTEXT s_lastOSRTransitionContext; + s_lastOSRTransitionContext = *pFrameContext; +#endif + // Restore last error (since call below does not return) // END_PRESERVE_LAST_ERROR; ::SetLastError(dwLastError); @@ -5425,7 +5431,7 @@ HCIMPL1(VOID, JIT_PartialCompilationPatchpoint, int ilOffset) // Patchpoint identity is the helper return address PCODE ip = (PCODE)_ReturnAddress(); -#if _DEBUG +#ifdef _DEBUG // Friendly ID number int ppId = 0; #endif @@ -5439,7 +5445,7 @@ HCIMPL1(VOID, JIT_PartialCompilationPatchpoint, int ilOffset) OnStackReplacementManager* manager = allocator->GetOnStackReplacementManager(); ppInfo = manager->GetPerPatchpointInfo(ip); -#if _DEBUG +#ifdef _DEBUG ppId = ppInfo->m_patchpointId; #endif