summaryrefslogtreecommitdiff
path: root/src/vm/eventpipe.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/vm/eventpipe.h')
-rw-r--r--src/vm/eventpipe.h85
1 files changed, 82 insertions, 3 deletions
diff --git a/src/vm/eventpipe.h b/src/vm/eventpipe.h
index fa7d734280..bac7be6ac8 100644
--- a/src/vm/eventpipe.h
+++ b/src/vm/eventpipe.h
@@ -29,6 +29,69 @@ typedef void (*EventPipeCallback)(
void *FilterData,
void *CallbackContext);
+struct EventData
+{
+public:
+ unsigned long Ptr;
+ unsigned int Size;
+ unsigned int Reserved;
+};
+
+class EventPipeEventPayload
+{
+private:
+ BYTE *m_pData;
+ EventData **m_pEventData;
+ unsigned int m_eventDataCount;
+ unsigned int m_size;
+ bool m_allocatedData;
+
+ // If the data is stored only as an array of EventData objects, create a flat buffer and copy into it
+ void Flatten();
+
+public:
+ // Build this payload with a flat buffer inside
+ EventPipeEventPayload(BYTE *pData, unsigned int length);
+
+ // Build this payload to contain an array of EventData objects
+ EventPipeEventPayload(EventData **pEventData, unsigned int eventDataCount);
+
+ // If a buffer was allocated internally, delete it
+ ~EventPipeEventPayload();
+
+ // Copy the data (whether flat or array of objects) into a flat buffer at pDst
+ // Assumes that pDst points to an appropriatly sized buffer
+ void CopyData(BYTE *pDst);
+
+ // Get the flat formatted data in this payload
+ // This method will allocate a buffer if it does not already contain flattened data
+ // This method will return NULL on OOM if a buffer needed to be allocated
+ BYTE* GetFlatData();
+
+ // Return true is the data is stored in a flat buffer
+ bool IsFlattened() const
+ {
+ LIMITED_METHOD_CONTRACT;
+
+ return m_pData != NULL;
+ }
+
+ // The the size of buffer needed to contain the stored data
+ unsigned int GetSize() const
+ {
+ LIMITED_METHOD_CONTRACT;
+
+ return m_size;
+ }
+
+ EventData** GetEventDataArray() const
+ {
+ LIMITED_METHOD_CONTRACT;
+
+ return m_pEventData;
+ }
+};
+
class StackContents
{
private:
@@ -181,15 +244,19 @@ class EventPipe
static bool Enabled();
// Create a provider.
- static EventPipeProvider* CreateProvider(const GUID &providerID, EventPipeCallback pCallbackFunction = NULL, void *pCallbackData = NULL);
+ static EventPipeProvider* CreateProvider(const SString &providerName, EventPipeCallback pCallbackFunction = NULL, void *pCallbackData = NULL);
// Delete a provider.
static void DeleteProvider(EventPipeProvider *pProvider);
- // Write out an event.
+ // Write out an event from a flat buffer.
// Data is written as a serialized blob matching the ETW serialization conventions.
static void WriteEvent(EventPipeEvent &event, BYTE *pData, unsigned int length, LPCGUID pActivityId = NULL, LPCGUID pRelatedActivityId = NULL);
+ // Write out an event from an EventData array.
+ // Data is written as a serialized blob matching the ETW serialization conventions.
+ static void WriteEvent(EventPipeEvent &event, EventData **pEventData, unsigned int eventDataCount, LPCGUID pActivityId = NULL, LPCGUID pRelatedActivityId = NULL);
+
// Write out a sample profile event.
static void WriteSampleProfileEvent(Thread *pSamplingThread, EventPipeEvent *pEvent, Thread *pTargetThread, StackContents &stackContents, BYTE *pData = NULL, unsigned int length = 0);
@@ -199,6 +266,11 @@ class EventPipe
// Get the managed call stack for the specified thread.
static bool WalkManagedStackForThread(Thread *pThread, StackContents &stackContents);
+ protected:
+
+ // The counterpart to WriteEvent which after the payload is constructed
+ static void WriteEventInternal(EventPipeEvent &event, EventPipeEventPayload &payload, LPCGUID pActivityId = NULL, LPCGUID pRelatedActivityId = NULL);
+
private:
// Callback function for the stack walker. For each frame walked, this callback is invoked.
@@ -286,7 +358,7 @@ public:
static void QCALLTYPE Disable();
static INT_PTR QCALLTYPE CreateProvider(
- GUID providerID,
+ __in_z LPCWSTR providerName,
EventPipeCallback pCallbackFunc);
static INT_PTR QCALLTYPE DefineEvent(
@@ -307,6 +379,13 @@ public:
void *pData,
unsigned int length,
LPCGUID pActivityId, LPCGUID pRelatedActivityId);
+
+ static void QCALLTYPE WriteEventData(
+ INT_PTR eventHandle,
+ unsigned int eventID,
+ EventData **pEventData,
+ unsigned int eventDataCount,
+ LPCGUID pActivityId, LPCGUID pRelatedActivityId);
};
#endif // FEATURE_PERFTRACING