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

Use enum for frametype not v table #112166

Merged
merged 20 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
10 changes: 5 additions & 5 deletions src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ ULONG32 DacDbiInterfaceImpl::GetCountOfInternalFrames(VMPTR_Thread vmThread)
if (g_isNewExceptionHandlingEnabled && InlinedCallFrame::FrameHasActiveCall(pFrame))
{
// Skip new exception handling helpers
InlinedCallFrame *pInlinedCallFrame = (InlinedCallFrame *)pFrame;
InlinedCallFrame *pInlinedCallFrame = dac_cast<PTR_InlinedCallFrame>(pFrame);
PTR_NDirectMethodDesc pMD = pInlinedCallFrame->m_Datum;
TADDR datum = dac_cast<TADDR>(pMD);
if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper)
Expand Down Expand Up @@ -518,7 +518,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread
if (g_isNewExceptionHandlingEnabled && InlinedCallFrame::FrameHasActiveCall(pFrame))
{
// Skip new exception handling helpers
InlinedCallFrame *pInlinedCallFrame = (InlinedCallFrame *)pFrame;
InlinedCallFrame *pInlinedCallFrame = dac_cast<PTR_InlinedCallFrame>(pFrame);
PTR_NDirectMethodDesc pMD = pInlinedCallFrame->m_Datum;
TADDR datum = dac_cast<TADDR>(pMD);
if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper)
Expand Down Expand Up @@ -558,7 +558,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread
// it. In this case, pMD will remain NULL.
EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY
{
if (pFrame->GetVTablePtr() == ComMethodFrame::GetMethodFrameVPtr())
if (pFrame->GetFrameIdentifier() == FrameIdentifier::ComMethodFrame)
{
ComMethodFrame * pCOMFrame = dac_cast<PTR_ComMethodFrame>(pFrame);
PTR_VOID pUnkStackSlot = pCOMFrame->GetPointerToArguments();
Expand Down Expand Up @@ -1142,7 +1142,7 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra
}
else if (ft == Frame::TYPE_EXIT)
{
if ((pFrame->GetVTablePtr() != InlinedCallFrame::GetMethodFrameVPtr()) ||
if ((pFrame->GetFrameIdentifier() != FrameIdentifier::InlinedCallFrame) ||
InlinedCallFrame::FrameHasActiveCall(pFrame))
{
resultType = STUBFRAME_M2U;
Expand All @@ -1153,7 +1153,7 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra

case Frame::TT_M2U:
// Refer to the comment in DebuggerWalkStackProc() for StubDispatchFrame.
if (pFrame->GetVTablePtr() != StubDispatchFrame::GetMethodFrameVPtr())
if (pFrame->GetFrameIdentifier() != FrameIdentifier::StubDispatchFrame)
{
if (it == Frame::INTERCEPTION_SECURITY)
{
Expand Down
257 changes: 253 additions & 4 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13475,10 +13475,7 @@ void Debugger::UnhandledHijackWorker(CONTEXT * pContext, EXCEPTION_RECORD * pRec
fSOException))
{

FrameWithCookie<FaultingExceptionFrame> fef;
#if defined(FEATURE_EH_FUNCLETS)
*((&fef)->GetGSCookiePtr()) = GetProcessGSCookie();
#endif // FEATURE_EH_FUNCLETS
FaultingExceptionFrame fef;
if ((pContext != NULL) && fSOException)
{
GCX_COOP(); // Must be cooperative to modify frame chain.
Expand Down Expand Up @@ -16799,4 +16796,256 @@ void Debugger::ExternalMethodFixupNextStep(PCODE address)
}
#endif //DACCESS_COMPILE

unsigned FuncEvalFrame::GetFrameAttribs_Impl(void)
{
LIMITED_METHOD_DAC_CONTRACT;

if (GetDebuggerEval()->m_evalDuringException)
{
return FRAME_ATTR_NONE;
}
else
{
return FRAME_ATTR_RESUMABLE; // Treat the next frame as the top frame.
}
}

TADDR FuncEvalFrame::GetReturnAddressPtr_Impl()
{
LIMITED_METHOD_DAC_CONTRACT;

if (GetDebuggerEval()->m_evalDuringException)
{
return (TADDR)NULL;
}
else
{
return PTR_HOST_MEMBER_TADDR(FuncEvalFrame, this, m_ReturnAddress);
}
}

//
// This updates the register display for a FuncEvalFrame.
//
void FuncEvalFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats)
{
SUPPORTS_DAC;
DebuggerEval * pDE = GetDebuggerEval();

// No context to update if we're doing a func eval from within exception processing.
if (pDE->m_evalDuringException)
{
return;
}

#ifndef FEATURE_EH_FUNCLETS
// Reset pContext; it's only valid for active (top-most) frame.
pRD->pContext = NULL;
#endif // !FEATURE_EH_FUNCLETS


#ifdef TARGET_X86
// Update all registers in the reg display from the CONTEXT we stored when the thread was hijacked for this func
// eval. We have to update all registers, not just the callee saved registers, because we can hijack a thread at any
// point for a func eval, not just at a call site.
pRD->SetEdiLocation(&(pDE->m_context.Edi));
pRD->SetEsiLocation(&(pDE->m_context.Esi));
pRD->SetEbxLocation(&(pDE->m_context.Ebx));
pRD->SetEdxLocation(&(pDE->m_context.Edx));
pRD->SetEcxLocation(&(pDE->m_context.Ecx));
pRD->SetEaxLocation(&(pDE->m_context.Eax));
pRD->SetEbpLocation(&(pDE->m_context.Ebp));
pRD->PCTAddr = GetReturnAddressPtr();

#ifdef FEATURE_EH_FUNCLETS

pRD->IsCallerContextValid = FALSE;
pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary.

pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr);
pRD->pCurrentContext->Esp = (DWORD)GetSP(&pDE->m_context);

SyncRegDisplayToCurrentContext(pRD);

#else // FEATURE_EH_FUNCLETS

pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr);
pRD->SP = (DWORD)GetSP(&pDE->m_context);

#endif // FEATURE_EH_FUNCLETS

#elif defined(TARGET_AMD64)
pRD->IsCallerContextValid = FALSE;
pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary.

memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(CONTEXT));

pRD->pCurrentContextPointers->Rax = &(pDE->m_context.Rax);
pRD->pCurrentContextPointers->Rcx = &(pDE->m_context.Rcx);
pRD->pCurrentContextPointers->Rdx = &(pDE->m_context.Rdx);
pRD->pCurrentContextPointers->R8 = &(pDE->m_context.R8);
pRD->pCurrentContextPointers->R9 = &(pDE->m_context.R9);
pRD->pCurrentContextPointers->R10 = &(pDE->m_context.R10);
pRD->pCurrentContextPointers->R11 = &(pDE->m_context.R11);

pRD->pCurrentContextPointers->Rbx = &(pDE->m_context.Rbx);
pRD->pCurrentContextPointers->Rsi = &(pDE->m_context.Rsi);
pRD->pCurrentContextPointers->Rdi = &(pDE->m_context.Rdi);
pRD->pCurrentContextPointers->Rbp = &(pDE->m_context.Rbp);
pRD->pCurrentContextPointers->R12 = &(pDE->m_context.R12);
pRD->pCurrentContextPointers->R13 = &(pDE->m_context.R13);
pRD->pCurrentContextPointers->R14 = &(pDE->m_context.R14);
pRD->pCurrentContextPointers->R15 = &(pDE->m_context.R15);

// SyncRegDisplayToCurrentContext() sets the pRD->SP and pRD->ControlPC on AMD64.
SyncRegDisplayToCurrentContext(pRD);

#elif defined(TARGET_ARM)
pRD->IsCallerContextValid = FALSE;
pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary.

memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT));

pRD->pCurrentContextPointers->R4 = &(pDE->m_context.R4);
pRD->pCurrentContextPointers->R5 = &(pDE->m_context.R5);
pRD->pCurrentContextPointers->R6 = &(pDE->m_context.R6);
pRD->pCurrentContextPointers->R7 = &(pDE->m_context.R7);
pRD->pCurrentContextPointers->R8 = &(pDE->m_context.R8);
pRD->pCurrentContextPointers->R9 = &(pDE->m_context.R9);
pRD->pCurrentContextPointers->R10 = &(pDE->m_context.R10);
pRD->pCurrentContextPointers->R11 = &(pDE->m_context.R11);
pRD->pCurrentContextPointers->Lr = &(pDE->m_context.Lr);

pRD->volatileCurrContextPointers.R0 = &(pDE->m_context.R0);
pRD->volatileCurrContextPointers.R1 = &(pDE->m_context.R1);
pRD->volatileCurrContextPointers.R2 = &(pDE->m_context.R2);
pRD->volatileCurrContextPointers.R3 = &(pDE->m_context.R3);
pRD->volatileCurrContextPointers.R12 = &(pDE->m_context.R12);

SyncRegDisplayToCurrentContext(pRD);

#elif defined(TARGET_ARM64)
pRD->IsCallerContextValid = FALSE;
pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary.

memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT));

