diff options
author | Brian Robbins <brianrob@microsoft.com> | 2017-05-15 08:13:42 -0700 |
---|---|---|
committer | Vance Morrison <vancem@microsoft.com> | 2017-05-15 08:13:42 -0700 |
commit | f11f3d73eb432b1dc4c42df6eb1e1fb099222730 (patch) | |
tree | 42e34c206d1d1781cf081db699b068eaa4095cb0 | |
parent | c4db3ea4f2912288256f55d16dffe225abbb72e8 (diff) | |
download | coreclr-f11f3d73eb432b1dc4c42df6eb1e1fb099222730.tar.gz coreclr-f11f3d73eb432b1dc4c42df6eb1e1fb099222730.tar.bz2 coreclr-f11f3d73eb432b1dc4c42df6eb1e1fb099222730.zip |
EventPipe: Prepend variable length field sizes (#11600)
* Write the size in bytes of the stack before the stack contents.
* Specify the size of the metadata payload explicitly in the file.
-rw-r--r-- | src/vm/eventpipeconfiguration.cpp | 6 | ||||
-rw-r--r-- | src/vm/eventpipeeventinstance.cpp | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/vm/eventpipeconfiguration.cpp b/src/vm/eventpipeconfiguration.cpp index fb264e2bc3..7ce06badff 100644 --- a/src/vm/eventpipeconfiguration.cpp +++ b/src/vm/eventpipeconfiguration.cpp @@ -336,7 +336,7 @@ EventPipeEventInstance* EventPipeConfiguration::BuildEventMetadataEvent(EventPip const GUID &providerID = sourceEvent.GetProvider()->GetProviderID(); unsigned int eventID = sourceEvent.GetEventID(); unsigned int eventVersion = sourceEvent.GetEventVersion(); - unsigned int instancePayloadSize = sizeof(providerID) + sizeof(eventID) + sizeof(eventVersion) + payloadLength; + unsigned int instancePayloadSize = sizeof(providerID) + sizeof(eventID) + sizeof(eventVersion) + sizeof(payloadLength) + payloadLength; // Allocate the payload. BYTE *pInstancePayload = new BYTE[instancePayloadSize]; @@ -356,6 +356,10 @@ EventPipeEventInstance* EventPipeConfiguration::BuildEventMetadataEvent(EventPip memcpy(currentPtr, &eventVersion, sizeof(eventVersion)); currentPtr += sizeof(eventVersion); + // Write the size of the metadata. + memcpy(currentPtr, &payloadLength, sizeof(payloadLength)); + currentPtr += sizeof(payloadLength); + // Write the incoming payload data. memcpy(currentPtr, pPayloadData, payloadLength); diff --git a/src/vm/eventpipeeventinstance.cpp b/src/vm/eventpipeeventinstance.cpp index dc84c04178..4527ed5b26 100644 --- a/src/vm/eventpipeeventinstance.cpp +++ b/src/vm/eventpipeeventinstance.cpp @@ -101,6 +101,7 @@ void EventPipeEventInstance::FastSerialize(FastSerializer *pSerializer, StreamLa sizeof(m_threadID) + // Thread ID sizeof(m_timeStamp) + // TimeStamp m_dataLength + // Event payload data length + sizeof(unsigned int) + // Prepended stack payload size in bytes m_stackContents.GetSize(); // Stack payload size // Write the size of the event to the file. @@ -121,10 +122,14 @@ void EventPipeEventInstance::FastSerialize(FastSerializer *pSerializer, StreamLa pSerializer->WriteBuffer(m_pData, m_dataLength); } + // Write the size of the stack in bytes. + unsigned int stackSize = m_stackContents.GetSize(); + pSerializer->WriteBuffer((BYTE*)&stackSize, sizeof(stackSize)); + // Write the stack if present. - if(m_stackContents.GetSize() > 0) + if(stackSize > 0) { - pSerializer->WriteBuffer(m_stackContents.GetPointer(), m_stackContents.GetSize()); + pSerializer->WriteBuffer(m_stackContents.GetPointer(), stackSize); } } |