Skip to content

Commit 0e2d6c5

Browse files
authored
Change VMPTR IPC events to ensure endianness consistency (#128058)
The inadvertent consequence of #127943 is that since VMPTR now wraps a `Portable<CORDB_ADDRESS>`, VMPTR is propagated as a little-endian value across DBI, DAC, and EE, as opposed to solely in the IPC layer. Changing this such that VMPTR wraps CORDB_ADDRESS and we have `Portable<VMPTR>` in the IPC layer - remains little-endian in IPC, but the conversion operator to a VMPTR converts it to the machine endianness.
1 parent cfdb6ed commit 0e2d6c5

6 files changed

Lines changed: 111 additions & 77 deletions

File tree

src/coreclr/debug/di/breakpoint.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,11 @@ HRESULT CordbStepper::StepRange(BOOL fStepIn,
522522

523523
if (m_frame == NULL)
524524
{
525-
pEvent->StepData.frameToken = LEAF_MOST_FRAME;
525+
pEvent->StepData.frameToken = (CORDB_ADDRESS)0;
526526
}
527527
else
528528
{
529-
pEvent->StepData.frameToken = m_frame->GetFramePointer();
529+
pEvent->StepData.frameToken = PTR_TO_CORDB_ADDRESS(m_frame->GetFramePointer().GetSPValue());
530530
}
531531

532532
pEvent->StepData.stepIn = (fStepIn != 0);
@@ -688,11 +688,11 @@ HRESULT CordbStepper::StepOut()
688688

689689
if (m_frame == NULL)
690690
{
691-
pEvent->StepData.frameToken = LEAF_MOST_FRAME;
691+
pEvent->StepData.frameToken = (CORDB_ADDRESS)0;
692692
}
693693
else
694694
{
695-
pEvent->StepData.frameToken = m_frame->GetFramePointer();
695+
pEvent->StepData.frameToken = PTR_TO_CORDB_ADDRESS(m_frame->GetFramePointer().GetSPValue());
696696
}
697697

698698
pEvent->StepData.totalRangeCount = 0;

src/coreclr/debug/di/process.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5559,7 +5559,7 @@ void CordbProcess::RawDispatchEvent(
55595559
{
55605560
STRESS_LOG4(LF_CORDB, LL_INFO100,
55615561
"RCET::DRCE: Exception2 0x%p 0x%X 0x%X 0x%X\n",
5562-
pEvent->ExceptionCallback2.framePointer.GetSPValue(),
5562+
CORDB_ADDRESS_TO_PTR(pEvent->ExceptionCallback2.framePointer),
55635563
pEvent->ExceptionCallback2.nOffset,
55645564
pEvent->ExceptionCallback2.eventType,
55655565
pEvent->ExceptionCallback2.dwFlags
@@ -5581,7 +5581,7 @@ void CordbProcess::RawDispatchEvent(
55815581
//
55825582
RSSmartPtr<CordbFrame> pFrame;
55835583

5584-
FramePointer fp = pEvent->ExceptionCallback2.framePointer;
5584+
FramePointer fp = FramePointer::MakeFramePointer(CORDB_ADDRESS_TO_PTR(pEvent->ExceptionCallback2.framePointer));
55855585
if (fp != LEAF_MOST_FRAME)
55865586
{
55875587
// The interface forces us to pass a FramePointer via an ICorDebugFrame.

src/coreclr/debug/di/rsthread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,7 @@ HRESULT CordbThread::InterceptCurrentException(ICorDebugFrame * pFrame)
21832183
GetProcess()->InitIPCEvent(&event, DB_IPCE_INTERCEPT_EXCEPTION, true, VMPTR_AppDomain::NullPtr());
21842184

21852185
event.InterceptException.vmThreadToken = m_vmThreadToken;
2186-
event.InterceptException.frameToken = pRealFrame->GetFramePointer();
2186+
event.InterceptException.frameToken = PTR_TO_CORDB_ADDRESS(pRealFrame->GetFramePointer().GetSPValue());
21872187

21882188
hr = GetProcess()->m_cordb->SendIPCEvent(GetProcess(), &event, sizeof(DebuggerIPCEvent));
21892189

src/coreclr/debug/ee/debugger.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7159,7 +7159,7 @@ HRESULT Debugger::SendExceptionHelperAndBlock(
71597159
//
71607160
InitIPCEvent(ipce, DB_IPCE_EXCEPTION_CALLBACK2, pThread);
71617161

7162-
ipce->ExceptionCallback2.framePointer = framePointer;
7162+
ipce->ExceptionCallback2.framePointer = PTR_TO_CORDB_ADDRESS(framePointer.GetSPValue());
71637163
ipce->ExceptionCallback2.eventType = eventType;
71647164
ipce->ExceptionCallback2.nOffset = (UINT)nOffset;
71657165
ipce->ExceptionCallback2.dwFlags = dwFlags;
@@ -7312,7 +7312,7 @@ void Debugger::SendExceptionEventsWorker(
73127312

73137313
InitIPCEvent(ipce, DB_IPCE_EXCEPTION_CALLBACK2, pThread);
73147314

7315-
ipce->ExceptionCallback2.framePointer = framePointer;
7315+
ipce->ExceptionCallback2.framePointer = PTR_TO_CORDB_ADDRESS(framePointer.GetSPValue());
73167316
ipce->ExceptionCallback2.eventType = DEBUG_EXCEPTION_USER_FIRST_CHANCE;
73177317
ipce->ExceptionCallback2.nOffset = (UINT)nOffset;
73187318
ipce->ExceptionCallback2.dwFlags = fIsInterceptable ? DEBUG_EXCEPTION_CAN_BE_INTERCEPTED : 0;
@@ -7971,7 +7971,7 @@ void Debugger::SendCatchHandlerFound(
79717971
//
79727972
InitIPCEvent(ipce, DB_IPCE_EXCEPTION_CALLBACK2, pThread);
79737973

7974-
ipce->ExceptionCallback2.framePointer = fp;
7974+
ipce->ExceptionCallback2.framePointer = PTR_TO_CORDB_ADDRESS(fp.GetSPValue());
79757975
ipce->ExceptionCallback2.eventType = DEBUG_EXCEPTION_CATCH_HANDLER_FOUND;
79767976
ipce->ExceptionCallback2.nOffset = (UINT)nOffset;
79777977
ipce->ExceptionCallback2.dwFlags = dwFlags;
@@ -10293,7 +10293,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
1029310293
LOG((LF_CORDB,LL_INFO10000, "D::HIPCE: frame SP:%p "
1029410294
"StepIn:%s RangeIL:%s RangeCount:%u MapStop:0x%x "
1029510295
"InterceptStop:0x%x AppD:%p\n",
10296-
pEvent->StepData.frameToken.GetSPValue(),
10296+
CORDB_ADDRESS_TO_PTR(pEvent->StepData.frameToken),
1029710297
(pEvent->StepData.stepIn ? "true" : "false"),
1029810298
(pEvent->StepData.rangeIL ? "true" : "false"),
1029910299
pEvent->StepData.rangeCount,
@@ -10349,7 +10349,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
1034910349

1035010350
_ASSERTE(cRanges == 0 || ((cRanges > 0) && (cRanges == pEvent->StepData.rangeCount)));
1035110351

10352-
if (!pStepper->Step(pEvent->StepData.frameToken,
10352+
if (!pStepper->Step(FramePointer::MakeFramePointer(CORDB_ADDRESS_TO_PTR(pEvent->StepData.frameToken)),
1035310353
pEvent->StepData.stepIn,
1035410354
&(pEvent->StepData.range),
1035510355
cRanges,
@@ -10423,7 +10423,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
1042310423
// Safe to stack trace b/c we're stopped.
1042410424
StackTraceTicket ticket(pThread);
1042510425

10426-
pStepper->StepOut(pEvent->StepData.frameToken, ticket);
10426+
pStepper->StepOut(FramePointer::MakeFramePointer(CORDB_ADDRESS_TO_PTR(pEvent->StepData.frameToken)), ticket);
1042710427

1042810428
pIPCResult->StepData.stepperToken.Set(pStepper);
1042910429
}
@@ -11108,7 +11108,7 @@ HRESULT Debugger::GetAndSendInterceptCommand(DebuggerIPCEvent *event)
1110811108
//
1110911109
// Now start processing the parameters from the event.
1111011110
//
11111-
FramePointer targetFramePointer = event->InterceptException.frameToken;
11111+
FramePointer targetFramePointer = FramePointer::MakeFramePointer(CORDB_ADDRESS_TO_PTR(event->InterceptException.frameToken));
1111211112

1111311113
ControllerStackInfo csi;
1111411114

@@ -11438,7 +11438,7 @@ void Debugger::TypeHandleToBasicTypeInfo(AppDomain *pAppDomain, TypeHandle th, D
1143811438
case ELEMENT_TYPE_BYREF:
1143911439
res->vmTypeHandle = WrapTypeHandle(th);
1144011440
res->metadataToken = mdTokenNil;
11441-
res->vmAssembly.SetRawPtr(NULL);
11441+
res->vmAssembly = VMPTR_Assembly::NullPtr();
1144211442
break;
1144311443

1144411444
case ELEMENT_TYPE_CLASS:
@@ -11456,7 +11456,7 @@ void Debugger::TypeHandleToBasicTypeInfo(AppDomain *pAppDomain, TypeHandle th, D
1145611456
default:
1145711457
res->vmTypeHandle = VMPTR_TypeHandle::NullPtr();
1145811458
res->metadataToken = mdTokenNil;
11459-
res->vmAssembly.SetRawPtr(NULL);
11459+
res->vmAssembly = VMPTR_Assembly::NullPtr();
1146011460
break;
1146111461
}
1146211462
return;

0 commit comments

Comments
 (0)