pRD->pCurrentContextPointers->X19 = &(pDE->m_context.X19);
pRD->pCurrentContextPointers->X20 = &(pDE->m_context.X20);
pRD->pCurrentContextPointers->X21 = &(pDE->m_context.X21);
pRD->pCurrentContextPointers->X22 = &(pDE->m_context.X22);
pRD->pCurrentContextPointers->X23 = &(pDE->m_context.X23);
pRD->pCurrentContextPointers->X24 = &(pDE->m_context.X24);
pRD->pCurrentContextPointers->X25 = &(pDE->m_context.X25);
pRD->pCurrentContextPointers->X26 = &(pDE->m_context.X26);
pRD->pCurrentContextPointers->X27 = &(pDE->m_context.X27);
pRD->pCurrentContextPointers->X28 = &(pDE->m_context.X28);
pRD->pCurrentContextPointers->Lr = &(pDE->m_context.Lr);
pRD->pCurrentContextPointers->Fp = &(pDE->m_context.Fp);

pRD->volatileCurrContextPointers.X0 = &(pDE->m_context.X0);
pRD->volatileCurrContextPointers.X1 = &(pDE->m_context.X1);
pRD->volatileCurrContextPointers.X2 = &(pDE->m_context.X2);
pRD->volatileCurrContextPointers.X3 = &(pDE->m_context.X3);
pRD->volatileCurrContextPointers.X4 = &(pDE->m_context.X4);
pRD->volatileCurrContextPointers.X5 = &(pDE->m_context.X5);
pRD->volatileCurrContextPointers.X6 = &(pDE->m_context.X6);
pRD->volatileCurrContextPointers.X7 = &(pDE->m_context.X7);
pRD->volatileCurrContextPointers.X8 = &(pDE->m_context.X8);
pRD->volatileCurrContextPointers.X9 = &(pDE->m_context.X9);
pRD->volatileCurrContextPointers.X10 = &(pDE->m_context.X10);
pRD->volatileCurrContextPointers.X11 = &(pDE->m_context.X11);
pRD->volatileCurrContextPointers.X12 = &(pDE->m_context.X12);
pRD->volatileCurrContextPointers.X13 = &(pDE->m_context.X13);
pRD->volatileCurrContextPointers.X14 = &(pDE->m_context.X14);
pRD->volatileCurrContextPointers.X15 = &(pDE->m_context.X15);
pRD->volatileCurrContextPointers.X16 = &(pDE->m_context.X16);
pRD->volatileCurrContextPointers.X17 = &(pDE->m_context.X17);

