├── .allstar └── binary_artifacts.yaml ├── .gitattributes ├── .gitignore ├── AUTHORS ├── CONTRIBUTING ├── CONTRIBUTORS ├── CompatibilityManifest.man ├── DelayedCreateProcess ├── DelayedCreateProcess.cpp └── make.bat ├── DummyChrome ├── DummyChrome.cpp ├── DummyChrome.sln ├── DummyChrome.vcxproj ├── DummyChrome.vcxproj.filters ├── ReadMe.md ├── dllmain.cpp ├── stdafx.cpp └── stdafx.h ├── ETWEventDemo ├── ETWEventDemo.cpp ├── ETWEventDemo.sln ├── ETWEventDemo.vcxproj ├── ETWEventDemo.vcxproj.filters ├── ReadMe.txt ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── ETWInsights ├── ETWInsights.sln ├── ETWInsights.vcxproj ├── ETWInsights.vcxproj.filters ├── README.md ├── base │ ├── base.h │ ├── base.vcxproj │ ├── base.vcxproj.filters │ ├── binary_search.h │ ├── child_process.cc │ ├── child_process.h │ ├── command_line.cc │ ├── command_line.h │ ├── error_string.cc │ ├── error_string.h │ ├── file.cc │ ├── file.h │ ├── history.h │ ├── logging.cc │ ├── logging.h │ ├── numeric_conversions.cc │ ├── numeric_conversions.h │ ├── string_utils.cc │ ├── string_utils.h │ └── types.h ├── etw_reader │ ├── etw_reader.cc │ ├── etw_reader.h │ ├── etw_reader.vcxproj │ ├── etw_reader.vcxproj.filters │ ├── generate_history_from_trace.cc │ ├── generate_history_from_trace.h │ ├── stack.h │ ├── system_history.cc │ ├── system_history.h │ └── thread_history.h └── flame_graph │ ├── clean_stack.cc │ ├── clean_stack.h │ ├── flame_graph.cc │ ├── flame_graph.h │ ├── flame_graph.vcxproj │ ├── flame_graph.vcxproj.filters │ └── main.cc ├── ETWProviders ├── ETWProviders.cpp ├── ETWProviders.rc ├── ETWProviders.sln ├── ETWProviders.vcxproj ├── ETWProviders.vcxproj.filters ├── ReadMe.txt ├── dllmain.cpp ├── etwprof.cpp ├── etwproviders.man ├── resource.h ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── EventEmitter ├── EventEmitter.cpp ├── EventEmitter.h ├── EventEmitter.ico ├── EventEmitter.rc ├── EventEmitter.sln ├── EventEmitter.vcxproj ├── EventEmitter.vcxproj.filters ├── ReadMe.txt ├── Resource.h ├── small.ico ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── LICENSE ├── LabScripts ├── ETWPMCDemo │ ├── .gitignore │ ├── ConditionalCount │ │ ├── ConditionalCount.cpp │ │ ├── ConditionalCount.sln │ │ ├── ConditionalCount.vcxproj │ │ ├── ConditionalCount.vcxproj.filters │ │ ├── OtherFile.cpp │ │ └── ReadMe.txt │ ├── etwpmc_parser.py │ └── etwpmc_record.bat ├── GPUTracing │ ├── GPUUsageByProcess.wpaProfile │ ├── GPUUsageDetails.wpaProfile │ ├── ReadMe.txt │ ├── start_tracing.bat │ └── stop_tracing.bat └── GeneralTracing │ ├── .gitignore │ ├── CPUDetailsByProcess.wpaProfile │ ├── CPUSummaryByProcess.wpaProfile │ ├── CreateExporterConfig.py │ ├── GPUDetailsByProcess.wpaProfile │ ├── GPUSummaryByProcess.wpaProfile │ ├── PrivateWorkingSetSummaryByProcess.wpaProfile │ ├── ReadMe.txt │ ├── SummarizeData.py │ ├── set_vars.bat │ ├── start_tracing.bat │ └── stop_tracing.bat ├── PowerMon ├── PowerMon.cpp ├── PowerMon.sln ├── PowerMon.vcxproj ├── PowerMon.vcxproj.filters ├── PowerStatus.cpp ├── PowerStatus.h ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── README ├── RetrieveSymbols ├── ReadMe.txt ├── RetrieveSymbols.cpp ├── RetrieveSymbols.sln ├── RetrieveSymbols.vcxproj └── RetrieveSymbols.vcxproj.filters ├── SignBinaries.bat ├── TraceProcessors ├── CPUSummary │ ├── App.config │ ├── CPUSummary.cs │ ├── CPUSummary.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config ├── HeapSnapshotCompare │ ├── App.config │ ├── HeapSnapshotCompare.cs │ ├── HeapSnapshotCompare.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config ├── IdentifyChromeProcesses │ ├── App.config │ ├── IdentifyChromeProcesses.cs │ ├── IdentifyChromeProcesses.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config ├── IdleWakeups │ ├── IdleWakeups.cs │ ├── IdleWakeups.csproj │ └── IdleWakeups.sln ├── TraceProcessors.sln └── VideoConfCPUCounters │ ├── App.config │ ├── Properties │ └── AssemblyInfo.cs │ ├── VideoConfCPUCounters.cs │ ├── VideoConfCPUCounters.csproj │ ├── etwpmc_record.bat │ └── packages.config ├── UIforETW ├── About.h ├── CPUFrequency.cpp ├── CPUFrequency.h ├── ChildProcess.cpp ├── ChildProcess.h ├── DirectoryMonitor.cpp ├── DirectoryMonitor.h ├── KeyLoggerThread.cpp ├── KeyLoggerThread.h ├── PowerStatus.cpp ├── PowerStatus.h ├── ProcessChecks.cpp ├── ReadMe.md ├── Resource.h ├── Settings.cpp ├── Settings.h ├── SpinALot32.asm ├── SpinALot64.asm ├── StackWalkFlags.txt ├── StrictRules.ruleset ├── Support.cpp ├── TraceLoggingSupport.cpp ├── TraceLoggingSupport.h ├── UIforETW.cpp ├── UIforETW.h ├── UIforETW.rc ├── UIforETW.sln ├── UIforETW.vcxproj ├── UIforETW.vcxproj.filters ├── UIforETWDlg.cpp ├── UIforETWDlg.h ├── Utility.cpp ├── Utility.h ├── Version.h ├── VersionChecker.cpp ├── VersionChecker.h ├── VersionCopy.h ├── WorkingSet.cpp ├── WorkingSet.h ├── build_static.bat ├── res │ ├── UIforETW.ico │ └── UIforETW.rc2 ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── bin ├── .gitignore ├── CPUByCommandLine.py ├── CPUUsageByCommandLine.wpaProfile ├── CPUUsageByProcess.wpaProfile ├── ETWPackSymbols.py ├── ETWTimeBuild2005.bat ├── ETWTimeBuild2010.bat ├── ExportCPUUsageSampled.wpaProfile ├── FindRandomasciiProfilePresets.py ├── HeapAnalysis.wpaProfile ├── HeapSnapshot.wpaProfile ├── IdentifyChromeProcesses.py ├── Python.sln ├── StripChromeSymbols.py ├── TestIdentifyChromeProcesses.bat ├── TransientProcessTree.wpaProfile ├── UserMarks.wpaProfile ├── VirtualFreeStacks.py ├── XperfProcessParentage.py ├── XperfProcessParentage.wpaProfile ├── bin.pyproj ├── chrome_events_win.man ├── chrome_regions_of_interest.xml ├── etw_cpuusage_longterm.bat ├── etw_gdi_longterm.bat ├── etw_handles_longterm.bat ├── etw_processes_longterm.bat ├── etwcirc.bat ├── etwcommonsettings.bat ├── etwheap.bat ├── etwheapsnapshot.bat ├── etwpmc_parser.py ├── etwpmc_record.bat ├── etwproviders.man ├── etwrecord.bat ├── etwregister.bat ├── etwsamplefast.bat ├── etwsamplenormal.bat ├── etwsampleslow.bat ├── metatrace.bat ├── readme.txt ├── startup10.wpaProfile ├── summarize_timer_intervals.py ├── timer_intervals.wpaProfile ├── trace_timer_intervals.bat └── xperf_to_collapsedstacks.py ├── excludecopy.txt ├── include └── ETWProviders │ └── etwprof.h ├── make_zip_file.py ├── package_etw.bat ├── rename_to_version.py ├── third_party ├── .gitignore ├── dbghelp.dll ├── license.txt ├── pdbcopy.exe ├── redist.txt ├── symsrv.dll └── x64 │ ├── dbghelp.dll │ ├── redist.txt │ └── symsrv.dll └── vs-chromium-project.txt /.allstar/binary_artifacts.yaml: -------------------------------------------------------------------------------- 1 | # Ignore reason: These signed files all come from a Microsoft SDK and are needed for UIforETW's functionality. 2 | ignorePaths: 3 | - third_party/dbghelp.dll 4 | - third_party/pdbcopy.exe 5 | - third_party/symsrv.dll 6 | - third_party/x64/dbghelp.dll 7 | - third_party/x64/symsrv.dll 8 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | *.aps 3 | # wpaexporter drops these 4 | *.csv 5 | *.etl 6 | *.obj 7 | *.exe 8 | *.exp 9 | *.ilk 10 | *.opensdf 11 | *.pyc 12 | *.sdf 13 | *.suo 14 | *.svg 15 | *.pdb 16 | *.user 17 | *.launchSettings.json 18 | # New Visual Studio 2015 intellisense DB files 19 | # http://blogs.msdn.com/b/vcblog/archive/2015/11/11/new-improved-and-faster-database-engine.aspx 20 | *.VC.db 21 | symsrv.yes 22 | pmc_counters_test.txt 23 | 24 | # Binaries that are built instead of committed as of commit ea32da8 25 | bin/DummyChrome.dll 26 | bin/ETWProviders.dll 27 | bin/ETWProviders64.dll 28 | bin/ETWProvidersARM64.dll 29 | lib/* 30 | 31 | # GPUView likes to drop these files when run. 32 | FuncStats.txt 33 | GuidStats.txt 34 | Log.txt 35 | present.txt 36 | *.lastcodeanalysissucceeded 37 | 38 | *Generated* 39 | 40 | # VS 2015 drops these 41 | *.VC.opendb 42 | .vs/ 43 | 44 | # Temporary flamegraph files 45 | flamegraph.txt 46 | 47 | #Created by package_etw.bat 48 | etwpackage/ 49 | etwpackage*.zip 50 | etwsymbols*.zip 51 | sourceindex.txt 52 | 53 | # Avoid shipping nuget files and others in /obj/ directories. 54 | obj/ 55 | 56 | Debug/ 57 | Release/ 58 | *DoNotShip/ 59 | ipch/ 60 | 61 | # Recommended changes for working with nuget packages 62 | 63 | # Ignore NuGet Packages 64 | *.nupkg 65 | 66 | # The packages folder can be ignored because of Package Restore 67 | **/[Pp]ackages/* 68 | 69 | # except build/, which is used as an MSBuild target. 70 | !**/[Pp]ackages/build/ 71 | 72 | # Uncomment if necessary however generally it will be regenerated when needed 73 | #!**/[Pp]ackages/repositories.config 74 | 75 | # NuGet v3's project.json files produces more ignorable files 76 | *.nuget.props 77 | *.nuget.targets 78 | 79 | # Ignore other intermediate files that NuGet might create. project.lock.json is used in conjunction 80 | # with project.json (NuGet v3); project.assets.json is used in conjunction with the PackageReference 81 | # format (NuGet v4 and .NET Core). 82 | project.lock.json 83 | project.assets.json 84 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of The UIforETW Project Authors 2 | # for copyright purposes. 3 | # This file is distinct from the CONTRIBUTORS files. 4 | # See the latter for an explanation. 5 | 6 | # Names should be added to this file as 7 | # Name or Organization 8 | # Email addresses for individuals are tracked elsewhere to avoid spam. 9 | 10 | Google Inc. 11 | Kristof Mattei 12 | Alexander Riccio 13 | Bradley Grainger 14 | Michael Winterberg 15 | Suresh Kumar Ponnusamy 16 | -------------------------------------------------------------------------------- /CONTRIBUTING: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/CONTRIBUTING -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This is the official list of people who can contribute 2 | # (and who have contributed) code to the UIforETW project 3 | # repository. 4 | # The AUTHORS file lists the copyright holders; this file 5 | # lists people. For example, Google employees are listed here 6 | # but not in AUTHORS, because Google holds the copyright. 7 | # 8 | 9 | Google Inc. 10 | Bruce Dawson 11 | Georges Khalil 12 | 13 | Kristof Mattei 14 | Alexander Riccio 15 | Bradley Grainger 16 | Michael Winterberg 17 | Suresh Kumar Ponnusamy 18 | Chris Davis -------------------------------------------------------------------------------- /CompatibilityManifest.man: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /DelayedCreateProcess/DelayedCreateProcess.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | int main(int argc, char* argv[]) 21 | { 22 | if (argc < 2) { 23 | printf("This program creates a process in a suspended state, prints its PID" 24 | " so that heap tracing can be enabled, and resumes the thread after a" 25 | " brief delay. This helps etwheapsnapshot.bat trace a process from" 26 | " birth. Only the PID is printed to stdout (for easy capture from a" 27 | " batch file) - the rest is printed to stderr.\n"); 28 | printf("Usage: %s proc_name.exe [delay_ms]\n", argv[0]); 29 | return 0; 30 | } 31 | 32 | const char* name = argv[1]; 33 | STARTUPINFOA startup_info = {sizeof(startup_info)}; 34 | PROCESS_INFORMATION process_info = {}; 35 | LARGE_INTEGER start; 36 | QueryPerformanceCounter(&start); 37 | BOOL result = CreateProcessA(name, nullptr, nullptr, nullptr, FALSE, 38 | CREATE_SUSPENDED, nullptr, nullptr, &startup_info, 39 | &process_info); 40 | 41 | if (!result) { 42 | fprintf(stderr, "CreateProcess failed.\n"); 43 | return -1; 44 | } 45 | 46 | // Print the process ID to stdout for consumption by a batch file. 47 | printf("%d\n", process_info.dwProcessId); 48 | // Print the process to stderr so that the output can be seen. 49 | fprintf(stderr, "PID is %d.\n", process_info.dwProcessId); 50 | 51 | DWORD delay = 10000; 52 | if (argc >= 3) 53 | delay = atoi(argv[2]); 54 | fprintf(stderr, "Waiting %1.3f s before letting the process run.\n", delay / 1e3); 55 | Sleep(delay); 56 | // Resume the main thread, thus starting the process. 57 | ResumeThread(process_info.hThread); 58 | fprintf(stderr, "Process is now running.\n"); 59 | 60 | // When this process is destroyed all its handles to the new process will be 61 | // cleaned up, so no cleanup is necessary. 62 | } 63 | -------------------------------------------------------------------------------- /DelayedCreateProcess/make.bat: -------------------------------------------------------------------------------- 1 | cl %~dp0DelayedCreateProcess.cpp /link /out:%~dp0..\bin\DelayedCreateProcess.exe 2 | -------------------------------------------------------------------------------- /DummyChrome/DummyChrome.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "stdafx.h" 18 | 19 | 20 | -------------------------------------------------------------------------------- /DummyChrome/DummyChrome.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DummyChrome", "DummyChrome.vcxproj", "{ECC4778A-713B-4B02-AAFD-DD09DE29C248}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {ECC4778A-713B-4B02-AAFD-DD09DE29C248}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {ECC4778A-713B-4B02-AAFD-DD09DE29C248}.Debug|Win32.Build.0 = Debug|Win32 16 | {ECC4778A-713B-4B02-AAFD-DD09DE29C248}.Release|Win32.ActiveCfg = Release|Win32 17 | {ECC4778A-713B-4B02-AAFD-DD09DE29C248}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /DummyChrome/DummyChrome.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Resource Files 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /DummyChrome/ReadMe.md: -------------------------------------------------------------------------------- 1 | This project exists solely to compile in Chrome's ETW manifest so that DummyChrome.dll can be used to register Chrome's ETW providers. 2 | This is much simpler than tracking down where Chrome is installed, especially during the early days when not all versions of Chrome have ETW providers. 3 | -------------------------------------------------------------------------------- /DummyChrome/dllmain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "stdafx.h" 18 | 19 | BOOL APIENTRY DllMain( HMODULE hModule, 20 | DWORD ul_reason_for_call, 21 | LPVOID lpReserved 22 | ) 23 | { 24 | switch (ul_reason_for_call) 25 | { 26 | case DLL_PROCESS_ATTACH: 27 | case DLL_THREAD_ATTACH: 28 | case DLL_THREAD_DETACH: 29 | case DLL_PROCESS_DETACH: 30 | break; 31 | } 32 | return TRUE; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /DummyChrome/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | #include "stdafx.h" 19 | -------------------------------------------------------------------------------- /DummyChrome/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 20 | // Windows Header Files: 21 | #include 22 | -------------------------------------------------------------------------------- /ETWEventDemo/ETWEventDemo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "stdafx.h" 18 | #include 19 | #include "ETWProviders\etwprof.h" 20 | 21 | /* 22 | This demonstrates how to use ETWProviders*.dll to emit custom ETW events. 23 | These events will be recorded by UIforETW, and the default WPA startup 24 | profile configured by UIforETW will display them in the Generic Events 25 | section. 26 | 27 | See this blog post for an early mention of these providers. 28 | 29 | https://randomascii.wordpress.com/2011/08/18/xperf-basics-recording-a-trace/ 30 | */ 31 | 32 | // Pause for a short period of time with the CPU idle. 33 | __declspec(noinline) void IdleDelay() 34 | { 35 | Sleep(10); 36 | } 37 | 38 | // Pause for a short period of time with the CPU busy. 39 | __declspec(noinline) void BusyDelay() 40 | { 41 | DWORD startTick = GetTickCount(); 42 | 43 | for (;;) 44 | { 45 | DWORD elapsed = GetTickCount() - startTick; 46 | if (elapsed > 10) 47 | break; 48 | } 49 | } 50 | 51 | int _tmain(int argc, _TCHAR* argv[]) 52 | { 53 | printf("Emitting custom ETW events that can be recorded with etwrecord.bat\n"); 54 | CETWScope timer("main"); 55 | for (int i = 0; i < 40; ++i) 56 | { 57 | ETWMarkPrintf("This is loop %d", i); 58 | ETWRenderFrameMark(); 59 | // Simulating code that does something. 60 | IdleDelay(); 61 | BusyDelay(); 62 | } 63 | 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /ETWEventDemo/ETWEventDemo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ETWEventDemo", "ETWEventDemo.vcxproj", "{2AA7F923-CF20-4BAE-9C01-1FAE9CAF842F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {2AA7F923-CF20-4BAE-9C01-1FAE9CAF842F}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {2AA7F923-CF20-4BAE-9C01-1FAE9CAF842F}.Debug|Win32.Build.0 = Debug|Win32 18 | {2AA7F923-CF20-4BAE-9C01-1FAE9CAF842F}.Debug|x64.ActiveCfg = Debug|x64 19 | {2AA7F923-CF20-4BAE-9C01-1FAE9CAF842F}.Debug|x64.Build.0 = Debug|x64 20 | {2AA7F923-CF20-4BAE-9C01-1FAE9CAF842F}.Release|Win32.ActiveCfg = Release|Win32 21 | {2AA7F923-CF20-4BAE-9C01-1FAE9CAF842F}.Release|Win32.Build.0 = Release|Win32 22 | {2AA7F923-CF20-4BAE-9C01-1FAE9CAF842F}.Release|x64.ActiveCfg = Release|x64 23 | {2AA7F923-CF20-4BAE-9C01-1FAE9CAF842F}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /ETWEventDemo/ETWEventDemo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /ETWEventDemo/ReadMe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/ETWEventDemo/ReadMe.txt -------------------------------------------------------------------------------- /ETWEventDemo/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "stdafx.h" 18 | -------------------------------------------------------------------------------- /ETWEventDemo/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "targetver.h" 20 | 21 | #include 22 | #include 23 | -------------------------------------------------------------------------------- /ETWEventDemo/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /ETWInsights/ETWInsights.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "base", "base\base.vcxproj", "{637388CA-E6E9-4D38-8DC9-CC2FE937DE24}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "etw_reader", "etw_reader\etw_reader.vcxproj", "{E1FCFE0C-B8CB-4516-9F46-54C1F73A9601}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {637388CA-E6E9-4D38-8DC9-CC2FE937DE24} = {637388CA-E6E9-4D38-8DC9-CC2FE937DE24} 11 | EndProjectSection 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flame_graph", "flame_graph\flame_graph.vcxproj", "{EE253535-588A-4ABC-A65E-8DE45E240D7F}" 14 | ProjectSection(ProjectDependencies) = postProject 15 | {E1FCFE0C-B8CB-4516-9F46-54C1F73A9601} = {E1FCFE0C-B8CB-4516-9F46-54C1F73A9601} 16 | {637388CA-E6E9-4D38-8DC9-CC2FE937DE24} = {637388CA-E6E9-4D38-8DC9-CC2FE937DE24} 17 | EndProjectSection 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|Win32 = Debug|Win32 22 | Release|Win32 = Release|Win32 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {637388CA-E6E9-4D38-8DC9-CC2FE937DE24}.Debug|Win32.ActiveCfg = Debug|Win32 26 | {637388CA-E6E9-4D38-8DC9-CC2FE937DE24}.Debug|Win32.Build.0 = Debug|Win32 27 | {637388CA-E6E9-4D38-8DC9-CC2FE937DE24}.Release|Win32.ActiveCfg = Release|Win32 28 | {637388CA-E6E9-4D38-8DC9-CC2FE937DE24}.Release|Win32.Build.0 = Release|Win32 29 | {E1FCFE0C-B8CB-4516-9F46-54C1F73A9601}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {E1FCFE0C-B8CB-4516-9F46-54C1F73A9601}.Debug|Win32.Build.0 = Debug|Win32 31 | {E1FCFE0C-B8CB-4516-9F46-54C1F73A9601}.Release|Win32.ActiveCfg = Release|Win32 32 | {E1FCFE0C-B8CB-4516-9F46-54C1F73A9601}.Release|Win32.Build.0 = Release|Win32 33 | {EE253535-588A-4ABC-A65E-8DE45E240D7F}.Debug|Win32.ActiveCfg = Debug|Win32 34 | {EE253535-588A-4ABC-A65E-8DE45E240D7F}.Debug|Win32.Build.0 = Debug|Win32 35 | {EE253535-588A-4ABC-A65E-8DE45E240D7F}.Release|Win32.ActiveCfg = Release|Win32 36 | {EE253535-588A-4ABC-A65E-8DE45E240D7F}.Release|Win32.Build.0 = Release|Win32 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /ETWInsights/ETWInsights.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | -------------------------------------------------------------------------------- /ETWInsights/README.md: -------------------------------------------------------------------------------- 1 | # ETWInsights 2 | 3 | ## flame_graph 4 | 5 | flame_graph is a command-line tool to generate a 6 | [flame graph](http://www.brendangregg.com/flamegraphs.html) from an ETW trace. 7 | 8 | Usage: `flame_graph.exe --trace [options]` 9 | 10 | Options: 11 | 12 | - `--process_name`: Only include stacks from processes with the specified name. 13 | - `--tid`: Only include stacks from the specified thread. 14 | - `--start_ts`: Only include stacks that occurred after the specified timestamp. 15 | - `--end_ts`: Only include stacks that occurred before the specified timestamp. 16 | - `--out`: Output file path. Default: .flamegraph.txt 17 | 18 | Timestamps are a number of microseconds elapsed since the beginning of the 19 | trace. 20 | 21 | `flame_graph.exe` produces a text file that tells how much time was spent in 22 | each call stack. To convert this text file to a nice-looking SVG report, use 23 | this [perl script](https://github.com/brendangregg/FlameGraph/blob/master/flamegraph.pl). 24 | -------------------------------------------------------------------------------- /ETWInsights/base/base.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | // Macro to disable the copy constructor and assignment operator. 20 | // Must be placed with the private declarations of a class. 21 | #define DISALLOW_COPY_AND_ASSIGN(ClassType) \ 22 | ClassType(const ClassType&); \ 23 | void operator=(const ClassType&) 24 | -------------------------------------------------------------------------------- /ETWInsights/base/base.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | Header Files 50 | 51 | 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | Source Files 70 | 71 | 72 | Source Files 73 | 74 | 75 | -------------------------------------------------------------------------------- /ETWInsights/base/binary_search.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | namespace base { 23 | 24 | // Finds the last element of a vector that compares smaller or equal to |val|. 25 | // @param vec the vector in which to search. 26 | // @param val the value used for comparison. 27 | // @param comparator the comparison function or function object. 28 | // @returns an iterator to the last element of |vec| that is smaller or equal 29 | // to |val|, of .end() if none exists. 30 | template 33 | auto FindSmallerOrEqual(container_type& vec, 34 | comparison_value_type& val, 35 | comparator_type comparator) -> decltype(vec.begin()) { 36 | auto it = std::upper_bound(vec.begin(), vec.end(), val, comparator); 37 | if (it == vec.begin()) 38 | return vec.end(); 39 | 40 | --it; 41 | 42 | return it; 43 | } 44 | 45 | } // namespace base 46 | -------------------------------------------------------------------------------- /ETWInsights/base/child_process.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #define WIN32_LEAN_AND_MEAN 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include "base/base.h" 26 | 27 | namespace base { 28 | 29 | // This class encapsulates running a child process and writing its output to a 30 | // file. Typical usage is: 31 | // ChildProcess child(); 32 | // child.SetOutputPath(L"output.txt"); 33 | // child.Run(L"exename.exe -arg value"); 34 | // child.WaitForCompletion(); 35 | // Run returns immediately. The destructor, GetExitCode(), and 36 | // WaitForCompletion() will all wait for the process to exit. 37 | 38 | class ChildProcess { 39 | public: 40 | ChildProcess(); 41 | // This waits for the child process to terminate. 42 | ~ChildProcess(); 43 | 44 | // Sets the path to which output will be written. 45 | void SetOutputPath(const std::wstring& output_path) { 46 | output_path_ = output_path; 47 | } 48 | 49 | // Returns true if the process started. This function returns 50 | // immediately without waiting for process completion. 51 | _Pre_satisfies_(!(this->hProcess_)) bool Run(const std::wstring& command); 52 | 53 | // This can be called even if the process doesn't start, but it will return 54 | // zero. If the process is still running it will wait until the process 55 | // returns and then get the exit code. 56 | DWORD GetExitCode(); 57 | 58 | // Waits for the process to complete its execution. This is called by the 59 | // destructor so calling it is strictly optional. 60 | void WaitForCompletion(); 61 | 62 | private: 63 | // Process, thread, and event handles have an uninitialized state of zero. 64 | // Files have an uninitialized state of INVALID_HANDLE_VALUE. Yay Windows! 65 | HANDLE hProcess_ = 0; 66 | 67 | // Output handles for the child process. 68 | HANDLE hStdOutput_ = INVALID_HANDLE_VALUE; 69 | HANDLE hStdError_ = INVALID_HANDLE_VALUE; 70 | HANDLE hStdInput_ = INVALID_HANDLE_VALUE; 71 | 72 | // Output path. 73 | std::wstring output_path_; 74 | 75 | DISALLOW_COPY_AND_ASSIGN(ChildProcess); 76 | }; 77 | 78 | } // namespace base 79 | -------------------------------------------------------------------------------- /ETWInsights/base/command_line.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "base/command_line.h" 18 | 19 | #include "base/string_utils.h" 20 | 21 | namespace base { 22 | 23 | namespace { 24 | 25 | const wchar_t kSwitchNamePrefix[] = L"--"; 26 | const size_t kSwitchNamePrefixLength = 27 | (sizeof(kSwitchNamePrefix) / sizeof(wchar_t)) - 1; 28 | 29 | void ParseCommandLine( 30 | int argc, 31 | wchar_t* argv[], 32 | std::unordered_map* switches) { 33 | std::wstring current_switch_name; 34 | for (int i = 0; i < argc; ++i) { 35 | std::wstring token(argv[i]); 36 | // Check if this is a switch name. 37 | if (base::WStringBeginsWith(token, kSwitchNamePrefix)) { 38 | // Add the previous switch name to the switch map. 39 | if (!current_switch_name.empty()) 40 | switches->insert({current_switch_name, std::wstring()}); 41 | 42 | // Keep track of the name of the current switch. 43 | current_switch_name = token.substr(kSwitchNamePrefixLength); 44 | } else if (!current_switch_name.empty()) { 45 | // This a switch value. Add it to the switch map with its name. 46 | switches->insert({current_switch_name, token}); 47 | current_switch_name.clear(); 48 | } 49 | } 50 | 51 | // If necessary, add the last switch name to the map. 52 | if (!current_switch_name.empty()) 53 | switches->insert({current_switch_name, std::wstring()}); 54 | } 55 | 56 | } // namespace 57 | 58 | CommandLine::CommandLine(int argc, wchar_t* argv[]) { 59 | ParseCommandLine(argc, argv, &switches_); 60 | } 61 | 62 | bool CommandLine::HasSwitch(const std::wstring& switch_name) const { 63 | return switches_.find(switch_name) != switches_.end(); 64 | } 65 | 66 | std::wstring CommandLine::GetSwitchValue( 67 | const std::wstring& switch_name) const { 68 | auto look = switches_.find(switch_name); 69 | if (look == switches_.end()) 70 | return std::wstring(); 71 | 72 | return look->second; 73 | } 74 | 75 | } // namespace base 76 | -------------------------------------------------------------------------------- /ETWInsights/base/command_line.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | #include "base/base.h" 23 | 24 | namespace base { 25 | 26 | class CommandLine { 27 | public: 28 | // Constructs a command line from an argument list. 29 | // @param argc Number of arguments. 30 | // @param argv Arguments. 31 | CommandLine(int argc, wchar_t* argv[]); 32 | 33 | // @param switch_name Name of a switch. 34 | // @returns true if the command line contains the given switch. 35 | bool HasSwitch(const std::wstring& switch_name) const; 36 | 37 | // @param switch_name Name of a switch. 38 | // @returns the value associated with the switch, or an empty string if no 39 | // value was specified for the switch in the command line. 40 | std::wstring GetSwitchValue(const std::wstring& switch_name) const; 41 | 42 | // @returns the number of command-line switches. 43 | size_t GetNumSwitches() const { 44 | return switches_.size(); 45 | } 46 | 47 | private: 48 | // Map Switch Name -> Switch Value. 49 | std::unordered_map switches_; 50 | 51 | DISALLOW_COPY_AND_ASSIGN(CommandLine); 52 | }; 53 | 54 | } // namespace base 55 | -------------------------------------------------------------------------------- /ETWInsights/base/error_string.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "base/error_string.h" 18 | 19 | #include 20 | #include 21 | 22 | #include "base/string_utils.h" 23 | 24 | namespace base { 25 | 26 | std::string GetWindowsErrorString(DWORD error) { 27 | LPWSTR error_desc_buffer = NULL; 28 | LPWSTR error_str_buffer = NULL; 29 | 30 | ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | 31 | FORMAT_MESSAGE_IGNORE_INSERTS, 32 | NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 33 | (LPTSTR)&error_desc_buffer, 0, NULL); 34 | 35 | error_str_buffer = (LPWSTR)LocalAlloc( 36 | LMEM_ZEROINIT, 37 | (lstrlen((LPCTSTR)error_desc_buffer) + 40) * sizeof(TCHAR)); 38 | ::StringCchPrintf((LPTSTR)error_str_buffer, 39 | LocalSize(error_str_buffer) / sizeof(TCHAR), 40 | TEXT("%d - %s"), error, error_desc_buffer); 41 | 42 | std::wstring error_str(error_str_buffer); 43 | 44 | ::LocalFree(error_desc_buffer); 45 | ::LocalFree(error_str_buffer); 46 | 47 | return WStringToString(error_str); 48 | } 49 | 50 | std::string GetLastWindowsErrorString() { 51 | return GetWindowsErrorString(::GetLastError()); 52 | } 53 | 54 | } // namespace base 55 | -------------------------------------------------------------------------------- /ETWInsights/base/error_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #define WIN32_LEAN_AND_MEAN 20 | #include // NOLINT 21 | 22 | #include 23 | 24 | namespace base { 25 | 26 | // @param error A Windows error code. 27 | // @returns The error message for the provided error code. 28 | std::string GetWindowsErrorString(DWORD error); 29 | 30 | // @returns The error message for the last Windows error. 31 | std::string GetLastWindowsErrorString(); 32 | 33 | } // namespace base 34 | -------------------------------------------------------------------------------- /ETWInsights/base/file.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "base/file.h" 18 | 19 | #define WIN32_LEAN_AND_MEAN 20 | #include 21 | 22 | namespace base { 23 | 24 | std::wstring DirName(const std::wstring& path) { 25 | auto pos = path.rfind(L'\\'); 26 | if (pos == std::wstring::npos) 27 | return std::wstring(); 28 | return path.substr(0, pos); 29 | } 30 | 31 | std::wstring BaseName(const std::wstring& path) { 32 | size_t last_backslash = path.find_last_of(L"\\"); 33 | if (last_backslash == std::wstring::npos) 34 | return path; 35 | return path.substr(last_backslash + 1); 36 | } 37 | 38 | bool FilePathExists(const std::wstring& path) { 39 | HANDLE handle = ::CreateFileW(path.c_str(), // file to open 40 | GENERIC_READ, // open for reading 41 | FILE_SHARE_READ, // share for reading 42 | NULL, // default security 43 | OPEN_EXISTING, // existing file only 44 | FILE_ATTRIBUTE_NORMAL, // normal file 45 | NULL); // no attr. template 46 | if (handle == INVALID_HANDLE_VALUE) 47 | return false; 48 | ::CloseHandle(handle); 49 | return true; 50 | } 51 | 52 | } // namespace base 53 | -------------------------------------------------------------------------------- /ETWInsights/base/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | namespace base { 22 | 23 | // @param path a file path. 24 | // @returns everything that comes before the last backslash in |path|. Empty if 25 | // |path| doesn't contain a backslash. 26 | std::wstring DirName(const std::wstring& path); 27 | 28 | // @param path a file path. 29 | // @returns the last path component of the provided file path. 30 | std::wstring BaseName(const std::wstring& path); 31 | 32 | // @param path a file path. 33 | // @returns true if the file path exists, false otherwise. 34 | bool FilePathExists(const std::wstring& path); 35 | 36 | } // namespace base 37 | -------------------------------------------------------------------------------- /ETWInsights/base/logging.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "base/logging.h" 20 | 21 | namespace base { 22 | 23 | LogMessage::~LogMessage() { 24 | // TODO(etienneb): Implements a clever logging dispatch. 25 | switch (severity_) { 26 | case LOG_INFO: 27 | std::cout << stream_.str(); 28 | break; 29 | case LOG_WARNING: 30 | std::cerr << "WARNING(" << file_ << ":" << line_ << "): " << stream_.str() 31 | << std::endl; 32 | break; 33 | case LOG_ERROR: 34 | std::cerr << "ERROR(" << file_ << ":" << line_ << "): " << stream_.str() 35 | << std::endl; 36 | break; 37 | case LOG_FATAL: 38 | std::cerr << "FATAL(" << file_ << ":" << line_ << "): " << stream_.str() 39 | << std::endl; 40 | exit(-1); // TODO(etienneb): Do we really want this? 41 | break; 42 | } 43 | } 44 | 45 | } // namespace base 46 | -------------------------------------------------------------------------------- /ETWInsights/base/logging.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | #include "base/base.h" 23 | 24 | namespace base { 25 | 26 | enum LogSeverity { LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL }; 27 | 28 | class LogMessage { 29 | public: 30 | LogMessage(LogSeverity severity, const char* file, int line) 31 | : severity_(severity), file_(file), line_(line) {} 32 | 33 | ~LogMessage(); 34 | 35 | std::ostream& stream() { return stream_; } 36 | 37 | private: 38 | std::ostringstream stream_; 39 | LogSeverity severity_; 40 | const char* file_; 41 | const int line_; 42 | 43 | DISALLOW_COPY_AND_ASSIGN(LogMessage); 44 | }; 45 | 46 | #define LOG(severity) \ 47 | base::LogMessage(base::LOG_##severity, __FILE__, __LINE__).stream() 48 | 49 | #ifndef NDEBUG 50 | #define DCHECK(cond) \ 51 | if (!(cond)) \ 52 | LOG(FATAL) << "'" << #cond << "' failed.\n" 53 | #else 54 | #define DCHECK(cond) (void)(cond); 55 | #endif 56 | 57 | #define DCHECK_EQ(a, b) DCHECK((a) == (b)) 58 | #define DCHECK_NE(a, b) DCHECK((a) != (b)) 59 | #define DCHECK_LT(a, b) DCHECK((a) < (b)) 60 | #define DCHECK_LE(a, b) DCHECK((a) <= (b)) 61 | #define DCHECK_GT(a, b) DCHECK((a) > (b)) 62 | #define DCHECK_GE(a, b) DCHECK((a) >= (b)) 63 | 64 | } // namespace base 65 | -------------------------------------------------------------------------------- /ETWInsights/base/numeric_conversions.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "base/numeric_conversions.h" 18 | 19 | #include 20 | 21 | #include "base/logging.h" 22 | 23 | namespace base { 24 | 25 | bool StrToULong(const std::string& str, uint64_t* ulong) { 26 | DCHECK(ulong); 27 | try { 28 | *ulong = std::stoull(str); 29 | return true; 30 | } catch (std::invalid_argument&) { 31 | return false; 32 | } 33 | } 34 | 35 | bool StrToULong(const std::wstring& str, uint64_t* ulong) { 36 | DCHECK(ulong); 37 | try { 38 | *ulong = std::stoull(str); 39 | return true; 40 | } catch (std::invalid_argument&) { 41 | return false; 42 | } 43 | } 44 | 45 | bool StrToULongHex(const std::string& str, uint64_t* ulong) { 46 | DCHECK(ulong); 47 | try { 48 | size_t pos = 0; 49 | *ulong = std::stoull(str, &pos, 16); 50 | return true; 51 | } catch (std::invalid_argument&) { 52 | return false; 53 | } 54 | } 55 | 56 | } // namespace base 57 | -------------------------------------------------------------------------------- /ETWInsights/base/numeric_conversions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | namespace base { 23 | 24 | // @param str a string to convert to unsigned long. 25 | // @param ulong the result of the conversion. 26 | // @returns true if the conversion was successful, false otherwise. 27 | bool StrToULong(const std::string& str, uint64_t* ulong); 28 | bool StrToULong(const std::wstring& str, uint64_t* ulong); 29 | bool StrToULongHex(const std::string& str, uint64_t* ulong); 30 | 31 | } // namespace base 32 | -------------------------------------------------------------------------------- /ETWInsights/base/string_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | namespace base { 23 | 24 | // Convert between ASCII and Unicode strings. 25 | std::wstring StringToWString(const std::string& string); 26 | std::string WStringToString(const std::wstring& string); 27 | 28 | // Returns true if |str| contains |substr| at position |pos|. 29 | bool SubstrAtPos(const std::string& str, const std::string& substr, size_t pos); 30 | bool WSubstrAtPos(const std::wstring& str, 31 | const std::wstring& substr, 32 | size_t pos); 33 | 34 | // Returns true if |str| begins with |starting|, or false otherwise. 35 | bool StringBeginsWith(const std::string& str, const std::string& starting); 36 | bool WStringBeginsWith(const std::wstring& str, const std::wstring& starting); 37 | 38 | // Returns true if |str| ends with |ending|, or false otherwise. 39 | bool StringEndsWith(const std::string& str, const std::string& ending); 40 | bool WStringEndsWith(const std::wstring& str, const std::wstring& ending); 41 | 42 | // Escape the C special characters with a backslash. 43 | // @param str the string to be escaped. 44 | // @returns a string escaped copy of |str|. 45 | std::string StringEscapeSpecialCharacter(const std::string& str); 46 | 47 | // Splits |str| at each occurrence of |separator|. 48 | std::vector SplitString(const std::string& str, 49 | const std::string& separator); 50 | std::vector SplitWString(const std::wstring& str, 51 | const std::wstring& separator); 52 | 53 | // Removes spaces at the beginning and end of |str|. 54 | std::string Trim(const std::string& str); 55 | std::wstring TrimW(const std::wstring& str); 56 | 57 | // Replaces all occurrences of |search| in |str| by |replace|. 58 | void ReplaceAll(const std::string& search, 59 | const std::string& replace, 60 | std::string* str); 61 | void ReplaceAllW(const std::wstring& search, 62 | const std::wstring& replace, 63 | std::wstring* str); 64 | 65 | } // namespace base 66 | -------------------------------------------------------------------------------- /ETWInsights/base/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | namespace base { 24 | 25 | typedef uint64_t Timestamp; 26 | typedef uint64_t Pid; 27 | typedef uint64_t Tid; 28 | 29 | const Timestamp kInvalidTimestamp = static_cast(-1); 30 | const Pid kInvalidPid = static_cast(-1); 31 | const Tid kInvalidTid = static_cast(-1); 32 | 33 | } // namespace base 34 | -------------------------------------------------------------------------------- /ETWInsights/etw_reader/etw_reader.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | -------------------------------------------------------------------------------- /ETWInsights/etw_reader/generate_history_from_trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #include "etw_reader/system_history.h" 22 | 23 | namespace etw_insights { 24 | 25 | // Traverses the event of an ETW trace to fill a system history. 26 | // @param trace_path Path to a .etl trace file. 27 | // @param system_history The system history to fill. 28 | // @returns true if the history was filled successfully, false otherwise. 29 | bool GenerateHistoryFromTrace(const std::wstring& trace_path, 30 | SystemHistory* system_history); 31 | 32 | } // namespace etw_insights 33 | -------------------------------------------------------------------------------- /ETWInsights/etw_reader/stack.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | namespace etw_insights { 23 | 24 | typedef std::vector Stack; 25 | 26 | } // namespace etw_insights 27 | -------------------------------------------------------------------------------- /ETWInsights/etw_reader/system_history.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "etw_reader/system_history.h" 18 | 19 | namespace etw_insights { 20 | 21 | SystemHistory::SystemHistory() 22 | : first_event_ts_(0), 23 | last_event_ts_(base::kInvalidTimestamp), 24 | first_non_empty_paint_ts_(base::kInvalidTimestamp) {} 25 | 26 | ThreadHistory& SystemHistory::GetThread(base::Tid tid) { 27 | auto look = threads_.find(tid); 28 | if (look != threads_.end()) 29 | return look->second; 30 | threads_[tid] = ThreadHistory(tid); 31 | return threads_[tid]; 32 | } 33 | 34 | void SystemHistory::SetProcessName(base::Pid process_id, 35 | const std::string& process_name) { 36 | process_names_[process_id] = process_name; 37 | } 38 | 39 | const std::string& SystemHistory::GetProcessName(base::Pid process_id) const { 40 | auto look = process_names_.find(process_id); 41 | if (look == process_names_.end()) 42 | return empty_string_; 43 | return look->second; 44 | } 45 | 46 | } // namespace etw_insights 47 | -------------------------------------------------------------------------------- /ETWInsights/etw_reader/system_history.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #include "base/base.h" 22 | #include "base/types.h" 23 | #include "etw_reader/thread_history.h" 24 | 25 | namespace etw_insights { 26 | 27 | // Contains the history of a system for the duration of a trace. 28 | class SystemHistory { 29 | public: 30 | typedef std::unordered_map ThreadHistoryMap; 31 | 32 | SystemHistory(); 33 | 34 | ThreadHistory& GetThread(base::Tid tid); 35 | 36 | void set_first_event_ts(base::Timestamp ts) { first_event_ts_ = ts; } 37 | base::Timestamp first_event_ts() const { return first_event_ts_; } 38 | 39 | void set_last_event_ts(base::Timestamp ts) { last_event_ts_ = ts; } 40 | base::Timestamp last_event_ts() const { return last_event_ts_; } 41 | 42 | void set_first_non_empty_paint_ts(base::Timestamp ts) { 43 | first_non_empty_paint_ts_ = ts; 44 | } 45 | base::Timestamp first_non_empty_paint_ts() const { 46 | return first_non_empty_paint_ts_; 47 | } 48 | 49 | void SetProcessName(base::Pid process_id, const std::string& process_name); 50 | const std::string& GetProcessName(base::Pid process_id) const; 51 | 52 | ThreadHistoryMap::const_iterator threads_begin() const { 53 | return threads_.begin(); 54 | } 55 | ThreadHistoryMap::const_iterator threads_end() const { 56 | return threads_.end(); 57 | } 58 | 59 | private: 60 | // Empty string. 61 | std::string empty_string_; 62 | 63 | // Timestamp of the first event. 64 | base::Timestamp first_event_ts_; 65 | 66 | // Timestamp of the last event. 67 | base::Timestamp last_event_ts_; 68 | 69 | // Timestamp of the first non empty paint, in Chrome. 70 | base::Timestamp first_non_empty_paint_ts_; 71 | 72 | // History of each thread. 73 | ThreadHistoryMap threads_; 74 | 75 | // Process names (Process ID -> Process Name). 76 | std::unordered_map process_names_; 77 | 78 | DISALLOW_COPY_AND_ASSIGN(SystemHistory); 79 | }; 80 | 81 | } // namespace etw_insights 82 | -------------------------------------------------------------------------------- /ETWInsights/etw_reader/thread_history.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "base/history.h" 20 | #include "base/types.h" 21 | #include "etw_reader/stack.h" 22 | 23 | namespace etw_insights { 24 | 25 | // Contains the history of a thread for the duration of a trace. 26 | class ThreadHistory { 27 | public: 28 | ThreadHistory() 29 | : tid_(base::kInvalidTid), 30 | start_ts_(base::kInvalidTimestamp), 31 | end_ts_(base::kInvalidTimestamp), 32 | parent_process_id_(base::kInvalidPid) {} 33 | ThreadHistory(base::Tid tid) 34 | : tid_(tid), 35 | start_ts_(base::kInvalidTimestamp), 36 | end_ts_(base::kInvalidTimestamp), 37 | parent_process_id_(base::kInvalidPid) {} 38 | 39 | base::Tid tid() const { return tid_; } 40 | 41 | void set_start_ts(base::Timestamp ts) { start_ts_ = ts; } 42 | base::Timestamp start_ts() const { return start_ts_; } 43 | 44 | void set_end_ts(base::Timestamp ts) { end_ts_ = ts; } 45 | base::Timestamp end_ts() const { return end_ts_; } 46 | 47 | void set_parent_process_id(base::Pid parent_process_id) { 48 | parent_process_id_ = parent_process_id; 49 | } 50 | base::Timestamp parent_process_id() const { return parent_process_id_; } 51 | 52 | typedef base::History StackHistory; 53 | StackHistory& Stacks() { return stacks_; } 54 | const StackHistory& Stacks() const { return stacks_; } 55 | 56 | private: 57 | // Thread id. 58 | base::Tid tid_; 59 | 60 | // Start timestamp. 61 | base::Timestamp start_ts_; 62 | 63 | // End timestamp. 64 | base::Timestamp end_ts_; 65 | 66 | // Parent process. 67 | base::Pid parent_process_id_; 68 | 69 | // Stack history. 70 | StackHistory stacks_; 71 | }; 72 | 73 | } // namespace etw_insights 74 | -------------------------------------------------------------------------------- /ETWInsights/flame_graph/clean_stack.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "etw_reader/stack.h" 20 | 21 | #include 22 | 23 | namespace etw_insights { 24 | 25 | // Cleans a call stack. 26 | // - Tall call stacks are truncated. 27 | // - Frames related to page faults are replaced by [Page Fault]. 28 | // - Uninteresting frames are removed. 29 | Stack CleanStack(const Stack& stack); 30 | 31 | } // namespace etw_insights 32 | -------------------------------------------------------------------------------- /ETWInsights/flame_graph/flame_graph.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #include "base/base.h" 22 | #include "base/types.h" 23 | #include "etw_reader/thread_history.h" 24 | 25 | namespace etw_insights { 26 | 27 | class FlameGraph { 28 | public: 29 | FlameGraph(); 30 | 31 | void AddThreadHistory(const ThreadHistory& thread_history, 32 | base::Timestamp start_ts, 33 | base::Timestamp end_ts); 34 | 35 | void WriteTxtReport(const std::wstring& path); 36 | 37 | private: 38 | // Map: Stack -> Total time spent in the call stack. 39 | typedef std::map StackTimeMap; 40 | StackTimeMap stack_time_; 41 | 42 | DISALLOW_COPY_AND_ASSIGN(FlameGraph); 43 | }; 44 | 45 | } // namespace etw_insights 46 | -------------------------------------------------------------------------------- /ETWInsights/flame_graph/flame_graph.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /ETWProviders/ETWProviders.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "stdafx.h" 18 | 19 | 20 | -------------------------------------------------------------------------------- /ETWProviders/ETWProviders.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/ETWProviders/ETWProviders.rc -------------------------------------------------------------------------------- /ETWProviders/ETWProviders.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.106 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ETWProviders", "ETWProviders.vcxproj", "{5136829D-E7F2-48CA-971E-27D26821C00D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM64 = Debug|ARM64 11 | Debug|Win32 = Debug|Win32 12 | Debug|x64 = Debug|x64 13 | Release|ARM64 = Release|ARM64 14 | Release|Win32 = Release|Win32 15 | Release|x64 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Debug|ARM64.ActiveCfg = Debug|ARM64 19 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Debug|ARM64.Build.0 = Debug|ARM64 20 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Debug|Win32.ActiveCfg = Debug|Win32 21 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Debug|Win32.Build.0 = Debug|Win32 22 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Debug|x64.ActiveCfg = Debug|x64 23 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Debug|x64.Build.0 = Debug|x64 24 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Release|ARM64.ActiveCfg = Release|ARM64 25 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Release|ARM64.Build.0 = Release|ARM64 26 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Release|Win32.ActiveCfg = Release|Win32 27 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Release|Win32.Build.0 = Release|Win32 28 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Release|x64.ActiveCfg = Release|x64 29 | {5136829D-E7F2-48CA-971E-27D26821C00D}.Release|x64.Build.0 = Release|x64 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {E8424D67-AADC-4F1A-8D20-BF9E99F6D5C5} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /ETWProviders/ETWProviders.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | Resource Files 21 | 22 | 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | Resource Files 57 | 58 | 59 | -------------------------------------------------------------------------------- /ETWProviders/ReadMe.txt: -------------------------------------------------------------------------------- 1 | This project creates a DLL that can emit custom ETW events. By using this DLL in your 2 | projects you can make it easier to analyze ETW traces. The emitted ETW events can serve 3 | as signposts or can contain additional context. 4 | 5 | As a sample of how to use this DLL see UIforETW and ETWEventDemo, both available at 6 | https://github.com/randomascii/UIforETW. 7 | 8 | UIforETW is also the recommended way to record traces that are using this DLL since it 9 | registers the DLL and records ETW traces that listen to its providers. 10 | -------------------------------------------------------------------------------- /ETWProviders/dllmain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "stdafx.h" 18 | 19 | BOOL APIENTRY DllMain( HMODULE /*hModule*/, 20 | DWORD ul_reason_for_call, 21 | LPVOID /*lpReserved*/ 22 | ) 23 | { 24 | switch (ul_reason_for_call) 25 | { 26 | case DLL_PROCESS_ATTACH: 27 | case DLL_THREAD_ATTACH: 28 | case DLL_THREAD_DETACH: 29 | case DLL_PROCESS_DETACH: 30 | break; 31 | } 32 | return TRUE; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /ETWProviders/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by ETWProviders.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /ETWProviders/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "stdafx.h" 18 | -------------------------------------------------------------------------------- /ETWProviders/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "targetver.h" 20 | 21 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 22 | // Windows Header Files: 23 | #include 24 | 25 | 26 | 27 | // TODO: reference additional headers your program requires here 28 | -------------------------------------------------------------------------------- /ETWProviders/targetver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | // Including SDKDDKVer.h defines the highest available Windows platform. 20 | 21 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 22 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 23 | 24 | #include 25 | -------------------------------------------------------------------------------- /EventEmitter/EventEmitter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | -------------------------------------------------------------------------------- /EventEmitter/EventEmitter.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/EventEmitter/EventEmitter.ico -------------------------------------------------------------------------------- /EventEmitter/EventEmitter.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/EventEmitter/EventEmitter.rc -------------------------------------------------------------------------------- /EventEmitter/EventEmitter.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EventEmitter", "EventEmitter.vcxproj", "{8BC12273-8C7F-4AC7-819E-D6B9D4A726E7}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {8BC12273-8C7F-4AC7-819E-D6B9D4A726E7}.Debug|x64.ActiveCfg = Debug|x64 17 | {8BC12273-8C7F-4AC7-819E-D6B9D4A726E7}.Debug|x64.Build.0 = Debug|x64 18 | {8BC12273-8C7F-4AC7-819E-D6B9D4A726E7}.Debug|x86.ActiveCfg = Debug|Win32 19 | {8BC12273-8C7F-4AC7-819E-D6B9D4A726E7}.Debug|x86.Build.0 = Debug|Win32 20 | {8BC12273-8C7F-4AC7-819E-D6B9D4A726E7}.Release|x64.ActiveCfg = Release|x64 21 | {8BC12273-8C7F-4AC7-819E-D6B9D4A726E7}.Release|x64.Build.0 = Release|x64 22 | {8BC12273-8C7F-4AC7-819E-D6B9D4A726E7}.Release|x86.ActiveCfg = Release|Win32 23 | {8BC12273-8C7F-4AC7-819E-D6B9D4A726E7}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /EventEmitter/ReadMe.txt: -------------------------------------------------------------------------------- 1 | This tool can sit in the background, monitoring system activity, and 2 | emit events of the type that etwrecord.bat listens for. 3 | 4 | If you use UIforETW.exe then this is unneeded because it both emits 5 | events and controls the tracing which listens for them. However in a 6 | lab setting there will be batch files to start and stop tracing, so 7 | the emitting of events must be done separately. 8 | 9 | To start emitting events: 10 | bin\EventEmitter.exe 11 | 12 | To stop emitting events: 13 | bin\EventEmitter.exe -kill 14 | 15 | In order to be more robust it is recommend that a kill command be 16 | executed prior to starting event emitting, to ensure that any 17 | EventEmitter binaries remaining from previous runs are killed. 18 | 19 | Alternately, EventEmitter can be left running continuously instead of being 20 | started and stopped for each test. 21 | 22 | To-do: 23 | Stop including afxmt.h in order to avoid the bloat which comes with it 24 | Add command-line options for controlling what events are emitted - see the 25 | "Configuration stuff" comment in EventEmitter.cpp. 26 | -------------------------------------------------------------------------------- /EventEmitter/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by EventEmitter.rc 4 | // 5 | 6 | #define IDS_APP_TITLE 103 7 | 8 | #define IDR_MAINFRAME 128 9 | #define IDD_EVENTEMITTER_DIALOG 102 10 | #define IDD_ABOUTBOX 103 11 | #define IDM_ABOUT 104 12 | #define IDM_EXIT 105 13 | #define IDI_EVENTEMITTER 107 14 | #define IDI_SMALL 108 15 | #define IDC_EVENTEMITTER 109 16 | #define IDC_MYICON 2 17 | #ifndef IDC_STATIC 18 | #define IDC_STATIC -1 19 | #endif 20 | // Next default values for new objects 21 | // 22 | #ifdef APSTUDIO_INVOKED 23 | #ifndef APSTUDIO_READONLY_SYMBOLS 24 | 25 | #define _APS_NO_MFC 130 26 | #define _APS_NEXT_RESOURCE_VALUE 129 27 | #define _APS_NEXT_COMMAND_VALUE 32771 28 | #define _APS_NEXT_CONTROL_VALUE 1000 29 | #define _APS_NEXT_SYMED_VALUE 110 30 | #endif 31 | #endif 32 | -------------------------------------------------------------------------------- /EventEmitter/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/EventEmitter/small.ico -------------------------------------------------------------------------------- /EventEmitter/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // EventEmitter.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /EventEmitter/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | 12 | // Windows Header Files: 13 | #include 14 | #include 15 | 16 | // C RunTime Header Files 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #define UIETWASSERT( x ) assert( x ) 24 | 25 | // Global function for printing to the dialog output window. 26 | inline void outputPrintf(_Printf_format_string_ const wchar_t* pFormat, ...) {} 27 | // Needed for int64_t and friends 28 | #include 29 | 30 | // Using #define NOMINMAX would be nice but gdiplustypes.h *depends* 31 | // on min/max macros, so the best I can do is to undefine them here. 32 | #undef min 33 | #undef max 34 | -------------------------------------------------------------------------------- /EventEmitter/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /LabScripts/ETWPMCDemo/.gitignore: -------------------------------------------------------------------------------- 1 | pmc_counters_test.txt 2 | -------------------------------------------------------------------------------- /LabScripts/ETWPMCDemo/ConditionalCount/ConditionalCount.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | int sum_array(unsigned char* p, size_t count); 24 | 25 | int main(int argc, char* argv[]) 26 | { 27 | int64_t start = __rdtsc(); 28 | unsigned char buffer[8192]; 29 | 30 | for (auto& x : buffer) 31 | { 32 | x = (unsigned char)((rand() / 71) & 255); 33 | } 34 | 35 | if (argc > 1 && strcmp(argv[1], "-sort") == 0) 36 | std::sort(buffer, buffer + sizeof(buffer)); 37 | 38 | int64_t mid = __rdtsc(); 39 | int total = 0; 40 | for (int i = 0; i < 30000; ++i) 41 | { 42 | total += sum_array(buffer, sizeof(buffer)); 43 | } 44 | int64_t end = __rdtsc(); 45 | printf("%5.2f MCycles for initialization and %5.2f MCycles for conditional adding.\n", (mid - start) / 1e6, (end - mid) / 1e6); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /LabScripts/ETWPMCDemo/ConditionalCount/ConditionalCount.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConditionalCount", "ConditionalCount.vcxproj", "{A208226C-6D79-4317-B31E-732B6F57BE45}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A208226C-6D79-4317-B31E-732B6F57BE45}.Debug|x64.ActiveCfg = Debug|x64 17 | {A208226C-6D79-4317-B31E-732B6F57BE45}.Debug|x64.Build.0 = Debug|x64 18 | {A208226C-6D79-4317-B31E-732B6F57BE45}.Debug|x86.ActiveCfg = Debug|Win32 19 | {A208226C-6D79-4317-B31E-732B6F57BE45}.Debug|x86.Build.0 = Debug|Win32 20 | {A208226C-6D79-4317-B31E-732B6F57BE45}.Release|x64.ActiveCfg = Release|x64 21 | {A208226C-6D79-4317-B31E-732B6F57BE45}.Release|x64.Build.0 = Release|x64 22 | {A208226C-6D79-4317-B31E-732B6F57BE45}.Release|x86.ActiveCfg = Release|Win32 23 | {A208226C-6D79-4317-B31E-732B6F57BE45}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /LabScripts/ETWPMCDemo/ConditionalCount/ConditionalCount.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | -------------------------------------------------------------------------------- /LabScripts/ETWPMCDemo/ConditionalCount/OtherFile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | This exists as a separate source file, and Link Time Code Generation is 19 | disabled, in order to hide information from the optimizer so that it won't 20 | realize that this function is pure and idempotent. 21 | */ 22 | 23 | //#define UNWOUND 24 | 25 | int sum_array(unsigned char* p, size_t count) 26 | { 27 | int result = 0; 28 | #ifdef UNWOUND 29 | // I expected this to have a higher percentage of mispredicted 30 | // branches because four out of five branches in the loop are 31 | // unpredictable (the loop-end branch is very predictable). 32 | // But this code somehow shows almost zero branch mispredicts, 33 | // and performance that is equivalent to the perfectly predicted 34 | // code. Very odd. 35 | for (size_t i = 0; i < count; i += 4) 36 | { 37 | if (p[i + 0] < 128) 38 | result += p[i + 0]; 39 | if (p[i + 1] < 128) 40 | result += p[i + 1]; 41 | if (p[i + 2] < 128) 42 | result += p[i + 2]; 43 | if (p[i + 3] < 128) 44 | result += p[i + 3]; 45 | } 46 | #else 47 | for (size_t i = 0; i < count; i += 1) 48 | { 49 | // This test relies on this being implemented using a conditional 50 | // branch instruction. 51 | if (p[i] < 128) 52 | result += p[i]; 53 | } 54 | #endif 55 | return result; 56 | } 57 | -------------------------------------------------------------------------------- /LabScripts/ETWPMCDemo/ConditionalCount/ReadMe.txt: -------------------------------------------------------------------------------- 1 | This demonstrates how pre-sorting of an array can dramatically affect the number 2 | of branch mispredicts. The exact behavior is highly dependent on your compiler 3 | and CPU but this can be a good test case for testing CPU performance counters 4 | such as branch mispredict counts. 5 | -------------------------------------------------------------------------------- /LabScripts/GPUTracing/ReadMe.txt: -------------------------------------------------------------------------------- 1 | The set of files in this directory serve as an example of how to measure GPU 2 | usage with ETW in a lab scenario, such as for regression testing. Both batch 3 | files must be run from an administrator command prompt. It is assumed that WPT 4 | is in the path, either from being installed or from being copied to the test 5 | machine. 6 | 7 | start_tracing.bat starts tracing with the minimal flags needed to record 8 | process information and GPU usage. 9 | 10 | stop_tracing.bat stops tracing, merges the kernel and user traces, and then runs 11 | wpaexporter twice: once to get a per-process summary, and once to get details. 12 | 13 | The information that is printed is controlled by the .wpaProfile files, and the 14 | generated .csv files contain headers that explain the columns, so there's not 15 | much else to say, except to reflect on how cool it is that this level of detail 16 | about what your GPU is doing is trivially* available. 17 | 18 | The analysis of the traces could be done on a different machine. 19 | 20 | These batch files should work on Windows 7 but have actually only been tested on 21 | Windows 10. If somebody tests on other operating systems then they should update 22 | this comment for easy PR points. 23 | 24 | Details on how the export works have previously been written up at: 25 | https://randomascii.wordpress.com/2013/11/04/exporting-arbitrary-data-from-xperf-etl-files/ 26 | 27 | * For meanings of trivial that assume years of training in the dark arts. 28 | -------------------------------------------------------------------------------- /LabScripts/GPUTracing/start_tracing.bat: -------------------------------------------------------------------------------- 1 | @ver | find "6.1." 2 | @if %errorlevel% == 0 goto Windows7 3 | @rem Windows 8.0+ stuff goes here 4 | @rem Note that +Microsoft-Windows-MediaEngine, which gives us present events, 5 | @rem only works on non-server SKUs 6 | set DX_Flags=Microsoft-Windows-DxgKrnl:0xFFFF:5+Microsoft-Windows-MediaEngine 7 | goto Windows8 8 | 9 | :Windows7 10 | @rem Windows 7 stuff goes here 11 | set DX_Flags=DX:0x2F 12 | 13 | :Windows8 14 | 15 | @rem %temp% should be a good location for temporary traces. 16 | @rem Make sure this is a fast drive, preferably an SSD. 17 | @set xperftemptracedir=%temp% 18 | @rem Select locations for the temporary kernel and user trace files. 19 | @set kernelfile=%xperftemptracedir%\kernel.etl 20 | @set userfile=%xperftemptracedir%\user.etl 21 | @set SessionName=usersession 22 | @set FileName=trace.etl 23 | @set FileAndCompressFlags="%FileName%" -compress 24 | @set UserProviders=%DX_Flags%+Microsoft-Windows-Win32k:0xfdffffffefffffff+Multi-MAIN+Multi-FrameRate+Multi-Input+Multi-Worker+Microsoft-Windows-Kernel-Memory:0xE0 25 | 26 | @rem Stop any previous event emitter binaries 27 | @%~dp0..\..\bin\EventEmitter.exe -kill 28 | @rem Stop any previous tracing sessions that may have accidentally been left 29 | @rem running. Otherwise the start command will fail with incredibly cryptic 30 | @rem errors. Ignore all warnings because in most cases they are expected. 31 | @xperf -stop %SessionName% -stop 2>nul 32 | @rem Start emitting ETW events for the tracing to record. 33 | @if not exist %~dp0..\..\bin\EventEmitter.exe goto SkipEventEmitting 34 | start %~dp0..\..\bin\EventEmitter.exe 35 | :SkipEventEmitting 36 | xperf.exe -start %logger% -on PROC_THREAD+LOADER -buffersize 1024 -minbuffers 60 -maxbuffers 60 -f "%kernelfile%" -start %SessionName% -on %UserProviders% -f "%userfile% 37 | @rem You have to invoke -capturestate because otherwise the ETW gnomes will not 38 | @rem reliably record the user-mode data to your trace. Do not anger the gnomes. 39 | xperf.exe -capturestate %SessionName% %UserProviders% 40 | -------------------------------------------------------------------------------- /LabScripts/GPUTracing/stop_tracing.bat: -------------------------------------------------------------------------------- 1 | @setlocal 2 | 3 | xperf -stop %SessionName% -stop 4 | @rem Stop the event emitter process, if running. 5 | %~dp0..\..\bin\EventEmitter.exe -kill 6 | 7 | xperf -merge "%kernelfile%" "%userfile%" %FileAndCompressFlags% 8 | 9 | @rem First print the per-process summary 10 | @set CSVName=GPU_Utilization_Table_Randomascii_GPU_Summary_by_Process.csv 11 | @if not exist %CSVName% goto skipDelete 12 | @del %CSVName% 13 | :skipDelete 14 | @rem Ignore spurious warnings about upgrading field names that aren't even used 15 | wpaexporter %FileName% -profile GPUUsageByProcess.wpaProfile 2>nul 16 | @type %CSVName% 17 | 18 | 19 | @rem Then print the details 20 | @set CSVDetailsName=GPU_Utilization_Table_Randomascii_GPU_Utilization_Details.csv 21 | @if not exist %CSVDetailsName% goto skipDelete 22 | @del %CSVDetailsName% 23 | :skipDelete 24 | @rem Ignore spurious warnings about upgrading field names that aren't even used 25 | wpaexporter %FileName% -profile GPUUsageDetails.wpaProfile 2>nul 26 | @type %CSVDetailsName% 27 | -------------------------------------------------------------------------------- /LabScripts/GeneralTracing/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is created by CreateExporterConfig.py and should not be committed. 2 | exporterconfig.json 3 | # This file is created by SummarizeData.py and should not be committed. 4 | results.json 5 | -------------------------------------------------------------------------------- /LabScripts/GeneralTracing/ReadMe.txt: -------------------------------------------------------------------------------- 1 | The set of files in this directory serve as an example of how to measure CPU 2 | and GPU usage with ETW in a lab scenario, such as for regression testing. Both 3 | start_tracing.bat and stop_tracing.bat must be run from an administrator command 4 | prompt. It is assumed that WPT is in the path, either from being installed or 5 | from being copied to the test machine. 6 | 7 | Sample usage: 8 | Run an administrator command prompt. Then, make an output directory: 9 | > mkdir %temp%\output 10 | Start tracing, optionally with the detailed flag: 11 | > start_tracing.bat detailed 12 | Do the action that you want profiled, then stop tracing, telling the script to 13 | put the results in %temp%\output: 14 | > stop_tracing.bat %temp%\output 15 | Data will be found in .csv files in %temp%\output, and will be summarized in 16 | results.json. 17 | 18 | start_tracing.bat starts tracing with the minimal flags needed to record 19 | process information, CPU usage, context switches, and GPU usage. 20 | 21 | stop_tracing.bat stops tracing, merges the kernel and user traces. It then uses 22 | CreateExporterConfig.py to create a .json file which uses the marks inserted 23 | into the trace by "xperf -m" to tightly bound the relevant section of the trace. 24 | This information plus the set of summary .wpaProfile files is put into the 25 | .json file. You can optionally pass an output directory to stop_tracing.bat and 26 | the .etl, .csv, and .json files will be put there. 27 | 28 | Then wpaexporter is invoked with the .json file to create a set of .csv files 29 | that summarize the data in the trace. The .csv files are then summarized using 30 | SummarizeData.py, producing another .json file. 31 | 32 | These batch files should work on Windows 7 but have actually only been tested on 33 | Windows 10. If somebody tests on other operating systems then they should update 34 | this comment for easy PR points. 35 | 36 | Adding additional types of analysis is 'easily' done by making sure that the 37 | appropriate data is being recorded (being sure not to increase the data rate too 38 | much as we wouldn't want to affect the results we are measuring) and then adding 39 | .wpaProfile files to define the data to be exported. 40 | 41 | Details on how the export works have previously been written up at: 42 | https://randomascii.wordpress.com/2013/11/04/exporting-arbitrary-data-from-xperf-etl-files/ 43 | -------------------------------------------------------------------------------- /LabScripts/GeneralTracing/set_vars.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2017 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | ver | find "6.1." 16 | if %errorlevel% == 0 goto Windows7 17 | rem Windows 8.0+ stuff goes here 18 | rem Note that +Microsoft-Windows-MediaEngine, which gives us present events, 19 | rem only works on non-server SKUs 20 | set DX_Flags=Microsoft-Windows-DxgKrnl:0xFFFF:5+Microsoft-Windows-MediaEngine 21 | goto Windows8 22 | 23 | :Windows7 24 | rem Windows 7 stuff goes here 25 | set DX_Flags=DX:0x2F 26 | 27 | :Windows8 28 | 29 | rem %temp% should be a good location for temporary traces. 30 | rem Make sure this is a fast drive, preferably an SSD. 31 | set xperftemptracedir=%temp% 32 | rem Select locations for the temporary kernel and user trace files. 33 | set kernelfile=%xperftemptracedir%\lab_etw_kernel.etl 34 | set userfile=%xperftemptracedir%\lab_etw_user.etl 35 | set SessionName=lab_etw_usersession 36 | 37 | rem PROC_THREAD+LOADER are required in order to know what binaries are loaded 38 | rem and what threads are running. 39 | rem CSWITCH records context switch data so that precise CPU usage and context 40 | rem switch counts can be recorded. So, these three flags are our minimum set 41 | rem of kernel providers. I then add in +POWER so that we can see CPU frequency 42 | rem and power-state changes. 43 | set KernelProviders=PROC_THREAD+LOADER+CSWITCH+POWER 44 | 45 | rem These user providers record GPU usage, window-in-focus, eventemitter events 46 | rem (if emitted), and process working-set samples. 47 | set UserProviders=%DX_Flags%+Microsoft-Windows-Win32k:0xfdffffffefffffff+Multi-MAIN+Multi-FrameRate+Multi-Input+Multi-Worker+Microsoft-Windows-Kernel-Memory:0xE0 48 | -------------------------------------------------------------------------------- /LabScripts/GeneralTracing/start_tracing.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2017 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @rem Sample usage: 16 | @rem start_tracing.bat [detailed] 17 | 18 | @echo off 19 | setlocal 20 | 21 | call %~dp0set_vars.bat 22 | 23 | if not "%USE_EVENT_EMITTER%" == "1" goto SkipEventEmitting 24 | rem Stop any previous event emitter binaries 25 | %~dp0..\..\bin\EventEmitter.exe -kill 26 | rem Start emitting ETW events for the tracing to record. 27 | if not exist %~dp0..\..\bin\EventEmitter.exe goto SkipEventEmitting 28 | start %~dp0..\..\bin\EventEmitter.exe 29 | :SkipEventEmitting 30 | 31 | rem Stop any previous tracing sessions that may have accidentally been left 32 | rem running. Otherwise the start command will fail with incredibly cryptic 33 | rem errors. Ignore all warnings because in most cases they are expected. 34 | xperf -stop %SessionName% -stop 2>nul 35 | 36 | if "%1" == "detailed" goto detailed 37 | xperf.exe -start %logger% -on %KernelProviders% -buffersize 1024 -minbuffers 60 -maxbuffers 60 -f "%kernelfile%" -start %SessionName% -on %UserProviders% -f "%userfile% 38 | goto skipdetailed 39 | :detailed 40 | rem These are some typical flags used by UIforETW to get more detailed traces, 41 | rem which we optionally enable for lab tracing. 42 | rem This extra information will distort timings. This is particularly true 43 | rem of the CSwitch and ReadyThread stackwalk flags. 44 | set KernelProviders=%KernelProviders%+CSWITCH+DISK_IO+HARD_FAULTS+DPC+INTERRUPT+PROFILE 45 | set KernelProviders=%KernelProviders%+DISPATCHER+DISK_IO_INIT+FILE_IO+FILE_IO_INIT+VIRT_ALLOC+MEMINFO 46 | set StackWalkFlags=Profile+CSwitch+ReadyThread 47 | xperf.exe -start %logger% -on %KernelProviders% -stackwalk %StackWalkFlags% -buffersize 1024 -minbuffers 160 -maxbuffers 160 -f "%kernelfile%" -start %SessionName% -on %UserProviders% -f "%userfile% 48 | :skipdetailed 49 | 50 | rem You have to invoke -capturestate because otherwise the ETW gnomes will not 51 | rem reliably record the user-mode data to your trace. Do not anger the gnomes. 52 | xperf.exe -capturestate %SessionName% %UserProviders% 53 | 54 | rem Insert a mark just after tracing starts 55 | xperf -m LabScriptsStarting 56 | -------------------------------------------------------------------------------- /LabScripts/GeneralTracing/stop_tracing.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2017 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @rem Sample usage: 16 | @rem stop_tracing.bat [outputdir] 17 | 18 | @echo off 19 | setlocal 20 | 21 | call %~dp0set_vars.bat 22 | 23 | rem Insert a mark just before tracing starts 24 | xperf -m LabScriptsStopping 25 | 26 | xperf -stop %SessionName% -stop 27 | 28 | if not "%USE_EVENT_EMITTER%" == "1" goto SkipEventEmitting 29 | rem Stop the event emitter process, if running. 30 | %~dp0..\..\bin\EventEmitter.exe -kill 31 | :SkipEventEmitting 32 | 33 | if "%1" == "" goto DefaultOutput 34 | set OutputDir=%1\ 35 | goto SpecifiedOutput 36 | :DefaultOutput 37 | set OutputDir=.\ 38 | :SpecifiedOutput 39 | 40 | rem Clean up any previous results 41 | del %OutputDir%*.csv 2>nul 42 | del %OutputDir%*.etl 2>nul 43 | del %OutputDir%*.json 2>nul 44 | 45 | set FileName=%OutputDir%trace.etl 46 | set FileAndCompressFlags="%FileName%" -compress 47 | 48 | xperf -merge "%kernelfile%" "%userfile%" %FileAndCompressFlags% 49 | del "%kernelfile%" "%userfile%" 50 | 51 | rem Generate an exporter config file based on marks in the trace and all the 52 | rem .wpaProfile files found. 53 | rem 'call' is needed for those systems where python is python.bat. Sigh... 54 | call python %~dp0CreateExporterConfig.py %FileName% >%OutputDir%exporterconfig.json 55 | rem Export multiple sets of data for the specified time range 56 | wpaexporter -exporterconfig %OutputDir%exporterconfig.json -outputfolder %OutputDir% 2>nul 57 | 58 | call python %~dp0SummarizeData.py %OutputDir% 59 | -------------------------------------------------------------------------------- /PowerMon/PowerMon.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | #include "PowerStatus.h" 5 | 6 | const int kSamplingInterval = 2000; 7 | 8 | int _tmain(int argc, _TCHAR* argv[]) 9 | { 10 | CPowerStatusMonitor monitor; 11 | if (!monitor.IsInitialized()) 12 | { 13 | printf("Couldn't find Intel Power Gadget. Make sure it is installed and IPG_Dir environment variable is visible to this process.\n"); 14 | return 0; 15 | } 16 | 17 | for (;;) 18 | { 19 | monitor.SampleCPUPowerState(); 20 | Sleep(kSamplingInterval); 21 | wprintf(L"\n"); 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /PowerMon/PowerMon.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PowerMon", "PowerMon.vcxproj", "{06F58C67-77E3-493A-B463-88888CCA6B1D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {06F58C67-77E3-493A-B463-88888CCA6B1D}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {06F58C67-77E3-493A-B463-88888CCA6B1D}.Debug|Win32.Build.0 = Debug|Win32 16 | {06F58C67-77E3-493A-B463-88888CCA6B1D}.Release|Win32.ActiveCfg = Release|Win32 17 | {06F58C67-77E3-493A-B463-88888CCA6B1D}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /PowerMon/PowerMon.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /PowerMon/PowerStatus.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | // https://software.intel.com/en-us/blogs/2012/12/13/using-the-intel-power-gadget-api-on-mac-os-x 20 | typedef int(*IntelEnergyLibInitialize_t)(); 21 | typedef int(*GetNumMsrs_t)(int* nMsr); 22 | typedef int(*GetMsrName_t)(int iMsr, wchar_t* szName); 23 | typedef int(*GetMsrFunc_t)(int iMsr, int* pFuncID); 24 | typedef int(*GetPowerData_t)(int iNode, int iMsr, double* pResult, int* nResult); 25 | typedef int(*ReadSample_t)(); 26 | typedef int(*GetMaxTemperature_t)(int iNode, int* degreeC); 27 | 28 | // This is mostly a copy of the CPowerStatusMonitor class from UIforETW. 29 | class CPowerStatusMonitor 30 | { 31 | public: 32 | CPowerStatusMonitor(); 33 | 34 | void SampleCPUPowerState(); 35 | bool IsInitialized() const 36 | { 37 | return energyLib_ != nullptr; 38 | } 39 | 40 | private: 41 | void ClearEnergyLibFunctionPointers(); 42 | 43 | HMODULE energyLib_ = nullptr; 44 | IntelEnergyLibInitialize_t IntelEnergyLibInitialize = nullptr; 45 | GetNumMsrs_t GetNumMsrs = nullptr; 46 | GetMsrName_t GetMsrName = nullptr; 47 | GetMsrFunc_t GetMsrFunc = nullptr; 48 | GetPowerData_t GetPowerData = nullptr; 49 | ReadSample_t ReadSample = nullptr; 50 | int maxTemperature_ = 0; 51 | 52 | CPowerStatusMonitor& operator=(const CPowerStatusMonitor&) = delete; 53 | CPowerStatusMonitor(const CPowerStatusMonitor&) = delete; 54 | }; 55 | -------------------------------------------------------------------------------- /PowerMon/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // stdafx.cpp : source file that includes just the standard includes 18 | // PowerMon.pch will be the pre-compiled header 19 | // stdafx.obj will contain the pre-compiled type information 20 | 21 | #include "stdafx.h" 22 | 23 | // TODO: reference any additional headers you need in STDAFX.H 24 | // and not in this file 25 | -------------------------------------------------------------------------------- /PowerMon/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // stdafx.h : include file for standard system include files, 18 | // or project specific include files that are used frequently, but 19 | // are changed infrequently 20 | // 21 | 22 | #pragma once 23 | 24 | #include "targetver.h" 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | -------------------------------------------------------------------------------- /PowerMon/targetver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | // Including SDKDDKVer.h defines the highest available Windows platform. 20 | 21 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 22 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 23 | 24 | #include 25 | -------------------------------------------------------------------------------- /RetrieveSymbols/ReadMe.txt: -------------------------------------------------------------------------------- 1 | This tool is designed to download PE files and symbols from symbol servers. 2 | Normally this is done automatically by tools such as windbg but it can be 3 | helpful to be able to download these files on demand. 4 | 5 | Sample usage: 6 | 7 | > rem Add the VS tools to the path, for access to dumpbin 8 | > "%vs120comntools%vsvars32.bat" 9 | 10 | >dumpbin /headers "c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" | findstr "RSDS date image" 11 | 54E3AECF time date stamp Tue Feb 17 13:12:47 2015 12 | 400000 image base (00400000 to 004D2FFF) 13 | 0.00 image version 14 | D3000 size of image 15 | 54E3AECF cv 5D 0008DF80 8D380 Format: RSDS, {283A66AE-3EF3-4383-8798-F6617112B1F6}, 1, chrome.exe.pdb 16 | 17 | > RetrieveSymbols {283A66AE-3EF3-4383-8798-F6617112B1F6}, 1 chrome.exe.pdb 18 | Looking for PDB file 283A66AE3EF343838798F6617112B1F6 1 chrome.exe.pdb. 19 | Found file - placed it in d:\src\symbols\chrome.exe.pdb\283A66AE3EF343838798F6617112B1F61\chrome.exe.pdb. 20 | 21 | > RetrieveSymbols 54E3AECF D3000 chrome.exe 22 | Looking for PE file chrome.exe 54e3aecf d3000. 23 | Found file - placed it in d:\src\symbols\chrome.exe\54E3AECFd3000\chrome.exe. 24 | 25 | The first invocation of RetrieveSymbols uses the GUID, age, and PDB name from 26 | the RSDS line of the dumpbin output -- the extraneous '{', '}', ',' and '-' 27 | characters are stripped out. 28 | 29 | The second invocation of RetrieveSymbols uses the time date stamp from the 30 | first line of the dumpbin output, the "size of image" data, and the 31 | executable name. 32 | 33 | This information can also be obtained from breakpad reports, from windbg 34 | by using "lmv m chrome_elf" and "!lmi chrome_elf.dll", from ETW traces, 35 | and from other sources. 36 | 37 | This tool is used by StripChromeSymbols.py to retrieve and then strip 38 | Chrome's symbols in order to avoid performance problems in WPA: 39 | https://randomascii.wordpress.com/2014/11/04/slow-symbol-loading-in-microsofts-profiler-take-two/ 40 | -------------------------------------------------------------------------------- /RetrieveSymbols/RetrieveSymbols.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30723.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RetrieveSymbols", "RetrieveSymbols.vcxproj", "{A7E25ADF-5FEA-4506-BF39-B88EC8CBACA5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A7E25ADF-5FEA-4506-BF39-B88EC8CBACA5}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {A7E25ADF-5FEA-4506-BF39-B88EC8CBACA5}.Debug|Win32.Build.0 = Debug|Win32 16 | {A7E25ADF-5FEA-4506-BF39-B88EC8CBACA5}.Release|Win32.ActiveCfg = Release|Win32 17 | {A7E25ADF-5FEA-4506-BF39-B88EC8CBACA5}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /RetrieveSymbols/RetrieveSymbols.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SignBinaries.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set local 3 | rem Signing pattern taken from: 4 | rem https://textslashplain.com/2016/01/10/authenticode-in-2016/ 5 | 6 | rem Add path for signtool 7 | set path=%path%;C:\Program Files (x86)\Windows Kits\10\bin\x64 8 | 9 | rem So far I see no indications that SHA1 signing is actually needed. 10 | rem signtool sign /d "UIforETW" /du "https://github.com/randomascii/UIforETW/releases" /n "Bruce Dawson" /tr http://timestamp.digicert.com /fd SHA1 %~dp0bin\UIforETW.exe %~dp0bin\UIforETW32.exe 11 | rem @if not %errorlevel% equ 0 goto failure 12 | 13 | rem Sign both 64-bit and 32-bit versions of UIforETW with the same description. 14 | signtool sign /d "UIforETW" /du "https://github.com/randomascii/UIforETW/releases" /n "Bruce Dawson" /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 %~dp0bin\UIforETW.exe %~dp0bin\UIforETW32.exe 15 | @if not %errorlevel% equ 0 goto failure 16 | exit /b 17 | 18 | :failure 19 | echo Signing failed! 20 | -------------------------------------------------------------------------------- /TraceProcessors/CPUSummary/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /TraceProcessors/CPUSummary/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CPUSummary")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CPUSummary")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c670c694-74af-46ae-9861-005b14510db4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TraceProcessors/CPUSummary/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /TraceProcessors/HeapSnapshotCompare/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /TraceProcessors/HeapSnapshotCompare/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("HeapSnapshotCompare")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("HeapSnapshotCompare")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("96201be4-b511-49a3-a98d-537b77e054c6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TraceProcessors/HeapSnapshotCompare/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /TraceProcessors/IdentifyChromeProcesses/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /TraceProcessors/IdentifyChromeProcesses/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("IdentifyChromeProcesses")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IdentifyChromeProcesses")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("42ac0c9a-bbe7-4c8e-bb00-84d9c9fc8ee3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TraceProcessors/IdentifyChromeProcesses/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /TraceProcessors/IdleWakeups/IdleWakeups.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /TraceProcessors/IdleWakeups/IdleWakeups.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31912.275 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdleWakeups", "IdleWakeups.csproj", "{B088F2D9-100B-401D-A43A-3358BF682195}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B088F2D9-100B-401D-A43A-3358BF682195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {B088F2D9-100B-401D-A43A-3358BF682195}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {B088F2D9-100B-401D-A43A-3358BF682195}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {B088F2D9-100B-401D-A43A-3358BF682195}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {1273C88D-6FDB-4224-9D13-03762DB203A5} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /TraceProcessors/VideoConfCPUCounters/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /TraceProcessors/VideoConfCPUCounters/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("VideoConfCPUCounters")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("VideoConfCPUCounters")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c37b7893-d2b9-4da1-835c-04339b38bff7")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TraceProcessors/VideoConfCPUCounters/etwpmc_record.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2016 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @setlocal 16 | 17 | @set tracelogdir=C:\Program Files (x86)\Windows Kits\10\bin\x64 18 | @for /d %%f in ("C:\Program Files (x86)\Windows Kits\10\bin\10.*") do @if exist "%%f\x64\tracelog.exe" set tracelogdir=%%f\x64 19 | 20 | @if exist "%tracelogdir%\tracelog.exe" goto tracelog_exists 21 | @echo Can't find tracelog.exe 22 | @exit /b 23 | :tracelog_exists 24 | 25 | @set path=%path%;%tracelogdir% 26 | 27 | @rem Start tracing with context switches and with a few CPU performance 28 | @rem counters being recorded for each context switch. 29 | @rem Default settings: 30 | @rem tracelog.exe -start pmc_counters -f pmc_counter_temp.etl -eflag CSWITCH+PROC_THREAD+LOADER -PMC BranchMispredictions,BranchInstructions:CSWITCH 31 | 32 | tracelog.exe -start pmc_counters -f pmc_counter_temp.etl -eflag CSWITCH+PROC_THREAD+LOADER -PMC UnhaltedCoreCycles,UnhaltedReferenceCycles,TotalIssues,LLCMisses:CSWITCH 33 | 34 | @if %errorlevel% equ 0 goto started 35 | @echo Make sure you are running from an administrator command prompt 36 | @exit /b 37 | :started 38 | 39 | @rem Counters can also be associated with other events such as PROFILE - just 40 | @rem change both occurrences of CSWITCH to PROFILE. But the parsing code will have 41 | @rem to be updated to make it meaningful. 42 | 43 | @rem Other available counters can be found by running "tracelog -profilesources Help". 44 | 45 | sleep 25 46 | 47 | xperf -stop pmc_counters >nul 48 | xperf -merge pmc_counter_temp.etl pmc_counters_test.etl -compress 49 | @del pmc_counter_temp.etl 50 | @if not exist bin\Release\VideoConfCPUCounters.exe goto end 51 | bin\Release\VideoConfCPUCounters.exe pmc_counters_test.etl 52 | @exit /b 53 | :end 54 | @echo Run bin\Release\VideoConfCPUCounters.exe on pmc_counters_test_merged.etl. 55 | -------------------------------------------------------------------------------- /TraceProcessors/VideoConfCPUCounters/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /UIforETW/About.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include "Utility.h" 20 | #include "Version.h" 21 | 22 | class CATLAboutDlg final : public ATL::CDialogImpl< CATLAboutDlg > 23 | { 24 | public: 25 | enum { IDD = IDD_ABOUTBOX }; 26 | BEGIN_MSG_MAP( CATLAboutDlg ) 27 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 28 | COMMAND_HANDLER(IDOK, BN_CLICKED, OnBnClickedOk) 29 | END_MSG_MAP() 30 | LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) 31 | { 32 | wchar_t buffer[200]; 33 | #ifdef VERSION_SUFFIX 34 | swprintf_s(buffer, L"Version %1.2f%c, build date: %s", kCurrentVersion, VERSION_SUFFIX, GetEXEBuildTime().c_str()); 35 | #else 36 | swprintf_s(buffer, L"Version %1.2f, build date: %s", kCurrentVersion, GetEXEBuildTime().c_str()); 37 | #endif 38 | SetDlgItemText(IDC_BUILDDATE, buffer); 39 | return 0; 40 | } 41 | LRESULT OnBnClickedOk( WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/ ) 42 | { 43 | EndDialog( 1 ); 44 | return 1; 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /UIforETW/CPUFrequency.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | class CCPUFrequencyMonitor 23 | { 24 | public: 25 | CCPUFrequencyMonitor() noexcept; 26 | ~CCPUFrequencyMonitor(); 27 | 28 | // Start and stop the sampling threads so that they aren't running 29 | // when tracing is not running. 30 | void StartThreads(); 31 | void StopThreads(); 32 | 33 | private: 34 | // Call this function with the 'this' pointer. 35 | static DWORD __stdcall StaticMonitorThread(LPVOID); 36 | void MonitorThread(); 37 | 38 | void Sample(); 39 | 40 | // Call this with a pointer to a CPUSamplerState object. 41 | static DWORD __stdcall StaticPerCPUSamplingThread(LPVOID); 42 | void PerCPUSamplingThread(int cpuNumber); 43 | 44 | // Pass this to StaticPerCPUSamplingThread to initialize those threads. 45 | struct CPUSamplerState 46 | { 47 | CCPUFrequencyMonitor* pOwner; 48 | int cpuNumber; // Used to give each thread a CPU number 49 | HANDLE hThread; 50 | float frequency; // Measured frequency 51 | }; 52 | 53 | // The number of CPUs that we monitor - may be less than the actual number 54 | // of CPUs on some crazy multi-core machines. 55 | unsigned numCPUs_ = 0; 56 | // Startup information for sampling threads. 57 | std::vector threads_; 58 | 59 | // When this is set then the workStartSemaphore will cause the per-CPU 60 | // threads to exit. 61 | std::atomic_bool quit_; 62 | 63 | // Semaphores to start measurement and wait for results. 64 | HANDLE workStartSemaphore_ = nullptr; 65 | HANDLE resultsDoneSemaphore_ = nullptr; 66 | 67 | float startFrequency_ = 0.0f; 68 | 69 | // Handle to monitor thread and event to tell it to halt. 70 | HANDLE hThread_ = nullptr; 71 | HANDLE hExitEvent_ = nullptr; 72 | 73 | CCPUFrequencyMonitor(const CCPUFrequencyMonitor&) = delete; 74 | CCPUFrequencyMonitor(const CCPUFrequencyMonitor&&) = delete; 75 | CCPUFrequencyMonitor& operator=(const CCPUFrequencyMonitor&) = delete; 76 | CCPUFrequencyMonitor& operator=(const CCPUFrequencyMonitor&&) = delete; 77 | }; 78 | -------------------------------------------------------------------------------- /UIforETW/DirectoryMonitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | class DirectoryMonitor 22 | { 23 | public: 24 | DirectoryMonitor(CWnd* pMainWindow) noexcept; 25 | ~DirectoryMonitor(); 26 | 27 | 28 | _Pre_satisfies_(this->hThread_ == 0) 29 | _Pre_satisfies_(this->hShutdownRequest_ == 0) 30 | void StartThread(const std::wstring* traceDir) noexcept; 31 | 32 | private: 33 | static DWORD WINAPI DirectoryMonitorThreadStatic(LPVOID); 34 | DWORD DirectoryMonitorThread(); 35 | 36 | HANDLE hThread_ = 0; 37 | HANDLE hShutdownRequest_ = 0; 38 | 39 | CWnd* mainWindow_ = nullptr; 40 | const std::wstring* traceDir_ = nullptr; 41 | 42 | DirectoryMonitor(const DirectoryMonitor&) = delete; 43 | DirectoryMonitor(const DirectoryMonitor&&) = delete; 44 | DirectoryMonitor& operator=(const DirectoryMonitor&) = delete; 45 | DirectoryMonitor& operator=(const DirectoryMonitor&&) = delete; 46 | }; 47 | -------------------------------------------------------------------------------- /UIforETW/KeyLoggerThread.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | enum KeyLoggerState 20 | { 21 | kKeyLoggerOff, 22 | kKeyLoggerAnonymized, 23 | kKeyLoggerFull 24 | }; 25 | 26 | // Call SetKeyloggingState to set what type of key logging should 27 | // be done. If the key logging thread is not started then it will 28 | // be started. Call it with kKeyLoggerOff to shut down the key 29 | // logging thread and stop key logging. 30 | void SetKeyloggingState(KeyLoggerState) noexcept; 31 | -------------------------------------------------------------------------------- /UIforETW/PowerStatus.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | // https://software.intel.com/en-us/blogs/2012/12/13/using-the-intel-power-gadget-api-on-mac-os-x 22 | typedef int(*IntelEnergyLibInitialize_t)(); 23 | typedef int(*GetNumMsrs_t)(int* nMsr); 24 | typedef int(*GetMsrName_t)(int iMsr, wchar_t* szName); 25 | typedef int(*GetMsrFunc_t)(int iMsr, int* pFuncID); 26 | typedef int(*GetPowerData_t)(int iNode, int iMsr, double* pResult, int* nResult); 27 | typedef int(*ReadSample_t)(); 28 | typedef int(*GetMaxTemperature_t)(int iNode, int* degreeC); 29 | 30 | class CPowerStatusMonitor 31 | { 32 | public: 33 | enum class MonitorType 34 | { 35 | LightLoad, 36 | HeavyLoad 37 | }; 38 | CPowerStatusMonitor() noexcept; 39 | ~CPowerStatusMonitor(); 40 | 41 | // Tell the system which perf counters (if any) to monitor. Only call 42 | // this when the threads are stopped. 43 | void SetPerfCounters(const std::wstring& perfCounters); 44 | 45 | // Start and stop the sampling threads so that they aren't running 46 | // when tracing is not running. 47 | void StartThreads(MonitorType monitorType) noexcept; 48 | void StopThreads() noexcept; 49 | 50 | private: 51 | static DWORD __stdcall StaticPowerMonitorThread(LPVOID); 52 | void PowerMonitorThread(); 53 | 54 | void SampleBatteryStat(); 55 | void SampleCPUPowerState() noexcept; 56 | void SampleTimerState() noexcept; 57 | void ClearEnergyLibFunctionPointers() noexcept; 58 | 59 | HANDLE hThread_ = nullptr; 60 | HANDLE hExitEvent_ = nullptr; 61 | MonitorType monitorType_ = MonitorType::HeavyLoad; 62 | 63 | HMODULE energyLib_ = nullptr; 64 | IntelEnergyLibInitialize_t IntelEnergyLibInitialize = nullptr; 65 | GetNumMsrs_t GetNumMsrs = nullptr; 66 | GetMsrName_t GetMsrName = nullptr; 67 | GetMsrFunc_t GetMsrFunc = nullptr; 68 | GetPowerData_t GetPowerData = nullptr; 69 | ReadSample_t ReadSample = nullptr; 70 | int maxTemperature_ = 0; 71 | 72 | std::wstring perfCounters_; 73 | 74 | CPowerStatusMonitor& operator=(const CPowerStatusMonitor&) = delete; 75 | CPowerStatusMonitor& operator=(const CPowerStatusMonitor&&) = delete; 76 | CPowerStatusMonitor(const CPowerStatusMonitor&) = delete; 77 | CPowerStatusMonitor(const CPowerStatusMonitor&&) = delete; 78 | }; 79 | -------------------------------------------------------------------------------- /UIforETW/ProcessChecks.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | #include 4 | #include 5 | 6 | constexpr size_t MD5LEN = 16; 7 | 8 | void Hash(const wchar_t* const szExeFile) 9 | { 10 | HCRYPTPROV hContext = 0; 11 | // Get handle to the crypto provider 12 | if (!CryptAcquireContext(&hContext, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) 13 | return; 14 | 15 | HCRYPTHASH hHash = 0; 16 | if (!CryptCreateHash(hContext, CALG_MD5, 0, 0, &hHash)) 17 | { 18 | CryptReleaseContext(hContext, 0); 19 | return; 20 | } 21 | 22 | const wchar_t* pChars = szExeFile; 23 | while (*pChars) 24 | { 25 | wchar_t c = *pChars; 26 | // Apply simple lower-casing rules. 27 | if (c >= 'A' && c <= 'Z') 28 | { 29 | c = c + 'a' - 'A'; 30 | } 31 | if (!CryptHashData(hHash, reinterpret_cast(&c), sizeof(c), 0)) 32 | { 33 | CryptReleaseContext(hContext, 0); 34 | CryptDestroyHash(hHash); 35 | return; 36 | } 37 | ++pChars; 38 | } 39 | 40 | // This executable breaks the ETW CPU sampler for some reason 41 | const BYTE badSamplingHash[MD5LEN] = { 0xfb, 0x69, 0xef, 0xd9, 0xea, 0x12, 0xdf, 0xcc, 0x22, 0xe9, 0x7a, 0x15, 0x01, 0x02, 0xb3, 0x3c }; 42 | 43 | DWORD cbHash = MD5LEN; 44 | BYTE nameHash[MD5LEN]; 45 | if (CryptGetHashParam(hHash, HP_HASHVAL, nameHash, &cbHash, 0)) 46 | { 47 | if (memcmp(nameHash, badSamplingHash, sizeof(nameHash)) == 0) 48 | { 49 | const wchar_t* banner = L"------------------------------------------------------------"; 50 | outputPrintf(L"\n%s\n", banner); 51 | outputPrintf(L"Warning!!! Process %s may cause the ETW CPU sampler to fail. Consider disabling %s.\n", szExeFile, szExeFile); 52 | outputPrintf(L"MD5 hash is: "); 53 | for (DWORD i = 0; i < cbHash; i++) 54 | { 55 | outputPrintf(L"%02x", nameHash[i]); 56 | } 57 | outputPrintf(L"\n"); 58 | outputPrintf(L"%s\n", banner); 59 | } 60 | } 61 | 62 | CryptDestroyHash(hHash); 63 | CryptReleaseContext(hContext, 0); 64 | } 65 | 66 | void CheckProcesses() 67 | { 68 | // CreateToolhelp32Snapshot runs faster than EnumProcesses and 69 | // it returns the process name as well, thus avoiding a call to 70 | // EnumProcessModules to get the name. 71 | HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, TH32CS_SNAPPROCESS); 72 | if (!hSnapshot) 73 | return; 74 | 75 | PROCESSENTRY32W peInfo; 76 | peInfo.dwSize = sizeof(peInfo); 77 | BOOL nextProcess = Process32First(hSnapshot, &peInfo); 78 | 79 | // Iterate through the processes. 80 | while (nextProcess) 81 | { 82 | Hash(peInfo.szExeFile); 83 | nextProcess = Process32Next(hSnapshot, &peInfo); 84 | } 85 | CloseHandle(hSnapshot); 86 | } 87 | -------------------------------------------------------------------------------- /UIforETW/SpinALot32.asm: -------------------------------------------------------------------------------- 1 | ; Copyright 2015 Google Inc. All Rights Reserved. 2 | ; 3 | ; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ; you may not use this file except in compliance with the License. 5 | ; You may obtain a copy of the License at 6 | ; 7 | ; http://www.apache.org/licenses/LICENSE-2.0 8 | ; 9 | ; Unless required by applicable law or agreed to in writing, software 10 | ; distributed under the License is distributed on an "AS IS" BASIS, 11 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ; See the License for the specific language governing permissions and 13 | ; limitations under the License. 14 | 15 | .486 16 | .model flat,c 17 | .CODE 18 | 19 | ; Spin in a loop for 50*spinCount cycles 20 | ; On out-of-order CPUs the sub and jne will not add 21 | ; any execution time. 22 | 23 | SpinALot PROC ; (const int spinCount) 24 | mov ecx, 4[esp] 25 | start: 26 | ; Ten dependent adds 27 | add eax, eax 28 | add eax, eax 29 | add eax, eax 30 | add eax, eax 31 | add eax, eax 32 | 33 | add eax, eax 34 | add eax, eax 35 | add eax, eax 36 | add eax, eax 37 | add eax, eax 38 | 39 | ; Ten more dependent adds 40 | add eax, eax 41 | add eax, eax 42 | add eax, eax 43 | add eax, eax 44 | add eax, eax 45 | 46 | add eax, eax 47 | add eax, eax 48 | add eax, eax 49 | add eax, eax 50 | add eax, eax 51 | 52 | ; Ten more dependent adds 53 | add eax, eax 54 | add eax, eax 55 | add eax, eax 56 | add eax, eax 57 | add eax, eax 58 | 59 | add eax, eax 60 | add eax, eax 61 | add eax, eax 62 | add eax, eax 63 | add eax, eax 64 | 65 | ; Ten more dependent adds 66 | add eax, eax 67 | add eax, eax 68 | add eax, eax 69 | add eax, eax 70 | add eax, eax 71 | 72 | add eax, eax 73 | add eax, eax 74 | add eax, eax 75 | add eax, eax 76 | add eax, eax 77 | 78 | ; Ten more dependent adds 79 | add eax, eax 80 | add eax, eax 81 | add eax, eax 82 | add eax, eax 83 | add eax, eax 84 | 85 | add eax, eax 86 | add eax, eax 87 | add eax, eax 88 | add eax, eax 89 | add eax, eax 90 | 91 | 92 | sub ecx, 1 93 | jne start 94 | 95 | ret 0 96 | SpinALot ENDP 97 | 98 | END 99 | -------------------------------------------------------------------------------- /UIforETW/SpinALot64.asm: -------------------------------------------------------------------------------- 1 | ; Copyright 2015 Google Inc. All Rights Reserved. 2 | ; 3 | ; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ; you may not use this file except in compliance with the License. 5 | ; You may obtain a copy of the License at 6 | ; 7 | ; http://www.apache.org/licenses/LICENSE-2.0 8 | ; 9 | ; Unless required by applicable law or agreed to in writing, software 10 | ; distributed under the License is distributed on an "AS IS" BASIS, 11 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ; See the License for the specific language governing permissions and 13 | ; limitations under the License. 14 | 15 | .CODE 16 | 17 | ; Spin in a loop for 50*spinCount cycles 18 | ; On out-of-order CPUs the sub and jne will not add 19 | ; any execution time. 20 | 21 | SpinALot PROC ; (const int spinCount : rcx) 22 | ; spinCount is already in ecx 23 | start: 24 | ; Ten dependent adds 25 | add eax, eax 26 | add eax, eax 27 | add eax, eax 28 | add eax, eax 29 | add eax, eax 30 | 31 | add eax, eax 32 | add eax, eax 33 | add eax, eax 34 | add eax, eax 35 | add eax, eax 36 | 37 | ; Ten more dependent adds 38 | add eax, eax 39 | add eax, eax 40 | add eax, eax 41 | add eax, eax 42 | add eax, eax 43 | 44 | add eax, eax 45 | add eax, eax 46 | add eax, eax 47 | add eax, eax 48 | add eax, eax 49 | 50 | ; Ten more dependent adds 51 | add eax, eax 52 | add eax, eax 53 | add eax, eax 54 | add eax, eax 55 | add eax, eax 56 | 57 | add eax, eax 58 | add eax, eax 59 | add eax, eax 60 | add eax, eax 61 | add eax, eax 62 | 63 | ; Ten more dependent adds 64 | add eax, eax 65 | add eax, eax 66 | add eax, eax 67 | add eax, eax 68 | add eax, eax 69 | 70 | add eax, eax 71 | add eax, eax 72 | add eax, eax 73 | add eax, eax 74 | add eax, eax 75 | 76 | ; Ten more dependent adds 77 | add eax, eax 78 | add eax, eax 79 | add eax, eax 80 | add eax, eax 81 | add eax, eax 82 | 83 | add eax, eax 84 | add eax, eax 85 | add eax, eax 86 | add eax, eax 87 | add eax, eax 88 | 89 | 90 | sub ecx, 1 91 | jne start 92 | 93 | ret 0 94 | SpinALot ENDP 95 | 96 | END 97 | -------------------------------------------------------------------------------- /UIforETW/TraceLoggingSupport.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | extern std::wstring TraceLoggingProviderNameToGUID(const std::wstring& provider); 22 | 23 | -------------------------------------------------------------------------------- /UIforETW/UIforETW.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #ifndef __AFXWIN_H__ 20 | #error "include 'stdafx.h' before including this file for PCH" 21 | #endif 22 | 23 | #include "resource.h" // main symbols 24 | 25 | 26 | // CUIforETWApp: 27 | // See UIforETW.cpp for the implementation of this class 28 | // 29 | 30 | class CUIforETWApp : public CWinApp 31 | { 32 | public: 33 | CUIforETWApp() noexcept; 34 | 35 | // Overrides 36 | public: 37 | virtual BOOL InitInstance() override; 38 | afx_msg void OnHelp() noexcept; 39 | 40 | // Implementation 41 | 42 | DECLARE_MESSAGE_MAP() 43 | }; 44 | 45 | extern CUIforETWApp theApp; -------------------------------------------------------------------------------- /UIforETW/Version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // const float in a header file can lead to duplication of the storage 4 | // but I don't really care in this case. Just don't do it with a header 5 | // that is included hundreds of times. 6 | // constexpr might help avoid that, but then it breaks my fragile upgrade-needed 7 | // detection code, so this should be left as const. 8 | const float kCurrentVersion = 1.60f; 9 | 10 | // Put a "#define VERSION_SUFFIX 'b'" line here to add a minor version 11 | // increment that won't trigger the new-version checks, handy for minor 12 | // releases that I don't want to bother users about. 13 | //#define VERSION_SUFFIX 'b' 14 | -------------------------------------------------------------------------------- /UIforETW/VersionChecker.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "VersionChecker.h" 3 | #include "Version.h" 4 | 5 | #include 6 | #include 7 | 8 | void CVersionChecker::VersionCheckerThread() 9 | { 10 | UINT totalBytesRead = 0; 11 | // The Version.h file is about 470 bytes. 12 | char buffer[1000]; 13 | try 14 | { 15 | CInternetSession MySession; 16 | const wchar_t* const url = L"https://raw.githubusercontent.com/randomascii/UIforETW/main/UIforETW/VersionCopy.h"; 17 | std::unique_ptr webFile(MySession.OpenURL(url)); 18 | // Read into the buffer -- set the maximum to one less than the length 19 | // of the buffer. 20 | while (totalBytesRead < sizeof(buffer) - 1) 21 | { 22 | const UINT bytesRead = webFile->Read(buffer + totalBytesRead, sizeof(buffer) - 1 - totalBytesRead); 23 | if (!bytesRead) 24 | break; 25 | totalBytesRead += bytesRead; 26 | } 27 | webFile->Close(); 28 | } 29 | catch (...) 30 | { 31 | } 32 | // Null terminate the buffer. 33 | buffer[totalBytesRead] = 0; 34 | const char* const marker = "const float kCurrentVersion = "; 35 | char* version_string = strstr(buffer, marker); 36 | if (version_string) 37 | { 38 | version_string += strlen(marker); 39 | if (strlen(version_string) > 4) 40 | { 41 | // String will be something like: "1.32f" and we want to cut off at 'f'. 42 | version_string[5] = 0; 43 | PackagedFloatVersion newVersion; 44 | newVersion.u = 0; 45 | if (sscanf_s(version_string, "%f", &newVersion.f) == 1) 46 | { 47 | if (newVersion.f > kCurrentVersion) 48 | { 49 | pWindow_->PostMessage(WM_NEWVERSIONAVAILABLE, newVersion.u); 50 | } 51 | } 52 | } 53 | } 54 | } 55 | 56 | DWORD __stdcall CVersionChecker::StaticVersionCheckerThread(LPVOID pParam) 57 | { 58 | CVersionChecker* pThis = static_cast(pParam); 59 | pThis->VersionCheckerThread(); 60 | return 0; 61 | } 62 | 63 | void CVersionChecker::StartVersionCheckerThread(CWnd* pWindow) noexcept 64 | { 65 | pWindow_ = pWindow; 66 | hThread_ = CreateThread(nullptr, 0, StaticVersionCheckerThread, this, 0, nullptr); 67 | } 68 | 69 | CVersionChecker::CVersionChecker() noexcept 70 | { 71 | } 72 | 73 | CVersionChecker::~CVersionChecker() 74 | { 75 | if (hThread_) 76 | { 77 | WaitForSingleObject(hThread_, INFINITE); 78 | CloseHandle(hThread_); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /UIforETW/VersionChecker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Use this for packaging up a float into a WPARAM in order to losslessly 4 | // pass it in a windows message. 5 | union PackagedFloatVersion 6 | { 7 | unsigned u; 8 | float f; 9 | }; 10 | 11 | class CVersionChecker 12 | { 13 | public: 14 | CVersionChecker() noexcept; 15 | ~CVersionChecker(); 16 | 17 | void StartVersionCheckerThread(CWnd* pWindow) noexcept; 18 | 19 | private: 20 | static DWORD __stdcall StaticVersionCheckerThread(LPVOID); 21 | void VersionCheckerThread(); 22 | 23 | HANDLE hThread_ = nullptr; 24 | CWnd* pWindow_ = nullptr; 25 | 26 | CVersionChecker(const CVersionChecker&) = delete; 27 | CVersionChecker(const CVersionChecker&&) = delete; 28 | CVersionChecker& operator=(const CVersionChecker&) = delete; 29 | CVersionChecker& operator=(const CVersionChecker&&) = delete; 30 | }; 31 | -------------------------------------------------------------------------------- /UIforETW/VersionCopy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // const float in a header file can lead to duplication of the storage 4 | // but I don't really care in this case. Just don't do it with a header 5 | // that is included hundreds of times. 6 | // constexpr might help avoid that, but then it breaks my fragile upgrade-needed 7 | // detection code, so this should be left as const. 8 | const float kCurrentVersion = 1.60f; 9 | 10 | // Put a "#define VERSION_SUFFIX 'b'" line here to add a minor version 11 | // increment that won't trigger the new-version checks, handy for minor 12 | // releases that I don't want to bother users about. 13 | //#define VERSION_SUFFIX 'b' 14 | -------------------------------------------------------------------------------- /UIforETW/WorkingSet.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include "Utility.h" 22 | 23 | class CWorkingSetMonitor 24 | { 25 | public: 26 | CWorkingSetMonitor() noexcept; 27 | ~CWorkingSetMonitor(); 28 | 29 | // Start and stop the sampling threads so that they aren't running 30 | // when tracing is not running. 31 | void StartThreads(); 32 | void StopThreads() noexcept; 33 | 34 | // Pass in a semi-colon separated list of process names that 35 | // the working set display should monitor. If this is the 36 | // empty string then no processes will be monitored. 37 | // If this is '*' then all processes will be monitored. 38 | void SetProcessFilter(const std::wstring& processes, bool expensiveWSMonitoring); 39 | private: 40 | static DWORD __stdcall StaticWSMonitorThread(LPVOID); 41 | void WSMonitorThread(); 42 | 43 | void SampleWorkingSets(); 44 | 45 | HANDLE hThread_ = nullptr; 46 | HANDLE hExitEvent_ = nullptr; 47 | 48 | CriticalSection processesLock_; 49 | // This is a list of process names to monitor. If the list is 50 | // empty then no processes are monitored. If this list has one 51 | // entry that is '*' then all processes are monitored. Otherwise 52 | // processes are monitored if their name (without path, case 53 | // insensitive) matches one of the entries. 54 | // This variable is protected by processesLock_; 55 | std::vector processes_; 56 | // This variable is protected by processesLock_; 57 | bool processAll_ = false; 58 | // This variable is protected by processesLock_; 59 | bool bExpensiveWSMonitoring_ = false; 60 | 61 | // Incrementing counter that will be the same for all samples recorded 62 | // at the same time. 63 | unsigned counter_ = 0; 64 | 65 | CWorkingSetMonitor(const CWorkingSetMonitor&) = delete; 66 | CWorkingSetMonitor(const CWorkingSetMonitor&&) = delete; 67 | CWorkingSetMonitor& operator=(const CWorkingSetMonitor&) = delete; 68 | CWorkingSetMonitor& operator=(const CWorkingSetMonitor&&) = delete; 69 | }; 70 | -------------------------------------------------------------------------------- /UIforETW/build_static.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2015 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @rem Modify the UIforETW project to be statically linked and build that version 16 | @rem so that it will run without any extra install requirements. 17 | 18 | @setlocal 19 | 20 | pushd %~dp0 21 | 22 | call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" 23 | 24 | sed "s/UseOfMfc>Dynamic/UseOfMfc>Static/" UIforETWStatic.vcxproj 25 | sed "s/UIforETW.vcxproj/UIforETWStatic.vcxproj/" UIforETWStatic.sln 26 | if exist Release rmdir Release /s/q 27 | if exist x64\Release rmdir x64\Release /s/q 28 | devenv /rebuild "release|Win32" UIforETWStatic.sln 29 | devenv /rebuild "release|x64" UIforETWStatic.sln 30 | del UIforETWStatic.vcxproj 31 | del UIforETWStatic.sln 32 | 33 | @rem Clean up the build directories at the end to avoid subsequent build warnings. 34 | rmdir Release /s/q 35 | rmdir x64\Release /s/q 36 | 37 | @rem Copy the results to the release executables 38 | pushd %~dp0..\bin 39 | echo >UIforETW32.exe 40 | xcopy /y UIforETWStatic_devrel32.exe UIforETW32.exe 41 | echo >UIforETW.exe 42 | xcopy /y UIforETWStatic_devrel.exe UIforETW.exe 43 | popd 44 | -------------------------------------------------------------------------------- /UIforETW/res/UIforETW.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/UIforETW/res/UIforETW.ico -------------------------------------------------------------------------------- /UIforETW/res/UIforETW.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/UIforETW/res/UIforETW.rc2 -------------------------------------------------------------------------------- /UIforETW/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "stdafx.h" 18 | 19 | 20 | -------------------------------------------------------------------------------- /UIforETW/targetver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015 Google Inc. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | // Specify the minimum Windows version required. 20 | // ETW is effectively absent from Windows XP. It works pretty badly 21 | // on Vista as well so this could be moved up to NTDDI_WIN7 if necessary. 22 | // Note that NTDDI_VISTA is being used before it is defined, but this 23 | // seems to be unavoidable because winsdkver.h does not define it. 24 | #define _WIN32_WINNT NTDDI_VISTA 25 | -------------------------------------------------------------------------------- /bin/.gitignore: -------------------------------------------------------------------------------- 1 | dbghelp.dll 2 | symsrv.dll 3 | 4 | # Exclude files generated by Incremental LTCG in VS2015 5 | # Their location does not seem to be affected by the Intermediate Directory 6 | # setting, even though it seems like it should. 7 | *.iobj 8 | *.ipdb 9 | 10 | # Exclude flamegraph.pl so that users can install it 11 | flamegraph.pl 12 | -------------------------------------------------------------------------------- /bin/ETWTimeBuild2005.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2015 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @if "%1" == "" goto nofile 16 | @if "%2" == "" goto nofile 17 | 18 | @setlocal 19 | @call "%VS80COMNTOOLS%..\..\VC\vcvarsall.bat" 20 | 21 | @rem To conserve space all build profiling is done with stack walks disabled. 22 | 23 | @rem These settings give sampled profiling plus full file I/O details. 24 | @rem @set KernelProviders=Latency+POWER+DISPATCHER+file_io+FILE_IO_INIT 25 | 26 | @rem These settings disable the sampled profiler, reducing file size by ~30%. 27 | @rem @set KernelProviders=DiagEasy+POWER+file_io+FILE_IO_INIT 28 | 29 | @rem These settings use a compact form of the CSwitch event and disable file I/O 30 | @rem events. Disk I/O events are still enabled. File size is reduced by ~90%. 31 | @rem Very little investigation will be possible, but overall CPU usage and disk 32 | @rem usage is available. 33 | @set KernelProviders=Diag 34 | 35 | @set KBuffers=-buffersize 1024 -minbuffers 300 36 | xperf -on %KernelProviders% %KBuffers% 37 | @if not %errorlevel% equ 0 goto failure 38 | 39 | @set starttime=%time% 40 | @xperf -m "Starting build" 41 | 42 | devenv %2 /rebuild release 43 | 44 | @xperf -m "Finishing build" 45 | @echo Build went from %starttime% to %time% 46 | @xperf -stop -d %1 47 | @exit /b 48 | 49 | :nofile 50 | @echo Don't forget to specify an ETW filename to save to and 51 | @echo a solution file to build. 52 | @echo For example: "TimeBuild2005 tracefile.etl" dotadlls.sln 53 | @exit /b 54 | 55 | :failure 56 | @echo Failed to start tracing. 57 | @echo Make sure you are running from an elevated command prompt. 58 | @echo Force-stopping any previous sessions that may be interfering. 59 | xperf -stop -d %1 60 | @exit /b 61 | -------------------------------------------------------------------------------- /bin/ETWTimeBuild2010.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2015 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @if "%1" == "" goto nofile 16 | @if "%2" == "" goto nofile 17 | 18 | @setlocal 19 | @call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" 20 | 21 | @rem To conserve space all build profiling is done with stack walks disabled. 22 | 23 | @rem These settings give sampled profiling plus full file I/O details. 24 | @rem @set KernelProviders=Latency+POWER+DISPATCHER+file_io+FILE_IO_INIT 25 | 26 | @rem These settings disable the sampled profiler, reducing file size by ~30%. 27 | @rem @set KernelProviders=DiagEasy+POWER+file_io+FILE_IO_INIT 28 | 29 | @rem These settings use a compact form of the CSwitch event and disable file I/O 30 | @rem events. Disk I/O events are still enabled. File size is reduced by ~90%. 31 | @rem Very little investigation will be possible, but overall CPU usage and disk 32 | @rem usage is available. 33 | @set KernelProviders=Diag 34 | 35 | @set KBuffers=-buffersize 1024 -minbuffers 300 36 | xperf -on %KernelProviders% %KBuffers% 37 | @if not %errorlevel% equ 0 goto failure 38 | 39 | @set starttime=%time% 40 | @xperf -m "Starting build" 41 | 42 | devenv %2 /rebuild release 43 | 44 | @xperf -m "Finishing build" 45 | @echo Build went from %starttime% to %time% 46 | @xperf -stop -d %1 47 | @exit /b 48 | 49 | :nofile 50 | @echo Don't forget to specify an ETW filename to save to and 51 | @echo a solution file to build. 52 | @echo For example: "TimeBuild2010 tracefile.etl" dotadlls.sln 53 | @exit /b 54 | 55 | :failure 56 | @echo Failed to start tracing. 57 | @echo Make sure you are running from an elevated command prompt. 58 | @echo Force-stopping any previous sessions that may be interfering. 59 | xperf -stop -d %1 60 | @exit /b 61 | -------------------------------------------------------------------------------- /bin/FindRandomasciiProfilePresets.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Google Inc. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ''' 16 | This script scans a .wpaProfile file looking for presets that start with 17 | Randomascii. These are the custom presets shipped with UIforETW. When updating 18 | the startup profile it is easy for these to get deleted, so a tool for auditing 19 | changes is quite helpful. 20 | ''' 21 | 22 | from __future__ import print_function 23 | 24 | import re 25 | import sys 26 | 27 | if len(sys.argv) < 2: 28 | print('Usage: %s profilename.wpaProfile' % sys.argv[0]) 29 | print('Prints a list of Randomascii presets in a .wpaProfile file.') 30 | sys.exit(0) 31 | 32 | count = 0 33 | for line in open(sys.argv[1]).readlines(): 34 | match = re.match(r'.* 2 | 3 | 4 | Debug 5 | 2.0 6 | {b9aeffbe-4409-4c6d-80b0-19869cd62565} 7 | 8 | IdentifyChromeProcesses.py 9 | 10 | . 11 | . 12 | {888888a0-9f3d-457c-b088-3a5042f75d52} 13 | Standard Python launcher 14 | 15 | 16 | "C:\Users\brucedawson\Documents\etwtraces\2015-09-02_12-07-53 very slow shutdown.etl" 17 | 18 | 19 | False 20 | 21 | 22 | 23 | 24 | 10.0 25 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /bin/chrome_events_win.man: -------------------------------------------------------------------------------- 1 |  2 | 9 | 10 | 11 | 18 | 19 | 23 | 24 | 25 | 59 | 60 | 61 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /bin/chrome_regions_of_interest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /bin/etw_processes_longterm.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2015 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @setlocal 16 | 17 | @set logger="Circular Kernel Context Logger" 18 | @rem Can also use "NT Kernel Logger", but that conflicts with UIforETW 19 | @rem Better to use a different kernel logger to let them run in parallel. 20 | 21 | @rem Set the etwtracedir environment variable if it 22 | @rem isn't set already. 23 | @if not "%etwtracedir%" == "" goto TraceDirSet 24 | @set etwtracedir=%homedrive%%homepath%\documents\etwtraces 25 | :TraceDirSet 26 | 27 | @rem Make sure %etwtracedir% exists 28 | @if exist "%etwtracedir%" goto TraceDirExists 29 | @mkdir "%etwtracedir%" 30 | :TraceDirExists 31 | 32 | @rem Generate a file name based on the current date and time and put it in 33 | @rem etwtracedir. This is compatible with UIforETW which looks for traces there. 34 | @rem Note: this probably fails in some locales. Sorry. 35 | @for /F "tokens=2-4 delims=/- " %%A in ('date/T') do @set datevar=%%C-%%A-%%B 36 | @for /F "tokens=1-3 delims=:-. " %%A in ('echo %time%') do @set timevar=%%A-%%B-%%C&set hour=%%A 37 | @rem Make sure that morning hours such as 9:00 are handled as 09 rather than 9 38 | @if %hour% LSS 10 set timevar=0%timevar% 39 | @set tracefile=%etwtracedir%\%datevar%_%timevar%_process_creation.etl 40 | @set textfile=%etwtracedir%\%datevar%_%timevar%_process_creation.txt 41 | 42 | @set kernelfile=%temp%\kernel_trace.etl 43 | 44 | @xperf.exe -start %logger% -on PROC_THREAD+LOADER -buffersize 1024 -minbuffers 60 -maxbuffers 60 -f "%kernelfile%" 45 | @set starttime=%time% 46 | @if not %errorlevel% equ 0 goto failure 47 | @echo Low data-rate tracing started at %starttime% 48 | 49 | @echo Run the test you want to profile here 50 | @rem Can replace "pause" with "timeout 3600" so that tracing automatically stops 51 | @rem after an hour. But this will require some process to wake up once a second 52 | @rem to update the timeout status. 53 | @pause 54 | @xperf.exe -stop %logger% 55 | @xperf.exe -merge "%kernelfile%" "%tracefile%" -compress 56 | @del "%kernelfile%" 57 | @echo Tracing ran from %starttime% to %time% 58 | @echo Tracing ran from %starttime% to %time% > "%textfile%" 59 | 60 | @echo Trace can be loaded using UIforETW or with: 61 | @echo wpa "%tracefile%" -profile TransientProcessTree.wpaProfile 62 | @exit /b 63 | 64 | :failure 65 | @echo Failure! Stopping tracing to clear state. 66 | @xperf.exe -stop %logger% 67 | @exit /b 68 | -------------------------------------------------------------------------------- /bin/etwpmc_record.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2021 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @setlocal 16 | 17 | @set tracelogdir=C:\Program Files (x86)\Windows Kits\10\bin\x64 18 | @for /d %%f in ("C:\Program Files (x86)\Windows Kits\10\bin\10.*") do @if exist "%%f\x64\tracelog.exe" set tracelogdir=%%f\x64 19 | 20 | @if exist "%tracelogdir%\tracelog.exe" goto tracelog_exists 21 | @echo Can't find tracelog.exe 22 | @exit /b 23 | :tracelog_exists 24 | 25 | @set path=%path%;%tracelogdir% 26 | 27 | @set batchdir=%~dp0 28 | 29 | @rem Start tracing with context switches and with a few CPU performance 30 | @rem counters being recorded for each context switch. 31 | tracelog.exe -start pmc_counters -f pmc_counter_temp.etl -eflag CSWITCH+PROC_THREAD+LOADER -PMC InstructionRetired,TotalCycles,CacheMisses,LLCMisses:CSWITCH 32 | @if %errorlevel% equ 0 goto started 33 | @echo Make sure you are running from an administrator command prompt 34 | @exit /b 35 | :started 36 | 37 | @rem Counters can also be associated with other events such as PROFILE - just 38 | @rem change both occurrences of CSWITCH to PROFILE. But the parsing code will have 39 | @rem to be updated to make it meaningful. 40 | 41 | @rem Other available counters can be found by running "tracelog -profilesources Help" 42 | @rem and on my machine I see: 43 | @rem Timer 44 | @rem TotalIssues 45 | @rem BranchInstructions 46 | @rem CacheMisses 47 | @rem BranchMispredictions 48 | @rem TotalCycles 49 | @rem UnhaltedCoreCycles 50 | @rem InstructionRetired - shows same results as TotalIssues 51 | @rem UnhaltedReferenceCycles 52 | @rem LLCReference 53 | @rem LLCMisses 54 | @rem BranchInstructionRetired - shows same results as BranchInstructions 55 | @rem BranchMispredictsRetired - not significantly different from BranchMispredictions 56 | 57 | @echo Run your scenario now. Press any key when you are finished. 58 | pause 59 | 60 | xperf -stop pmc_counters >nul 61 | xperf -merge pmc_counter_temp.etl pmc_counters_test.etl -compress 62 | @del pmc_counter_temp.etl 63 | xperf -i pmc_counters_test.etl -o pmc_counters_test.txt 64 | call python %batchdir%etwpmc_parser.py pmc_counters_test.txt 65 | @echo Rerun etwpmc_parser.py with a filter argument if you want certain 66 | @echo processes to be summarized in more detail. For example: 67 | @echo python %batchdir%etwpmc_parser.py pmc_counters_test.txt chrome 68 | -------------------------------------------------------------------------------- /bin/etwregister.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2015 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @rem Customize to specify the location of your provider DLL or EXE 16 | 17 | @set DLLFileMain=%~dp0ETWProviders.dll 18 | @set ManifestFileMain=%~dp0etwproviders.man 19 | 20 | 21 | 22 | @echo This will register the custom ETW providers. 23 | 24 | @set DLLFile=%DLLFileMain% 25 | @if not exist %DLLFile% goto NoDLL 26 | 27 | @set ManifestFile=%ManifestFileMain% 28 | @if not exist %ManifestFile% goto NoManifest 29 | 30 | xcopy /y %DLLFile% "%temp%" 31 | @set DLLFileTemp=%temp%\ETWProviders.dll 32 | wevtutil um "%ManifestFile%" 33 | @if %errorlevel% == 5 goto NotElevated 34 | wevtutil im "%ManifestFile%" /mf:"%DLLFileTemp%" /rf:"%DLLFileTemp%" 35 | @:Done 36 | @exit /b 37 | 38 | @:NotElevated 39 | @echo ETW providers must be registered from an elevated (administrator) command 40 | @echo prompt. Try again from an elevated prompt. 41 | @exit /b 42 | 43 | @:NoDLL 44 | @echo Can't find %DLLFileMain% 45 | @exit /b 46 | 47 | @:NoManifest 48 | @echo Can't find %ManifestFileMain% 49 | @exit /b 50 | -------------------------------------------------------------------------------- /bin/etwsamplefast.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2015 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @echo Setting the ETW sampling profiler frequency to 10,000,000/1,221 samples 16 | @echo per second, also known as one sample every 0.1221 ms, or about 8190 17 | @echo samples per second. 18 | xperf -setprofint 1221 cached 19 | -------------------------------------------------------------------------------- /bin/etwsamplenormal.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2015 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @echo Setting the ETW sampling profiler frequency to 10,000,000/10,000 samples 16 | @echo per second, also known as one sample every 1.0 ms, or about 1,000 17 | @echo samples per second. 18 | xperf -setprofint 10000 cached 19 | -------------------------------------------------------------------------------- /bin/etwsampleslow.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2015 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @echo Setting the ETW sampling profiler frequency to 10,000,000/40,000 samples 16 | @echo per second, also known as one sample every 4.0 ms, or about 250 17 | @echo samples per second. 18 | xperf -setprofint 40000 cached 19 | -------------------------------------------------------------------------------- /bin/metatrace.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2015 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @rem Use this batch file to profile the ETW profiler. If the save or merge 16 | @rem steps of UIforETW or wprui are very slow then this batch file can profile 17 | @rem them. Save this batch file for special occasions. This works by using 18 | @rem "Circular Kernel Context Logger" instead of "NT Kernel Logger", 19 | @rem which makes it possible to have two kernel loggers running simultaneously. 20 | 21 | @echo Preparing to profile the ETW profiler. 22 | 23 | @setlocal 24 | @set tempFile=%temp%\kernel_meta.etl 25 | @set kernel=-start "Circular Kernel Context Logger" 26 | @set kernel=%kernel% -on Latency+POWER+DISPATCHER+FILE_IO+FILE_IO_INIT 27 | @set kernel=%kernel% -stackwalk PROFILE+CSWITCH+READYTHREAD 28 | @set kernel=%kernel% -minbuffers 300 -maxbuffers 300 -buffersize 1024 29 | @set kernel=%kernel% -f "%tempFile%" 30 | xperf %kernel% 31 | @echo Hit enter when enough data has been recorded. 32 | @pause 33 | xperf -stop "Circular Kernel Context Logger" 34 | 35 | @rem Rename c:\Windows\AppCompat\Programs\amcache.hve to avoid serious merge 36 | @rem performance problems (up to six minutes!) 37 | @set HVEDir=c:\Windows\AppCompat\Programs 38 | @rename %HVEDir%\Amcache.hve Amcache_temp.hve 2>nul 39 | @set RenameErrorCode=%errorlevel% 40 | 41 | xperf -merge "%tempFile%" "%temp%\metatrace.etl" -compress 42 | @del "%tempFile%" 43 | 44 | @rem Rename the file back 45 | @if not "%RenameErrorCode%" equ "0" goto SkipRename 46 | @rename %HVEDir%\Amcache_temp.hve Amcache.hve 47 | :SkipRename 48 | -------------------------------------------------------------------------------- /bin/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains xperf related scripts and binaries from a range of 2 | different blog posts. I will try to mention where they come from in order to 3 | make it easy to get more information. 4 | 5 | https://randomascii.wordpress.com/2014/02/04/process-tree-from-an-xperf-trace/ 6 | - XperfProcessParentage.py 7 | - XperfProcessParentage.wpaProfile 8 | 9 | https://randomascii.wordpress.com/2011/08/18/xperf-basics-recording-a-trace/ 10 | - etwrecord.bat and many other batch files are related to this article and 11 | various other articles. 12 | 13 | https://randomascii.wordpress.com/2014/11/04/slow-symbol-loading-in-microsofts-profiler-take-two/ 14 | - StripChromeSymbols.py 15 | 16 | https://randomascii.wordpress.com/2013/03/26/summarizing-xperf-cpu-usage-with-flame-graphs/ 17 | - xperf_to_collapsedstacks.py 18 | 19 | https://randomascii.wordpress.com/2015/04/14/uiforetw-windows-performance-made-easier/ 20 | - UIforETW.exe 21 | 22 | For a general overview of using UIforETW and ETW in general see 23 | https://randomascii.wordpress.com/2015/09/24/etw-central/ 24 | 25 | All of these scripts assume that you have a recent copy of the Windows 26 | Performance Toolkit, or WPT installed. Some of these scripts rely on Microsoft 27 | DLLs or executables that come with the Debuggers package, which also comes with 28 | the Windows SDK. The best way to get all of these is to download and unzip 29 | etwpackage*.zip from https://github.com/randomascii/UIforETW/releases and run 30 | bin\UIforETW.exeas as that will install WPT. 31 | - pdbcopy.exe is used by StripChromeSymbols.py which is used by etwrecord.bat 32 | if you are using the Chromium symbol server. 33 | - x86 versions of dbghelp.dll and symsrv.dll are used by RetrieveSymbols.exe 34 | which is used by StripChromeSymbols.py which is used by etwrecord.bat if you 35 | are using the Chromium symbol server. 36 | - x64 versions of dbghelp.dll and symsrv.dll can be copied to the WPT install 37 | directory if they are found in an effort to alleviate the slow or failed 38 | symbol processing issues described at: 39 | https://randomascii.wordpress.com/2012/10/04/xperf-symbol-loading-pitfalls/ 40 | -------------------------------------------------------------------------------- /bin/trace_timer_intervals.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2015 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @rem Use this batch file to record timer interrupt interval/frequency changes. 16 | @rem It relies on xperf, a Python script, wpaexporter, a .wpaProfile script, 17 | @rem and IdentifyChromeProcesses.py. The result will be a summary, per-process, 18 | @rem of what processes raised the timer frequency, to what level, how often, and 19 | @rem for how long. 20 | @rem The ETW traces also contain call stacks for all of the events recorded, 21 | @rem making it possible to find out where in ones code the timer interval 22 | @rem changes are coming from. 23 | 24 | @setlocal 25 | 26 | @echo Run this batch file with -f=ProcessName to filter results to a specified 27 | @echo process. To reprocess the results afterwards run: 28 | @echo python summarize_timer_intervals.py "%temp%\TimerDetails.etl" 29 | @echo and optionally specify -f=ProcessName 30 | 31 | @set user_providers=Microsoft-Windows-Kernel-Power:0x4000000000000004 32 | xperf.exe -start "NT Kernel Logger" -on PROC_THREAD+LOADER -f "%temp%\TimerDetailskernel.etl" -start TimerSession -on %user_providers%::'stack' -f "%temp%\TimerDetailsuser.etl" 33 | @echo Run your scenario and then press enter. 34 | pause 35 | @xperf.exe -capturestate TimerSession %user_providers% 36 | xperf.exe -stop TimerSession -stop "NT Kernel Logger" 37 | xperf.exe -merge "%temp%\TimerDetailskernel.etl" "%temp%\TimerDetailsuser.etl" "%temp%\TimerDetails.etl" -compress 38 | 39 | call python summarize_timer_intervals.py "%temp%\TimerDetails.etl" %* 40 | -------------------------------------------------------------------------------- /excludecopy.txt: -------------------------------------------------------------------------------- 1 | .aps 2 | .pyproj 3 | .sln 4 | .pyc 5 | .bak 6 | TestIdentifyChromeProcesses.bat 7 | __pycache__\ 8 | _deb64.exe 9 | 10 | UIforETW32.exe 11 | .csv 12 | .etl 13 | .exp 14 | .ilk 15 | .opensdf 16 | .sdf 17 | .suo 18 | .svg 19 | .pdb 20 | .user 21 | symsrv.yes 22 | .vc.db 23 | Debug\ 24 | Release\ 25 | 26 | 27 | pmc_counters_test.txt 28 | FuncStats.txt 29 | GuidStats.txt 30 | Log.txt 31 | present.txt 32 | .lastcodeanalysissucceeded 33 | 34 | .gitignore 35 | _dev 36 | flamegraph.pl 37 | 38 | .iobj 39 | .ipdb 40 | -------------------------------------------------------------------------------- /make_zip_file.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import zipfile 4 | 5 | if len(sys.argv) < 3: 6 | print('Usage: %s zipfile directory' % sys.argv[0]) 7 | sys.exit(0) 8 | 9 | filename = sys.argv[1] 10 | dirToZip = sys.argv[2] 11 | 12 | # Assume that dirToZip is a relative directory. 13 | dirToZip = dirToZip 14 | 15 | # Request compression 16 | zf = zipfile.ZipFile(filename, "w", zipfile.ZIP_DEFLATED) 17 | for dirname, subdirs, files in os.walk(dirToZip): 18 | zf.write(dirname) 19 | for filename in files: 20 | filePath = os.path.join(dirname, filename) 21 | zf.write(filePath) 22 | zf.close() 23 | -------------------------------------------------------------------------------- /rename_to_version.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | prefix = 'const float kCurrentVersion = ' 5 | 6 | version_header = sys.argv[1] 7 | for line in open(version_header).readlines(): 8 | if line.startswith(prefix): 9 | version = line[len(prefix) : len(prefix) + 4] 10 | print('Renaming zip files to version "%s"' % version) 11 | os.rename('etwpackage.zip', 'etwpackage%s.zip' % version) 12 | sys.exit(0) 13 | 14 | assert(not "Didn't find header") 15 | -------------------------------------------------------------------------------- /third_party/.gitignore: -------------------------------------------------------------------------------- 1 | !pdbcopy.exe 2 | -------------------------------------------------------------------------------- /third_party/dbghelp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/third_party/dbghelp.dll -------------------------------------------------------------------------------- /third_party/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/third_party/license.txt -------------------------------------------------------------------------------- /third_party/pdbcopy.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/third_party/pdbcopy.exe -------------------------------------------------------------------------------- /third_party/symsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/third_party/symsrv.dll -------------------------------------------------------------------------------- /third_party/x64/dbghelp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/third_party/x64/dbghelp.dll -------------------------------------------------------------------------------- /third_party/x64/symsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/UIforETW/26f61a73bb07f951dd4cae411464774d0dae6cc8/third_party/x64/symsrv.dll -------------------------------------------------------------------------------- /vs-chromium-project.txt: -------------------------------------------------------------------------------- 1 | [SourceExplorer.ignore] 2 | .git/ 3 | *.sdf 4 | *.opensdf 5 | *.suo 6 | *.csproj 7 | *.vcxproj 8 | 9 | 10 | [SearchableFiles.ignore] 11 | Binaries/ 12 | obj/ 13 | Debug/ 14 | x64/ 15 | *.png 16 | *.ico 17 | *.ipch 18 | *.pch 19 | *.dll 20 | *.pdb 21 | *.user 22 | 23 | [SearchableFiles.include] 24 | * 25 | --------------------------------------------------------------------------------