diff options
author | Adam Sitnik <adam.sitnik@gmail.com> | 2018-02-02 23:07:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-02 23:07:25 +0100 |
commit | f6ba335278bb966e8e5f9cd33f51818c6fac44fa (patch) | |
tree | 34f19451c962381c3d834fa8db5f334556390756 /src/vm/eventpipeeventinstance.cpp | |
parent | 70bf6a4586b3cad9cf8cc26ca85ec6d552123202 (diff) | |
download | coreclr-f6ba335278bb966e8e5f9cd33f51818c6fac44fa.tar.gz coreclr-f6ba335278bb966e8e5f9cd33f51818c6fac44fa.tar.bz2 coreclr-f6ba335278bb966e8e5f9cd33f51818c6fac44fa.zip |
Event Pipe File V3 (#16107)
* write missing information to the event pipe file (pointer size to make it work fo x86)
* define where the events start, not only where they end
* include process Id in the event pipe file, bump the version so old consumers get clear error message
* write the missing EndObject tag to close the header
* include expected CPU sampling rate in the event pipe header file
* include keywords in V3 of EventPipe metadata, fixes #11934
* remove forward references
* entry object comes after the header and ends after it's data, before the event block objects
* introduce event block
* fix the GC contracts
* generate metadata ids
* end the file with null reference tag
* getting it work
* 4 byte alignment of serialized event data
* Revert "include keywords in V3 of EventPipe metadata, fixes #11934"
This reverts commit 98ef2f588e271f928fd051e96da526dc1e0f017c.
* remove event Id and event version from metadata buffer (it was duplicated with native code)
* increase the block size to be the same as buffer size
* Write the last event block to the file after disabling the event pipe, right after last events
* include the sife in itself
* the native part was supposed to not duplicate the event id and version, not manged
* ensure 4 byte alignment
* build metadata when it's not provided, so payload is never empty (no need to serialize length)
* this todo is no longer valid
* don't align everything, just the content of event block as suggested by @vancem
* improvements after code review
* update TraceEvent dependency, make the test verify new feature
* InterlockedIncrement(Int32) is not available for non-Windows OSes
* code improvements after Skype code review from @jorive
Diffstat (limited to 'src/vm/eventpipeeventinstance.cpp')
-rw-r--r-- | src/vm/eventpipeeventinstance.cpp | 87 |
1 files changed, 9 insertions, 78 deletions
diff --git a/src/vm/eventpipeeventinstance.cpp b/src/vm/eventpipeeventinstance.cpp index 51bd4ce8a7..023b9b2aa9 100644 --- a/src/vm/eventpipeeventinstance.cpp +++ b/src/vm/eventpipeeventinstance.cpp @@ -65,60 +65,20 @@ EventPipeEventInstance::EventPipeEventInstance( #endif // _DEBUG } -StackContents* EventPipeEventInstance::GetStack() +unsigned int EventPipeEventInstance::GetAlignedTotalSize() const { - LIMITED_METHOD_CONTRACT; - - return &m_stackContents; -} - -EventPipeEvent* EventPipeEventInstance::GetEvent() const -{ - LIMITED_METHOD_CONTRACT; - - return m_pEvent; -} - -LARGE_INTEGER EventPipeEventInstance::GetTimeStamp() const -{ - LIMITED_METHOD_CONTRACT; - - return m_timeStamp; -} - -BYTE* EventPipeEventInstance::GetData() const -{ - LIMITED_METHOD_CONTRACT; - - return m_pData; -} - -unsigned int EventPipeEventInstance::GetLength() const -{ - LIMITED_METHOD_CONTRACT; - - return m_dataLength; -} - -void EventPipeEventInstance::FastSerialize(FastSerializer *pSerializer, StreamLabel metadataLabel) -{ - CONTRACTL + CONTRACT(unsigned int) { NOTHROW; GC_NOTRIGGER; MODE_ANY; + POSTCONDITION(RETVAL % ALIGNMENT_SIZE == 0); } - CONTRACTL_END; - -#ifdef EVENTPIPE_EVENT_MARKER - // Useful for diagnosing serialization bugs. - const unsigned int value = 0xDEADBEEF; - pSerializer->WriteBuffer((BYTE*)&value, sizeof(value)); -#endif + CONTRACT_END; // Calculate the size of the total payload so that it can be written to the file. unsigned int payloadLength = - sizeof(metadataLabel) + + sizeof(m_metadataId) + // Metadata ID sizeof(m_threadID) + // Thread ID sizeof(m_timeStamp) + // TimeStamp sizeof(m_activityId) + // Activity ID @@ -128,42 +88,13 @@ void EventPipeEventInstance::FastSerialize(FastSerializer *pSerializer, StreamLa sizeof(unsigned int) + // Prepended stack payload size in bytes m_stackContents.GetSize(); // Stack payload size - // Write the size of the event to the file. - pSerializer->WriteBuffer((BYTE*)&payloadLength, sizeof(payloadLength)); - - // Write the metadata label. - pSerializer->WriteBuffer((BYTE*)&metadataLabel, sizeof(metadataLabel)); - - // Write the thread ID. - pSerializer->WriteBuffer((BYTE*)&m_threadID, sizeof(m_threadID)); - - // Write the timestamp. - pSerializer->WriteBuffer((BYTE*)&m_timeStamp, sizeof(m_timeStamp)); - - // Write the activity id. - pSerializer->WriteBuffer((BYTE*)&m_activityId, sizeof(m_activityId)); - - // Write the related activity id. - pSerializer->WriteBuffer((BYTE*)&m_relatedActivityId, sizeof(m_relatedActivityId)); - - // Write the data payload size. - pSerializer->WriteBuffer((BYTE*)&m_dataLength, sizeof(m_dataLength)); - - // Write the event data payload. - if(m_dataLength > 0) + // round up to ALIGNMENT_SIZE bytes + if (payloadLength % ALIGNMENT_SIZE != 0) { - pSerializer->WriteBuffer(m_pData, m_dataLength); + payloadLength += ALIGNMENT_SIZE - (payloadLength % ALIGNMENT_SIZE); } - // 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(stackSize > 0) - { - pSerializer->WriteBuffer(m_stackContents.GetPointer(), stackSize); - } + RETURN payloadLength; } #ifdef _DEBUG |