SyncRegDisplayToCurrentContext(pRD);
#elif defined(TARGET_RISCV64)
pRD->IsCallerContextValid = FALSE;
pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary.

memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT));

pRD->pCurrentContextPointers->S1 = &(pDE->m_context.S1);
pRD->pCurrentContextPointers->S2 = &(pDE->m_context.S2);
pRD->pCurrentContextPointers->S3 = &(pDE->m_context.S3);
pRD->pCurrentContextPointers->S4 = &(pDE->m_context.S4);
pRD->pCurrentContextPointers->S5 = &(pDE->m_context.S5);
pRD->pCurrentContextPointers->S6 = &(pDE->m_context.S6);
pRD->pCurrentContextPointers->S7 = &(pDE->m_context.S7);
pRD->pCurrentContextPointers->S8 = &(pDE->m_context.S8);
pRD->pCurrentContextPointers->S9 = &(pDE->m_context.S9);
pRD->pCurrentContextPointers->S10 = &(pDE->m_context.S10);
pRD->pCurrentContextPointers->S11 = &(pDE->m_context.S11);
pRD->pCurrentContextPointers->Fp = &(pDE->m_context.Fp);
pRD->pCurrentContextPointers->Gp = &(pDE->m_context.Gp);
pRD->pCurrentContextPointers->Tp = &(pDE->m_context.Tp);
pRD->pCurrentContextPointers->Ra = &(pDE->m_context.Ra);

