예제 #1
0
        public EventPipeEventSourceV1(Deserializer deserializer, string fileName, int version)
            : base(deserializer)
        {
            // V1 EventPipe doesn't have process info.
            // Since it's from a single process, use the file name as the process name.
            _processName = Path.GetFileNameWithoutExtension(fileName);
            _processId   = 0;
            _version     = version;

            // V1 EventPipe doesn't have osVersion, cpuSpeedMHz, pointerSize, numberOfProcessors
            osVersion          = new Version("0.0.0.0");
            cpuSpeedMHz        = 10;
            pointerSize        = 8; // V1 EventPipe only supports Linux which is x64 only.
            numberOfProcessors = 1;

            // We need to read the header to get the sync time information here
            ReadEventPipeTimeInfo();

            var mem = (TraceEventNativeMethods.EVENT_RECORD *)Marshal.AllocHGlobal(sizeof(TraceEventNativeMethods.EVENT_RECORD));

            *mem = default(TraceEventNativeMethods.EVENT_RECORD);
            _header = mem;

            _eventParser = new EventPipeTraceEventParser(this);
        }
예제 #2
0
        /// <summary>
        /// Given the EventPIpe metaData header and a stream pointing at the serialized meta-data for the parameters for the
        /// event, create a new  DynamicTraceEventData that knows how to parse that event.
        /// ReaderForParameters.Current is advanced past the parameter information.
        /// </summary>
        private DynamicTraceEventData ReadEventParametersAndBuildTemplate(EventPipeEventMetaDataHeader eventMetaDataHeader, PinnedStreamReader readerForParameters)
        {
            int    opcode;
            string opcodeName;

            EventPipeTraceEventParser.GetOpcodeFromEventName(eventMetaDataHeader.EventName, out opcode, out opcodeName);

            DynamicTraceEventData.PayloadFetchClassInfo classInfo = null;
            DynamicTraceEventData template = new DynamicTraceEventData(null, eventMetaDataHeader.EventId, 0, eventMetaDataHeader.EventName, Guid.Empty, opcode, opcodeName, eventMetaDataHeader.ProviderId, eventMetaDataHeader.ProviderName);

            // If the metadata contains no parameter metadata, don't attempt to read it.
            if (!eventMetaDataHeader.ContainsParameterMetadata)
            {
                template.payloadNames   = new string[0];
                template.payloadFetches = new DynamicTraceEventData.PayloadFetch[0];
                return(template);
            }

            // Read the count of event payload fields.
            int fieldCount = readerForParameters.ReadInt32();

            Debug.Assert(0 <= fieldCount && fieldCount < 0x4000);

            if (fieldCount > 0)
            {
                // Recursively parse the metadata, building up a list of payload names and payload field fetch objects.
                classInfo = ParseFields(readerForParameters, fieldCount);
            }
            else
            {
                classInfo = new DynamicTraceEventData.PayloadFetchClassInfo()
                {
                    FieldNames   = new string[0],
                    FieldFetches = new DynamicTraceEventData.PayloadFetch[0]
                };
            }

            template.payloadNames   = classInfo.FieldNames;
            template.payloadFetches = classInfo.FieldFetches;

            return(template);
        }