@@ -8200,7 +8200,11 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk
8200
8200
else
8201
8201
{
8202
8202
EEToProfilerExceptionInterfaceWrapper::ExceptionSearchCatcherFound (pMD);
8203
- EEToProfilerExceptionInterfaceWrapper::ExceptionSearchFunctionLeave (pMD);
8203
+ if (pExInfo->m_pMDToReport != NULL )
8204
+ {
8205
+ EEToProfilerExceptionInterfaceWrapper::ExceptionSearchFunctionLeave (pExInfo->m_pMDToReport );
8206
+ pExInfo->m_pMDToReport = NULL ;
8207
+ }
8204
8208
8205
8209
// We don't need to do anything special for continuable exceptions after calling
8206
8210
// this callback. We are going to start unwinding anyway.
@@ -8233,7 +8237,7 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk
8233
8237
!(pExInfo->m_exception == CLRException::GetPreallocatedStackOverflowException ());
8234
8238
8235
8239
pExInfo->m_stackTraceInfo .AppendElement (canAllocateMemory, NULL , GetRegdisplaySP (pExInfo->m_frameIter .m_crawl .GetRegisterSet ()), pMD, &pExInfo->m_frameIter .m_crawl );
8236
- }
8240
+ }
8237
8241
}
8238
8242
}
8239
8243
StackWalkAction retVal = pThis->Next ();
@@ -8244,6 +8248,7 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk
8244
8248
if (pExInfo->m_passNumber == 1 )
8245
8249
{
8246
8250
EEToProfilerExceptionInterfaceWrapper::ExceptionSearchFunctionEnter (pMD);
8251
+ pExInfo->m_pMDToReport = pMD;
8247
8252
8248
8253
// Notify the debugger that we are on the first pass for a managed exception.
8249
8254
// Note that this callback is made for every managed frame.
@@ -8252,6 +8257,7 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk
8252
8257
else
8253
8258
{
8254
8259
EEToProfilerExceptionInterfaceWrapper::ExceptionUnwindFunctionEnter (pMD);
8260
+ pExInfo->m_pMDToReport = pMD;
8255
8261
}
8256
8262
8257
8263
pExInfo->m_sfLowBound = GetRegdisplaySP (pThis->m_crawl .GetRegisterSet ());
@@ -8296,15 +8302,24 @@ extern "C" bool QCALLTYPE SfiNext(StackFrameIterator* pThis, uint* uExCollideCla
8296
8302
8297
8303
ExInfo* pExInfo = pThis->GetNextExInfo ();
8298
8304
ExInfo* pTopExInfo = pThread->GetExceptionState ()->GetCurrentExInfo ();
8305
+ bool isCollided = false ;
8299
8306
8300
8307
MethodDesc *pMD = pThis->m_crawl .GetFunction ();
8301
8308
if (pTopExInfo->m_passNumber == 1 )
8302
8309
{
8303
- EEToProfilerExceptionInterfaceWrapper::ExceptionSearchFunctionLeave (pMD);
8310
+ if (pTopExInfo->m_pMDToReport != NULL )
8311
+ {
8312
+ EEToProfilerExceptionInterfaceWrapper::ExceptionSearchFunctionLeave (pTopExInfo->m_pMDToReport );
8313
+ pTopExInfo->m_pMDToReport = NULL ;
8314
+ }
8304
8315
}
8305
8316
else
8306
8317
{
8307
- EEToProfilerExceptionInterfaceWrapper::ExceptionUnwindFunctionLeave (pMD);
8318
+ if (pTopExInfo->m_pMDToReport != NULL )
8319
+ {
8320
+ EEToProfilerExceptionInterfaceWrapper::ExceptionUnwindFunctionLeave (pTopExInfo->m_pMDToReport );
8321
+ pTopExInfo->m_pMDToReport = NULL ;
8322
+ }
8308
8323
}
8309
8324
8310
8325
// Check for reverse pinvoke (but eliminate the case when the caller is managed) or CallDescrWorkerInternal.
@@ -8434,6 +8449,7 @@ extern "C" bool QCALLTYPE SfiNext(StackFrameIterator* pThis, uint* uExCollideCla
8434
8449
else
8435
8450
{
8436
8451
*uExCollideClauseIdx = pExInfo->m_idxCurClause ;
8452
+ isCollided = true ;
8437
8453
pExInfo->m_kind = (ExKind)((uint8_t )pExInfo->m_kind | (uint8_t )ExKind::SupersededFlag);
8438
8454
8439
8455
// Unwind until we hit the frame of the prevExInfo
@@ -8471,15 +8487,23 @@ extern "C" bool QCALLTYPE SfiNext(StackFrameIterator* pThis, uint* uExCollideCla
8471
8487
pMD = pThis->m_crawl .GetFunction ();
8472
8488
if (pTopExInfo->m_passNumber == 1 )
8473
8489
{
8474
- EEToProfilerExceptionInterfaceWrapper::ExceptionSearchFunctionEnter (pMD);
8475
-
8476
- // Notify the debugger that we are on the first pass for a managed exception.
8477
- // Note that this callback is made for every managed frame.
8478
- EEToDebuggerExceptionInterfaceWrapper::FirstChanceManagedException (pThread, GetControlPC (pThis->m_crawl .GetRegisterSet ()), GetRegdisplaySP (pThis->m_crawl .GetRegisterSet ()));
8490
+ // TODO: skip this and the related ...Leave for collided Unwind - maybe move this to the AppendElement above?
8491
+ if (!isCollided)
8492
+ {
8493
+ EEToProfilerExceptionInterfaceWrapper::ExceptionSearchFunctionEnter (pMD);
8494
+ pTopExInfo->m_pMDToReport = pMD;
8495
+ // Notify the debugger that we are on the first pass for a managed exception.
8496
+ // Note that this callback is made for every managed frame.
8497
+ EEToDebuggerExceptionInterfaceWrapper::FirstChanceManagedException (pThread, GetControlPC (pThis->m_crawl .GetRegisterSet ()), GetRegdisplaySP (pThis->m_crawl .GetRegisterSet ()));
8498
+ }
8479
8499
}
8480
8500
else
8481
8501
{
8482
- EEToProfilerExceptionInterfaceWrapper::ExceptionUnwindFunctionEnter (pMD);
8502
+ if (!isCollided)
8503
+ {
8504
+ EEToProfilerExceptionInterfaceWrapper::ExceptionUnwindFunctionEnter (pMD);
8505
+ pTopExInfo->m_pMDToReport = pMD;
8506
+ }
8483
8507
}
8484
8508
8485
8509
Exit:;
0 commit comments