pRD->volatileCurrContextPointers.R0 = &(pDE->m_context.R0);
pRD->volatileCurrContextPointers.A0 = &(pDE->m_context.A0);
pRD->volatileCurrContextPointers.A1 = &(pDE->m_context.A1);
pRD->volatileCurrContextPointers.A2 = &(pDE->m_context.A2);
pRD->volatileCurrContextPointers.A3 = &(pDE->m_context.A3);
pRD->volatileCurrContextPointers.A4 = &(pDE->m_context.A4);
pRD->volatileCurrContextPointers.A5 = &(pDE->m_context.A5);
pRD->volatileCurrContextPointers.A6 = &(pDE->m_context.A6);
pRD->volatileCurrContextPointers.A7 = &(pDE->m_context.A7);
pRD->volatileCurrContextPointers.T0 = &(pDE->m_context.T0);
pRD->volatileCurrContextPointers.T1 = &(pDE->m_context.T1);
pRD->volatileCurrContextPointers.T2 = &(pDE->m_context.T2);
pRD->volatileCurrContextPointers.T3 = &(pDE->m_context.T3);
pRD->volatileCurrContextPointers.T4 = &(pDE->m_context.T4);
pRD->volatileCurrContextPointers.T5 = &(pDE->m_context.T5);
pRD->volatileCurrContextPointers.T6 = &(pDE->m_context.T6);

SyncRegDisplayToCurrentContext(pRD);
#elif defined(TARGET_LOONGARCH64)
pRD->IsCallerContextValid = FALSE;
pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary.

memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT));

pRD->pCurrentContextPointers->S0 = &(pDE->m_context.S0);
pRD->pCurrentContextPointers->S1 = &(pDE->m_context.S1);
pRD->pCurrentContextPointers->S2 = &(pDE->m_context.S2);
pRD->pCurrentContextPointers->S3 = &(pDE->m_context.S3);
pRD->pCurrentContextPointers->S4 = &(pDE->m_context.S4);
pRD->pCurrentContextPointers->S5 = &(pDE->m_context.S5);
pRD->pCurrentContextPointers->S6 = &(pDE->m_context.S6);
pRD->pCurrentContextPointers->S7 = &(pDE->m_context.S7);
pRD->pCurrentContextPointers->S8 = &(pDE->m_context.S8);
pRD->pCurrentContextPointers->Fp = &(pDE->m_context.Fp);
pRD->pCurrentContextPointers->Ra = &(pDE->m_context.Ra);

pRD->volatileCurrContextPointers.R0 = &(pDE->m_context.R0);
pRD->volatileCurrContextPointers.A0 = &(pDE->m_context.A0);
pRD->volatileCurrContextPointers.A1 = &(pDE->m_context.A1);
pRD->volatileCurrContextPointers.A2 = &(pDE->m_context.A2);
pRD->volatileCurrContextPointers.A3 = &(pDE->m_context.A3);
pRD->volatileCurrContextPointers.A4 = &(pDE->m_context.A4);
pRD->volatileCurrContextPointers.A5 = &(pDE->m_context.A5);
pRD->volatileCurrContextPointers.A6 = &(pDE->m_context.A6);
pRD->volatileCurrContextPointers.A7 = &(pDE->m_context.A7);
pRD->volatileCurrContextPointers.T0 = &(pDE->m_context.T0);
pRD->volatileCurrContextPointers.T1 = &(pDE->m_context.T1);
pRD->volatileCurrContextPointers.T2 = &(pDE->m_context.T2);
pRD->volatileCurrContextPointers.T3 = &(pDE->m_context.T3);
pRD->volatileCurrContextPointers.T4 = &(pDE->m_context.T4);
pRD->volatileCurrContextPointers.T5 = &(pDE->m_context.T5);
pRD->volatileCurrContextPointers.T6 = &(pDE->m_context.T6);
pRD->volatileCurrContextPointers.T7 = &(pDE->m_context.T7);
pRD->volatileCurrContextPointers.T8 = &(pDE->m_context.T8);
pRD->volatileCurrContextPointers.X0 = &(pDE->m_context.X0);

SyncRegDisplayToCurrentContext(pRD);

#else
PORTABILITY_ASSERT("FuncEvalFrame::UpdateRegDisplay is not implemented on this platform.");
#endif
}

#endif //DEBUGGING_SUPPORTED
Loading
Loading