protected override void EnumerateTemplates(Func <string, string, EventFilterResponse> eventsToObserve, Action <TraceEvent> callback) { if (s_templates == null) { var templates = new TraceEvent[20]; templates[0] = new MarkTraceData(null, 1, 65533, "Mark", new Guid(), 0, "", ProviderGuid, ProviderName); templates[1] = new EmptyTraceData(null, 2, 1, "Tracing", new Guid(), 1, "Start", ProviderGuid, ProviderName); templates[2] = new EmptyTraceData(null, 3, 1, "Tracing", new Guid(), 2, "Stop", ProviderGuid, ProviderName); templates[3] = new EmptyTraceData(null, 4, 2, "Rundown", new Guid(), 1, "Start", ProviderGuid, ProviderName); templates[4] = new EmptyTraceData(null, 5, 2, "Rundown", new Guid(), 2, "Stop", ProviderGuid, ProviderName); templates[5] = new EmptyTraceData(null, 6, 65528, "WaitForIdle", new Guid(), 0, "", ProviderGuid, ProviderName); templates[6] = new CommandLineParametersTraceData(null, 10, 65524, "CommandLineParameters", new Guid(), 0, "", ProviderGuid, ProviderName); templates[7] = new SessionParametersTraceData(null, 11, 65523, "SessionParameters", new Guid(), 0, "", ProviderGuid, ProviderName); templates[8] = new KernelEnableParametersTraceData(null, 12, 65522, "KernelEnableParameters", new Guid(), 0, "", ProviderGuid, ProviderName); templates[9] = new ClrEnableParametersTraceData(null, 13, 65521, "ClrEnableParameters", new Guid(), 0, "", ProviderGuid, ProviderName); templates[10] = new ProviderEnableParametersTraceData(null, 14, 65520, "ProviderEnableParameters", new Guid(), 0, "", ProviderGuid, ProviderName); templates[11] = new StartAndStopTimesTraceData(null, 15, 65519, "StartAndStopTimes", new Guid(), 0, "", ProviderGuid, ProviderName); templates[12] = new DebugMessageTraceData(null, 16, 65518, "DebugMessage", new Guid(), 0, "", ProviderGuid, ProviderName); templates[13] = new CpuCountersConfiguredTraceData(null, 17, 65517, "CpuCountersConfigured", new Guid(), 0, "", ProviderGuid, ProviderName); templates[14] = new TickTraceData(null, 18, 65516, "Tick", new Guid(), 0, "", ProviderGuid, ProviderName); templates[15] = new StopReasonTraceData(null, 19, 65515, "StopReason", new Guid(), 0, "", ProviderGuid, ProviderName); templates[16] = new EmptyTraceData(null, 20, 65514, "StopTriggerSessionStart", new Guid(), 0, "", ProviderGuid, ProviderName); templates[17] = new StopTriggerDebugMessageTraceData(null, 21, 65513, "StopTriggerDebugMessage", new Guid(), 0, "", ProviderGuid, ProviderName); templates[18] = new PerfViewLogTraceData(null, 22, 65512, "PerfViewLog", new Guid(), 0, "", ProviderGuid, ProviderName); templates[19] = new TriggerHeapSnapshotTraceData(null, 23, 65511, "TriggerHeapSnapshot", new Guid(), 0, "", ProviderGuid, ProviderName); s_templates = templates; } foreach (var template in s_templates) { if (eventsToObserve == null || eventsToObserve(template.ProviderName, template.EventName) == EventFilterResponse.AcceptEvent) { callback(template); } } }
protected internal override void EnumerateTemplates(Func <string, string, EventFilterResponse> eventsToObserve, Action <TraceEvent> callback) { if (s_templates == null) { var templates = new TraceEvent[10]; templates[0] = new DbgIDRSDSTraceData(null, 0xFFFF, 0, "ImageID", ImageIDTaskGuid, DBGID_LOG_TYPE_RSDS, "DbgID_RSDS", ProviderGuid, ProviderName); templates[1] = new ImageIDTraceData(null, 0xFFFF, 0, "ImageID", ImageIDTaskGuid, DBGID_LOG_TYPE_IMAGEID, "Info", ProviderGuid, ProviderName); templates[2] = new FileVersionTraceData(null, 0xFFFF, 0, "ImageID", ImageIDTaskGuid, DBGID_LOG_TYPE_FILEVERSION, "FileVersion", ProviderGuid, ProviderName); templates[3] = new EmptyTraceData(null, 0xFFFF, 0, "ImageID", ImageIDTaskGuid, DBGID_LOG_TYPE_NONE, "None", ProviderGuid, ProviderName); templates[4] = new EmptyTraceData(null, 0xFFFF, 0, "ImageID", ImageIdTaskGuid, 37, "Opcode37", ProviderGuid, ProviderName); templates[5] = new WinSatXmlTraceData(null, 0xFFFF, 0, "WinSat", WinSatTaskGuid, 33, "WinSPR", ProviderGuid, ProviderName); templates[6] = new WinSatXmlTraceData(null, 0xFFFF, 0, "WinSat", WinSatTaskGuid, 35, "Metrics", ProviderGuid, ProviderName); templates[7] = new WinSatXmlTraceData(null, 0xFFFF, 0, "WinSat", WinSatTaskGuid, 37, "SystemConfig", ProviderGuid, ProviderName); templates[8] = new EmptyTraceData(null, 0xFFFF, 0, "MetaData", MetaDataTaskGuid, 32, "EventInfo", ProviderGuid, ProviderName); templates[9] = new EmptyTraceData(null, 0xFFFF, 0, "MetaData", MetaDataTaskGuid, 33, "EventMapInfo", ProviderGuid, ProviderName); s_templates = templates; } foreach (var template in s_templates) { if (eventsToObserve == null || eventsToObserve(template.ProviderName, template.EventName) == EventFilterResponse.AcceptEvent) { callback(template); } } }
public void DispatcherTests() { const int IterationCount = 2000; var asParserServices = (ITraceParserServices)m_dispatcher; var curCallbackCount = m_dispatcher.DistinctCallbackCount(); Output.WriteLine("Callback Count {0}", curCallbackCount); var r = new Random(10); bool verbose = false; for (int i = 1; i < IterationCount; i++) { if (i == -1 || i == -2) { verbose = true; Trace.WriteLine("**** ITERATION " + i); Trace.WriteLine(Dump()); Trace.WriteLine(m_dispatcher.DumpHash()); } Assert.True(m_dispatcher.TemplateLength() <= 1024); if (i % 128 == 0) { Trace.WriteLine("Callback Count " + m_dispatcher.DistinctCallbackCount()); Trace.WriteLine("templates.Length " + m_dispatcher.TemplateLength()); } if (m_activeTemplates.Count < 470 && (m_activeTemplates.Count == 0 || r.Next(100) < 51)) { if (r.Next(5) != 0 || m_activeTemplates.Count == 0) { var guid = new Guid(i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // sometimes add a brand new event var newTemplate = new EmptyTraceData(MakeTarget(i), r.Next(256), 0, "MyTask" + i.ToString(), Guid.Empty, 0, "", guid, "Test"); m_activeTemplates.Add(newTemplate); if (verbose) { Trace.WriteLine(string.Format("Adding new event {0} {1} {2}", newTemplate.GetHashCode(), newTemplate.ProviderGuid, newTemplate.eventID)); } asParserServices.RegisterEventTemplate(newTemplate); var newCallbackCount = m_dispatcher.DistinctCallbackCount(); Assert.Equal(curCallbackCount + 1, newCallbackCount); curCallbackCount = newCallbackCount; } else { // sometimes create another client for the same event. var toCloneIdx = r.Next(m_activeTemplates.Count); var toClone = m_activeTemplates[toCloneIdx]; var newTemplate = new EmptyTraceData(MakeTarget(i), (int)toClone.eventID, 0, "MyTask" + i.ToString(), Guid.Empty, 0, "", toClone.ProviderGuid, "Test"); m_repeatTemplates.Add(newTemplate); if (verbose) { Trace.WriteLine(string.Format("cloning event {0} {1} {2}", newTemplate.GetHashCode(), newTemplate.ProviderGuid, newTemplate.eventID)); } asParserServices.RegisterEventTemplate(newTemplate); var newCallbackCount = m_dispatcher.DistinctCallbackCount(); Assert.Equal(curCallbackCount, newCallbackCount); curCallbackCount = newCallbackCount; } } else { // Remove an entry at random. var toRemoveIdx = r.Next(m_activeTemplates.Count + m_repeatTemplates.Count); EmptyTraceData toRemove; if (toRemoveIdx < m_activeTemplates.Count) { toRemove = m_activeTemplates[toRemoveIdx]; m_activeTemplates.RemoveAt(toRemoveIdx); // If there are any repeated entries make it a new active. var replacementIdx = m_repeatTemplates.FindIndex(template => template.ProviderGuid == toRemove.ProviderGuid && template.eventID == toRemove.eventID); if (0 <= replacementIdx) { m_activeTemplates.Add(m_repeatTemplates[replacementIdx]); m_repeatTemplates.RemoveAt(replacementIdx); } } else { toRemoveIdx -= m_activeTemplates.Count; toRemove = m_repeatTemplates[toRemoveIdx]; m_repeatTemplates.RemoveAt(toRemoveIdx); } if (verbose) { Trace.WriteLine(string.Format("Removing event {0} {1} {2}", toRemove.GetHashCode(), toRemove.ProviderGuid, toRemove.eventID)); } m_inactiveTemplates.Add(toRemove); asParserServices.UnregisterEventTemplate(toRemove.Target, (int)toRemove.eventID, toRemove.ProviderGuid); curCallbackCount = m_dispatcher.DistinctCallbackCount(); } RunTest(); } // Remove all the rest. foreach (var toRemove in m_activeTemplates) { asParserServices.UnregisterEventTemplate(toRemove.Target, (int)toRemove.eventID, toRemove.ProviderGuid); } foreach (var toRemove in m_repeatTemplates) { asParserServices.UnregisterEventTemplate(toRemove.Target, (int)toRemove.eventID, toRemove.ProviderGuid); } Output.WriteLine("Callback Count {0}", m_dispatcher.DistinctCallbackCount()); }
void Target(EmptyTraceData data) { Assert.True(m_visited.Add(data)); }
private static void OnExceptionEnd(EmptyTraceData obj) { }