summaryrefslogtreecommitdiff
path: root/src/vm/eventpipefile.h
diff options
context:
space:
mode:
authorJosé Rivero <jorive@microsoft.com>2019-04-02 07:06:42 -0700
committerGitHub <noreply@github.com>2019-04-02 07:06:42 -0700
commit40dda195590873d18236bfbc7742bb6fe7305730 (patch)
tree4c45036684f5c4c2cf6d38f19a95626ac5fc2082 /src/vm/eventpipefile.h
parentd6dad7520ea0bac3894e908835d0321075df822d (diff)
downloadcoreclr-40dda195590873d18236bfbc7742bb6fe7305730.tar.gz
coreclr-40dda195590873d18236bfbc7742bb6fe7305730.tar.bz2
coreclr-40dda195590873d18236bfbc7742bb6fe7305730.zip
[EventPipe] Streaming events out-of-proc using IPC (#23448)
- There was a race condition on EventPipe::Disable where we deallocated the s_pSession and set it to NULL, but there was still a thread waiting to write and dereference the null pointer. Now, we check that the session is not null. - Added a new attach event to be handled to the Diagnostic server: Add streaming functionality (Syncronus) #23299 - On Linux, IPC was failing when delete was invoked because we were using new (std::nothrow) instead of new (nothrow) when allocating the newly connected clients/streams. I have replaced the call with new. This fixed #23580 - Move multiFileTraceLengthInSeconds out of the EventPipeSession. - Unlink previously existing socket. - EventPipeBlock: _ASSERTE was updated not to fail when data is not aligned if an error has already occurred. - Update _ASSERTE in fastserializer.cpp to take into account the the write operation could have failed.
Diffstat (limited to 'src/vm/eventpipefile.h')
-rw-r--r--src/vm/eventpipefile.h112
1 files changed, 55 insertions, 57 deletions
diff --git a/src/vm/eventpipefile.h b/src/vm/eventpipefile.h
index 29c2b19457..d99bcd1883 100644
--- a/src/vm/eventpipefile.h
+++ b/src/vm/eventpipefile.h
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
#ifndef __EVENTPIPE_FILE_H__
#define __EVENTPIPE_FILE_H__
@@ -12,87 +11,86 @@
#include "eventpipeblock.h"
#include "eventpipeeventinstance.h"
#include "fastserializableobject.h"
-#include "fastserializer.h"
-class EventPipeFile : public FastSerializableObject
-{
- public:
+class FastSerializer;
- EventPipeFile(SString &outputFilePath);
- ~EventPipeFile();
+class EventPipeFile final : public FastSerializableObject
+{
+public:
+ EventPipeFile(StreamWriter *pStreamWriter);
+ ~EventPipeFile();
- void WriteEvent(EventPipeEventInstance &instance);
+ void WriteEvent(EventPipeEventInstance &instance);
- void WriteEnd();
+ const char *GetTypeName() override
+ {
+ LIMITED_METHOD_CONTRACT;
+ return "Trace";
+ }
- const char* GetTypeName()
+ void FastSerialize(FastSerializer *pSerializer) override
+ {
+ CONTRACTL
{
- LIMITED_METHOD_CONTRACT;
- return "Trace";
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_PREEMPTIVE;
+ PRECONDITION(pSerializer != NULL);
}
+ CONTRACTL_END;
- void FastSerialize(FastSerializer *pSerializer)
- {
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_PREEMPTIVE;
- PRECONDITION(pSerializer != NULL);
- }
- CONTRACTL_END;
-
- pSerializer->WriteBuffer((BYTE*)&m_fileOpenSystemTime, sizeof(m_fileOpenSystemTime));
- pSerializer->WriteBuffer((BYTE*)&m_fileOpenTimeStamp, sizeof(m_fileOpenTimeStamp));
- pSerializer->WriteBuffer((BYTE*)&m_timeStampFrequency, sizeof(m_timeStampFrequency));
-
- // the beginning of V3
- pSerializer->WriteBuffer((BYTE*)&m_pointerSize, sizeof(m_pointerSize));
- pSerializer->WriteBuffer((BYTE*)&m_currentProcessId, sizeof(m_currentProcessId));
- pSerializer->WriteBuffer((BYTE*)&m_numberOfProcessors, sizeof(m_numberOfProcessors));
- pSerializer->WriteBuffer((BYTE*)&m_samplingRateInNs, sizeof(m_samplingRateInNs));
- }
+ pSerializer->WriteBuffer((BYTE *)&m_fileOpenSystemTime, sizeof(m_fileOpenSystemTime));
+ pSerializer->WriteBuffer((BYTE *)&m_fileOpenTimeStamp, sizeof(m_fileOpenTimeStamp));
+ pSerializer->WriteBuffer((BYTE *)&m_timeStampFrequency, sizeof(m_timeStampFrequency));
+
+ // the beginning of V3
+ pSerializer->WriteBuffer((BYTE *)&m_pointerSize, sizeof(m_pointerSize));
+ pSerializer->WriteBuffer((BYTE *)&m_currentProcessId, sizeof(m_currentProcessId));
+ pSerializer->WriteBuffer((BYTE *)&m_numberOfProcessors, sizeof(m_numberOfProcessors));
+ pSerializer->WriteBuffer((BYTE *)&m_samplingRateInNs, sizeof(m_samplingRateInNs));
+ }
- private:
+private:
+ void WriteEnd();
- unsigned int GenerateMetadataId();
+ unsigned int GenerateMetadataId();
- unsigned int GetMetadataId(EventPipeEvent &event);
+ unsigned int GetMetadataId(EventPipeEvent &event);
- void SaveMetadataId(EventPipeEvent &event, unsigned int metadataId);
+ void SaveMetadataId(EventPipeEvent &event, unsigned int metadataId);
- void WriteToBlock(EventPipeEventInstance &instance, unsigned int metadataId);
+ void WriteToBlock(EventPipeEventInstance &instance, unsigned int metadataId);
- // The object responsible for serialization.
- FastSerializer *m_pSerializer;
+ // The object responsible for serialization.
+ FastSerializer *m_pSerializer;
- EventPipeBlock *m_pBlock;
+ EventPipeBlock *m_pBlock;
- // The system time when the file was opened.
- SYSTEMTIME m_fileOpenSystemTime;
+ // The system time when the file was opened.
+ SYSTEMTIME m_fileOpenSystemTime;
- // The timestamp when the file was opened. Used for calculating file-relative timestamps.
- LARGE_INTEGER m_fileOpenTimeStamp;
+ // The timestamp when the file was opened. Used for calculating file-relative timestamps.
+ LARGE_INTEGER m_fileOpenTimeStamp;
- // The frequency of the timestamps used for this file.
- LARGE_INTEGER m_timeStampFrequency;
+ // The frequency of the timestamps used for this file.
+ LARGE_INTEGER m_timeStampFrequency;
- unsigned int m_pointerSize;
+ unsigned int m_pointerSize;
- unsigned int m_currentProcessId;
+ unsigned int m_currentProcessId;
- unsigned int m_numberOfProcessors;
+ unsigned int m_numberOfProcessors;
- unsigned int m_samplingRateInNs;
+ unsigned int m_samplingRateInNs;
- // The serialization which is responsible for making sure only a single event
- // or block of events gets written to the file at once.
- SpinLock m_serializationLock;
+ // The serialization which is responsible for making sure only a single event
+ // or block of events gets written to the file at once.
+ SpinLock m_serializationLock;
- // Hashtable of metadata labels.
- MapSHashWithRemove<EventPipeEvent*, unsigned int> *m_pMetadataIds;
+ // Hashtable of metadata labels.
+ MapSHashWithRemove<EventPipeEvent *, unsigned int> *m_pMetadataIds;
- Volatile<LONG> m_metadataIdCounter;
+ Volatile<LONG> m_metadataIdCounter;
};
#endif // FEATURE_PERFTRACING