static ETWEvent FromTraceEvent(TraceEvent item, Dictionary<string,string> additionalProperties) { var data = new Dictionary<string, object>(); for (var i = 0; i < item.PayloadNames.Length; i++) data.Add(item.PayloadNames[i], item.PayloadValue(i)); if (additionalProperties != null) { foreach (var property in additionalProperties) { if (!data.ContainsKey(property.Key)) data.Add(property.Key, property.Value); } } return new ETWEvent { Provider = item.ProviderName, EventName = item.EventName, EventId = (ushort)item.ID, Message = item.FormattedMessage ?? "none", Level = item.Level.ToString(), ActivityId = item.ActivityID, Timestamp = item.TimeStamp.ToUniversalTime(), Fields = data }; }
public ContextSwitch(TraceEvent sw) { // Old thread id & process id this.OldThreadId = (int)sw.PayloadValue(0); this.OldProcessId = (int)sw.PayloadValue(1); this.NewThreadId = (int)sw.PayloadValue(3); this.NewProcessId = (int)sw.PayloadValue(4); this.State = (ThreadState)sw.PayloadValue(13); this.ProcessorNumber = sw.ProcessorNumber; this.TimeStamp = sw.TimeStamp; this.TimeStamp100ns = sw.TimeStamp100ns; // Multiply by 10 to adjust the time as 100ns this.NewThreadWaitTime = (int)sw.PayloadValue(15) * 10; }
void OnDxgkrnlDmaPacketStop(TraceEvent obj) { Debug.Assert(obj.EventName == "DmaPacket/Stop"); Debug.Assert(obj.PayloadNames[0] == "hContext"); ulong hContext = (ulong)obj.PayloadValue(0); Debug.Assert(obj.PayloadNames[1] == "PacketType"); int packetType = (int)obj.PayloadValue(1); Debug.Assert(obj.PayloadNames[2] == "uliCompletionId"); long submissionId = (long)obj.PayloadValue(2); Debug.Assert(obj.PayloadNames[3] == "ulQueueSubmitSequence"); int queueSubmitSequence = (int)obj.PayloadValue(3); ContextInfo context = FindOrCreateContext(hContext); DmaPacket packet = null; if (!context.DmaLookup.ContainsKey(submissionId)) { // End packet for something we don't about, drop it return; } packet = context.DmaLookup[submissionId]; packet.End = obj.TimeStamp; }
void OnDxgkrnlVSyncInterrupt(TraceEvent obj) { Debug.Assert(obj.EventName == "VSyncInterrupt" && obj.PayloadNames.Length == 3); ulong pDxgiAdapter = (ulong)obj.PayloadValue(0); int vidPnTargetId = (int)obj.PayloadValue(1); long scannedPhysicalAddress = (long)obj.PayloadValue(2); }
void OnDxgkrnlDmaPacketInfo(TraceEvent obj) { Debug.Assert(obj.EventName == "DmaPacket" && (int)obj.Opcode == 0); Debug.Assert(obj.PayloadNames[0] == "hContext"); ulong hContext = (ulong)obj.PayloadValue(0); ContextInfo context = FindOrCreateContext(hContext); }
void OnDxgkrnlDmaPacketStart(TraceEvent obj) { Debug.Assert(obj.EventName == "DmaPacket/Start" && obj.PayloadNames.Length == 7); Debug.Assert(obj.PayloadNames[0] == "hContext"); ulong hContext = (ulong)obj.PayloadValue(0); Debug.Assert(obj.PayloadNames[2] == "PacketType"); int packetType = (int)obj.PayloadValue(2); Debug.Assert(obj.PayloadNames[3] == "uliSubmissionId"); long submissionId = (long)obj.PayloadValue(3); Debug.Assert(obj.PayloadNames[4] == "ulQueueSubmitSequence"); int queueSubmitSequence = (int)obj.PayloadValue(4); ContextInfo context = FindOrCreateContext(hContext); DmaPacket packet = null; if (context.DmaLookup.ContainsKey(submissionId)) { packet = context.DmaLookup[submissionId]; } else { packet = new DmaPacket(); packet.SubmissionId = submissionId; packet.QueueSubmitSequence = queueSubmitSequence; packet.PacketType = packetType; context.DmaPackets.Add(packet); context.DmaLookup.Add(submissionId, packet); } packet.Start = obj.TimeStamp; }
void OnDxgkrnlDpiReportAdapter(TraceEvent obj) { Debug.Assert(obj.EventName == "DpiReportAdapter" && obj.PayloadNames.Length == 12); Debug.Assert(obj.PayloadNames[0] == "pDxgAdapter"); ulong pDxgiAdapter = (ulong)obj.PayloadValue(0); if (!adapterLookup.ContainsKey(pDxgiAdapter)) { Debug.Assert(false); return; } AdapterInfo adapter = adapterLookup[pDxgiAdapter]; Debug.Assert(obj.PayloadNames[6] == "VendorID"); adapter.VendorID = (int)obj.PayloadValue(6); Debug.Assert(obj.PayloadNames[11] == "AdapterLuid"); adapter.AdapterLuid = (long)obj.PayloadValue(11); }
void OnDxgkrnlDeviceStart(TraceEvent obj) { Debug.Assert(obj.EventName == "Device/DC_Start" && obj.PayloadNames.Length == 6); Debug.Assert(obj.PayloadNames[0] == "hProcessId"); int processId = (int)(UInt64)obj.PayloadValue(0); Debug.Assert(obj.PayloadNames[1] == "pDxgAdapter"); ulong pDxgAdapter = (ulong)obj.PayloadValue(1); Debug.Assert(obj.PayloadNames[3] == "hDevice"); ulong hDevice = (ulong)obj.PayloadValue(3); // Make sure the device doesn't already exist (error if it does) if (deviceLookup.ContainsKey(hDevice)) { Debug.Assert(false); return; } DeviceInfo device = new DeviceInfo(); AllDevices.Add(device); deviceLookup.Add(hDevice, device); device.hDevice = hDevice; device.Adapter = FindOrCreateAdapter(pDxgAdapter); device.Process = FindOrCreateProcess(processId); }
void OnDxgkrnlAdapterStart(TraceEvent obj) { Debug.Assert(obj.EventName == "Adapter/DC_Start" && obj.PayloadNames.Length == 27); Debug.Assert(obj.PayloadNames[1] == "pDxgAdapter"); ulong pDxgAdapter = (ulong)obj.PayloadValue(1); if (adapterLookup.ContainsKey(pDxgAdapter)) { Debug.Assert(false); return; } AdapterInfo adapter = new AdapterInfo(); AllAdapters.Add(adapter); adapterLookup.Add(pDxgAdapter, adapter); adapter.pDxgiAdapter = pDxgAdapter; Debug.Assert(obj.PayloadNames[2] == "NbVidPnSources"); adapter.NumVidPnSources = (int)obj.PayloadValue(2); Debug.Assert(obj.PayloadNames[22] == "PagingNode"); adapter.PagingNode = (int)obj.PayloadValue(22); Debug.Assert(obj.PayloadNames[25] == "AdapterType"); adapter.AdapterType = (AdapterType)(int)obj.PayloadValue(25); }