Fix issue 23151 (Cleanup TODO introduced by PR dotnet/coreclr#23148)
authorAndrew Au <cshung@gmail.com>
Wed, 13 Mar 2019 16:56:41 +0000 (09:56 -0700)
committerGitHub <noreply@github.com>
Wed, 13 Mar 2019 16:56:41 +0000 (09:56 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/c6089f795eb9d5e72f5db5c530d73bc901245e2a

src/coreclr/src/vm/eventpipebuffer.cpp

index 6cc901c..31646be 100644 (file)
@@ -75,6 +75,15 @@ bool EventPipeBuffer::WriteEvent(Thread *pThread, EventPipeSession &session, Eve
 
         // Placement-new the EventPipeEventInstance.
         // if pthread is NULL, it's likely we are running in something like a GC thread which is not a Thread object, so it can't have an activity ID set anyway
+
+        StackContents s;
+        memset((void*)&s, 0, sizeof(s));
+        if (event.NeedStack() && !session.RundownEnabled() && pStack == NULL)
+        {
+            EventPipe::WalkManagedStackForCurrentThread(s);
+            pStack = &s;
+        }
+
         EventPipeEventInstance *pInstance = new (m_pCurrent) EventPipeEventInstance(
             session,
             event,
@@ -83,10 +92,9 @@ 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)
+        if (pStack != NULL)
         {
             StackContents *pInstanceStack = pInstance->GetStack();
             pStack->CopyTo(pInstanceStack);