From: Andrew Au Date: Sat, 9 Mar 2019 00:00:36 +0000 (-0800) Subject: Avoid StackWalk in EventPipeEventInstance constructor X-Git-Tag: submit/tizen/20210909.063632~11030^2~2212 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b9ad0968ae529662c055517e65b14a554c46e1e;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Avoid StackWalk in EventPipeEventInstance constructor Commit migrated from https://github.com/dotnet/coreclr/commit/8009ba276895edc9decf49c8a2470a1e6bbe2997 --- diff --git a/src/coreclr/src/vm/eventpipe.cpp b/src/coreclr/src/vm/eventpipe.cpp index c2db06d..4de0b3c 100644 --- a/src/coreclr/src/vm/eventpipe.cpp +++ b/src/coreclr/src/vm/eventpipe.cpp @@ -798,6 +798,7 @@ void EventPipe::WriteEventInternal(EventPipeEvent &event, EventPipeEventPayload payload.GetSize(), pActivityId, pRelatedActivityId); + instance.EnsureStack(*s_pSession); if(s_pFile != NULL) { diff --git a/src/coreclr/src/vm/eventpipebuffer.cpp b/src/coreclr/src/vm/eventpipebuffer.cpp index 395725e..6cc901c 100644 --- a/src/coreclr/src/vm/eventpipebuffer.cpp +++ b/src/coreclr/src/vm/eventpipebuffer.cpp @@ -83,6 +83,7 @@ bool EventPipeBuffer::WriteEvent(Thread *pThread, EventPipeSession &session, Eve payload.GetSize(), (pThread == NULL) ? NULL : pActivityId, pRelatedActivityId); + pInstance->EnsureStack(session); // TODO: Perform the stackwalk before the constructor // Copy the stack if a separate stack trace was provided. if(pStack != NULL) diff --git a/src/coreclr/src/vm/eventpipeconfiguration.cpp b/src/coreclr/src/vm/eventpipeconfiguration.cpp index d40f2b7..9cf8280 100644 --- a/src/coreclr/src/vm/eventpipeconfiguration.cpp +++ b/src/coreclr/src/vm/eventpipeconfiguration.cpp @@ -505,6 +505,7 @@ EventPipeEventInstance* EventPipeConfiguration::BuildEventMetadataEvent(EventPip instancePayloadSize, NULL /* pActivityId */, NULL /* pRelatedActivityId */); + _ASSERTE(!m_pMetadataEvent->NeedStack()); // Set the timestamp to match the source event, because the metadata event // will be emitted right before the source event. diff --git a/src/coreclr/src/vm/eventpipeeventinstance.cpp b/src/coreclr/src/vm/eventpipeeventinstance.cpp index 1424dbc..03ebc6d 100644 --- a/src/coreclr/src/vm/eventpipeeventinstance.cpp +++ b/src/coreclr/src/vm/eventpipeeventinstance.cpp @@ -34,7 +34,7 @@ EventPipeEventInstance::EventPipeEventInstance( #endif // _DEBUG m_pEvent = &event; m_threadID = threadID; - if(pActivityId != NULL) + if (pActivityId != NULL) { m_activityId = *pActivityId; } @@ -42,7 +42,7 @@ EventPipeEventInstance::EventPipeEventInstance( { m_activityId = {0}; } - if(pRelatedActivityId != NULL) + if (pRelatedActivityId != NULL) { m_relatedActivityId = *pRelatedActivityId; } @@ -55,15 +55,17 @@ EventPipeEventInstance::EventPipeEventInstance( m_dataLength = length; QueryPerformanceCounter(&m_timeStamp); _ASSERTE(m_timeStamp.QuadPart > 0); +#ifdef _DEBUG + EnsureConsistency(); +#endif // _DEBUG +} - if(event.NeedStack() && !session.RundownEnabled()) +void EventPipeEventInstance::EnsureStack(const EventPipeSession &session) +{ + if (m_pEvent->NeedStack() && !session.RundownEnabled()) { EventPipe::WalkManagedStackForCurrentThread(m_stackContents); } - -#ifdef _DEBUG - EnsureConsistency(); -#endif // _DEBUG } unsigned int EventPipeEventInstance::GetAlignedTotalSize() const diff --git a/src/coreclr/src/vm/eventpipeeventinstance.h b/src/coreclr/src/vm/eventpipeeventinstance.h index 47f1b5c..a0e6e54 100644 --- a/src/coreclr/src/vm/eventpipeeventinstance.h +++ b/src/coreclr/src/vm/eventpipeeventinstance.h @@ -23,6 +23,8 @@ public: EventPipeEventInstance(EventPipeSession &session, EventPipeEvent &event, DWORD threadID, BYTE *pData, unsigned int length, LPCGUID pActivityId, LPCGUID pRelatedActivityId); + void EnsureStack(const EventPipeSession &session); + StackContents* GetStack() { LIMITED_METHOD_CONTRACT;