Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VS debugger compensation for the new EH #98847

Merged
merged 2 commits into from
Feb 23, 2024
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
15 changes: 12 additions & 3 deletions src/coreclr/vm/debugdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,9 +1152,18 @@ void DebugStackTrace::GetStackFramesFromException(OBJECTREF * e,
// to spot.
DWORD dwNativeOffset;

if (cur.ip)
UINT_PTR ip = cur.ip;
#if defined(DACCESS_COMPILE) && defined(TARGET_AMD64)
// Compensate for a bug in the old EH that for a frame that faulted
// has the ip pointing to an address before the faulting instruction
if (g_isNewExceptionHandlingEnabled && (i == 0) && ((cur.flags & STEF_IP_ADJUSTED) == 0))
{
EECodeInfo codeInfo(cur.ip);
ip -= 1;
}
#endif // DACCESS_COMPILE && TARGET_AMD64
if (ip)
{
EECodeInfo codeInfo(ip);
dwNativeOffset = codeInfo.GetRelOffset();
}
else
Expand All @@ -1165,7 +1174,7 @@ void DebugStackTrace::GetStackFramesFromException(OBJECTREF * e,
pData->pElements[i].InitPass1(
dwNativeOffset,
pMD,
(PCODE)cur.ip,
(PCODE)ip,
cur.flags);
#ifndef DACCESS_COMPILE
pData->pElements[i].InitPass2();
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/vm/exceptionhandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7578,15 +7578,8 @@ extern "C" void QCALLTYPE AppendExceptionStackFrame(QCall::ObjectHandleOnStack e
_ASSERTE(pMD == codeInfo.GetMethodDesc());
#endif // _DEBUG

// Compensate for a bug in the old EH that doesn't mark faulting instructions as faulting. The VS expects that behavior.
bool hasFaulted = pExInfo->m_frameIter.m_crawl.HasFaulted();
if (hasFaulted)
{
pExInfo->m_frameIter.m_crawl.hasFaulted = false;
}
pExInfo->m_StackTraceInfo.AppendElement(canAllocateMemory, ip, sp, pMD, &pExInfo->m_frameIter.m_crawl);
pExInfo->m_StackTraceInfo.SaveStackTrace(canAllocateMemory, pExInfo->m_hThrowable, /*bReplaceStack*/FALSE, /*bSkipLastElement*/FALSE);
pExInfo->m_frameIter.m_crawl.hasFaulted = hasFaulted;
}

// Notify the debugger that we are on the first pass for a managed exception.
Expand Down