Code for the cross platform, single source, OpenDTrace implementation
Перейти к файлу
Akash Trehan d394cf0f5b
Allow IPI to a specific CPU (#55)
2024-02-18 19:59:25 -08:00
cmd Update Platform toolset to v143 and allow all Windows SDKs above v10.0.19041.0 2023-04-13 19:29:23 -07:00
lib Detect bad GUIDs for ETW trace providers and groups (#49) 2023-06-26 18:34:57 -07:00
releng Make Get-ExternalTools dl in releng/ if run in root 2021-03-01 20:47:33 -03:00
samples/windows Clean up use of wide strings in samples 2023-03-29 20:00:31 -07:00
sys Allow IPI to a specific CPU (#55) 2024-02-18 19:59:25 -08:00
.gitignore Add Visual Studio projects, scripts, and docs 2019-03-23 18:08:24 -07:00
COMPILING.md Updating DTrace 2022-04-20 19:34:24 -07:00
LICENSE Add the original CDDL/OPENSOLARIS License to the repo 2017-11-11 09:53:41 +08:00
NOTICE.md Add commit ID, copyrights and license names to NOTICE file (#39) 2023-10-11 11:23:25 -07:00
README.md Updating samples 2022-04-25 17:49:50 -07:00
SECURITY.md Adding Microsoft SECURITY.MD (#47) 2023-06-08 15:24:59 -07:00
azure-pipelines.yml Configure the Azure pipeline to include an ARM64 build target (#42) 2023-04-14 17:09:58 -07:00
cgmanifest.json Add gcmanifest.json file for component governance 2023-03-29 18:13:02 -07:00
opendtrace.sln DTrace on Windows - etw_trace(), lkd(), bug fixes. 2019-08-30 17:52:25 -07:00

README.md

DTrace on Windows

Here at Microsoft, we are always looking to engage with open source communities to produce better solutions for the community and our customers. One of the more useful debugging advances that have arrived in the last decade is DTrace. DTrace of course needs no introduction: it's a dynamic tracing framework that allows an admin or developer to get a real-time look into a system either in user or kernel mode.

DTrace has a C-style high level and powerful programming language that allows you to dynamically insert trace points. Using these dynamically inserted trace points, you can filter on conditions or errors, write code to analyze lock patterns, detect deadlocks, etc. ETW, while powerful, is static and does not provide the ability to programmatically insert trace points at runtime.

There are a lot of websites and resources from the community to learn about DTrace. One comprehensive option is the Dynamic Tracing Guide. This book describes DTrace in detail and is the authoritative guide for DTrace. We also have Windows specific examples below.

Starting in 2016, the OpenDTrace effort began on GitHub that tried to ensure a portable implementation of DTrace for different operating systems. We decided to add support for DTrace on Windows using this OpenDTrace port. This is a fork of the 'opendtrace' repository and contains the unified, cross platform, source code for the OpenDTrace system including kernel components.

Install

Follow MSDN instructions.

Prerequisites:

  • Windows 10 x64 Build 1903 or higher

Limitations:

  • Only available for 64-bit platforms
  • Only captures traces for 64-bit processes

Steps:

  1. Enable dtrace in the Boot Configuration Data (BCD) store. (bcdedit /set dtrace on) You will need to repeat this step every time you install a newer build of Windows.

  2. Download and execute the dtrace installer.

  3. Configure the _NT_SYMBOL_PATH environment variable for local symbol caching.

  4. Reboot the target machine.

Examples

Note: DTrace on Windows leverages additional Windows security features that may impact your experience.

// Syscall summary by program for 5 seconds: 
dtrace -Fn "tick-5sec { exit(0);} syscall:::entry{ @num[pid,execname] = count();} "
 
// Summarize timer set/cancel program for 3 seconds: 
dtrace -Fn "tick-3sec { exit(0);} syscall::Nt*Timer*:entry { @[probefunc, execname, pid] = count();}"
 
// Dump System Process kernel structure: (requires symbol path to be set)
dtrace -n "BEGIN{print(*(struct nt`_EPROCESS *) nt`PsInitialSystemProcess);exit(0);}"
 
// Tracing paths through NTFS when running notepad.exe (requires KD attach): Run below command and launch notepad.exe
dtrace -Fn "fbt:ntfs::/execname==\"notepad.exe\"/{}"

Learn more

License

OpenDTrace is under the CDDL license, see the LICENSE file in this repository for details.