@@ -199,50 +199,28 @@ ClrmaThread::get_FrameCount(
199199 frame.Frame = index;
200200 if (FAILED (hr = GetFrameLocation (pStackWalk, &frame.IP , &frame.SP )))
201201 {
202+ TraceError (" Unwind: GetFrameLocation() FAILED %08x\n " , hr);
202203 break ;
203204 }
205+ // Only include normal frames, skipping any special frames
204206 DacpFrameData frameData;
205207 if (SUCCEEDED (hr = frameData.Request (pStackWalk)) && frameData.frameAddr != 0 )
206208 {
207- frame.SP = frameData.frameAddr ;
208-
209- // Get special stack frame name
210- CLRDATA_ADDRESS methodDesc = 0 ;
211- if (SUCCEEDED (hr = m_managedAnalysis->SosDacInterface ()->GetMethodDescPtrFromFrame (frame.SP , &methodDesc)))
212- {
213- if (FAILED (hr = m_managedAnalysis->GetMethodDescInfo (methodDesc, frame, /* stripFunctionParameters */ false )))
214- {
215- continue ;
216- }
217- }
218- else
219- {
220- if (FAILED (hr = GetFrameFromStackWalk (pStackWalk, frame)))
221- {
222- continue ;
223- }
224- }
209+ TraceInformation (" Unwind: skipping special frame SP %016llx IP %016llx\n " , frame.SP , frame.IP );
210+ continue ;
225211 }
226- else
212+ CLRDATA_ADDRESS methodDesc = 0 ;
213+ if (FAILED (hr = m_managedAnalysis->SosDacInterface ()->GetMethodDescPtrFromIP (frame.IP , &methodDesc)))
227214 {
228- // Get normal module and method names like MethodNameFromIP() does for !clrstack
229- CLRDATA_ADDRESS methodDesc = 0 ;
230- if (SUCCEEDED (hr = m_managedAnalysis->SosDacInterface ()->GetMethodDescPtrFromIP (frame.IP , &methodDesc)))
231- {
232- if (FAILED (hr = m_managedAnalysis->GetMethodDescInfo (methodDesc, frame, /* stripFunctionParameters */ false )))
233- {
234- continue ;
235- }
236- }
237- else
238- {
239- if (FAILED (hr = GetFrameFromStackWalk (pStackWalk, frame)))
240- {
241- continue ;
242- }
243- }
215+ TraceInformation (" Unwind: skipping frame GetMethodDescPtrFromIP(%016llx) FAILED %08x\n " , frame.IP , hr);
216+ continue ;
217+ }
218+ // Get normal module and method names like MethodNameFromIP() does for !clrstack
219+ if (FAILED (hr = m_managedAnalysis->GetMethodDescInfo (methodDesc, frame, /* stripFunctionParameters */ false )))
220+ {
221+ TraceInformation (" Unwind: skipping frame GetMethodDescInfo(%016llx) FAILED %08x\n " , methodDesc, hr);
222+ continue ;
244223 }
245-
246224 m_stackFrames.push_back (frame);
247225 index++;
248226
@@ -534,81 +512,3 @@ ClrmaThread::GetFrameLocation(
534512 }
535513 return S_OK;
536514}
537-
538- HRESULT
539- ClrmaThread::GetFrameFromStackWalk (
540- IXCLRDataStackWalk* pStackWalk,
541- StackFrame& frame
542- )
543- {
544- HRESULT hr;
545- ReleaseHolder<IXCLRDataFrame> clrDataFrame;
546- if (SUCCEEDED (hr = pStackWalk->GetFrame ((IXCLRDataFrame**)&clrDataFrame)))
547- {
548- ReleaseHolder<IXCLRDataMethodInstance> methodInstance;
549- if (SUCCEEDED (hr = clrDataFrame->GetMethodInstance ((IXCLRDataMethodInstance**)&methodInstance)))
550- {
551- // Don't compute the method displacement if IP is 0
552- if (frame.IP > 0 )
553- {
554- CLRDATA_ADDRESS startAddr;
555- if (SUCCEEDED (hr = methodInstance->GetRepresentativeEntryAddress (&startAddr)))
556- {
557- frame.Displacement = (frame.IP - startAddr);
558- }
559- else
560- {
561- TraceError (" GetFrameFromStackWalk: IXCLRDataMethodInstance::GetRepresentativeEntryAddress FAILED %08x\n " , hr);
562- }
563- }
564-
565- ArrayHolder<WCHAR> wszNameBuffer = new WCHAR[MAX_LONGPATH + 1 ];
566- if (SUCCEEDED (hr = methodInstance->GetName (0 , MAX_LONGPATH, nullptr , wszNameBuffer)))
567- {
568- frame.Function = wszNameBuffer;
569- }
570- else
571- {
572- TraceError (" GetFrameFromStackWalk: IXCLRDataMethodInstance::GetName FAILED %08x\n " , hr);
573- }
574-
575- mdMethodDef token;
576- IXCLRDataModule* pModule;
577- if (SUCCEEDED (hr = methodInstance->GetTokenAndScope (&token, &pModule)))
578- {
579- wszNameBuffer[0 ] = L' \0 ' ;
580-
581- ULONG32 nameLen = 0 ;
582- if (SUCCEEDED (hr = pModule->GetFileName (MAX_LONGPATH, &nameLen, wszNameBuffer)))
583- {
584- frame.Module = wszNameBuffer;
585- }
586- else
587- {
588- TraceError (" GetFrameFromStackWalk: IXCLRDataModule::GetFileName FAILED %08x\n " , hr);
589- }
590- }
591- else
592- {
593- TraceError (" GetFrameFromStackWalk: IXCLRDataMethodInstance::GetTokenAndScope FAILED %08x\n " , hr);
594- }
595- }
596- else
597- {
598- TraceError (" GetFrameFromStackWalk: IXCLRDataFrame::GetMethodInstance FAILED %08x\n " , hr);
599- }
600- }
601- else
602- {
603- TraceError (" GetFrameFromStackWalk: IXCLRDataStackWalk::GetFrame FAILED %08x\n " , hr);
604- }
605- if (frame.Module .empty ())
606- {
607- frame.Module = L" UNKNOWN" ;
608- }
609- if (frame.Function .empty ())
610- {
611- frame.Function = L" UNKNOWN" ;
612- }
613- return hr;
614- }
0 commit comments