summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Au <andrewau@microsoft.com>2019-03-08 16:00:36 -0800
committerAndrew Au <cshung@gmail.com>2019-03-09 09:04:59 -0800
commit8009ba276895edc9decf49c8a2470a1e6bbe2997 (patch)
tree7acbca9277de2721d325c9b853aadf8118b6c810
parent6633b51df7f91623190ba6bf04c00869cd0fc1e4 (diff)
downloadcoreclr-8009ba276895edc9decf49c8a2470a1e6bbe2997.tar.gz
coreclr-8009ba276895edc9decf49c8a2470a1e6bbe2997.tar.bz2
coreclr-8009ba276895edc9decf49c8a2470a1e6bbe2997.zip
Avoid StackWalk in EventPipeEventInstance constructor
-rw-r--r--src/vm/eventpipe.cpp1
-rw-r--r--src/vm/eventpipebuffer.cpp1
-rw-r--r--src/vm/eventpipeconfiguration.cpp1
-rw-r--r--src/vm/eventpipeeventinstance.cpp16
-rw-r--r--src/vm/eventpipeeventinstance.h2
5 files changed, 14 insertions, 7 deletions
diff --git a/src/vm/eventpipe.cpp b/src/vm/eventpipe.cpp
index c2db06de8c..4de0b3c943 100644
--- a/src/vm/eventpipe.cpp
+++ b/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/vm/eventpipebuffer.cpp b/src/vm/eventpipebuffer.cpp
index 395725efef..6cc901cb7b 100644
--- a/src/vm/eventpipebuffer.cpp
+++ b/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/vm/eventpipeconfiguration.cpp b/src/vm/eventpipeconfiguration.cpp
index d40f2b789e..9cf8280722 100644
--- a/src/vm/eventpipeconfiguration.cpp
+++ b/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/vm/eventpipeeventinstance.cpp b/src/vm/eventpipeeventinstance.cpp
index 1424dbc94c..03ebc6d245 100644
--- a/src/vm/eventpipeeventinstance.cpp
+++ b/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/vm/eventpipeeventinstance.h b/src/vm/eventpipeeventinstance.h
index 47f1b5c35b..a0e6e54a5c 100644
--- a/src/vm/eventpipeeventinstance.h
+++ b/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;