How to track bugs in Windows 10 run PC/laptop with DTrace
If you are a Windows 10 user you must be frustrated by the lack of control over bugs and updates. Microsoft has made Windows 10 so remote-controlled that users have little or no command over what happens to the Windows 10 operating system once you buy a Windows 10 laptop or PC.
Luckily for you, Microsoft has started giving you an option to check your Windows 10 PC/laptop by using a tool called DTrace. Only venture to use DTrace if you are a good programmer and have good coding skills.
What is DTrace?
In simple layman terms, DTrace is tracing bugs in your Windows PC/laptop using a scripting language called D. Using the command line and the scripting language, D, you can write tracing programs, assigning actions to instrumentation probes.
Basically DTrace is like a screwdriver in your hands which allows you to check the loose nuts and bolts in your Windows 10 PC. You can set parameters and create log files for each and every action in your Windows 10 PC/Laptop using DTrace. The benefits of DTrace is you can use several parameters at a time to track down bugs that debuggers fail to point out.
Using DTrace is easy if you are using Unix or Linux. The DTrace was originally developed by Sun as a dynamic tracing tool that allows you to drill down into much of what’s happening in a running system, from the hardware, up through the OS, to your applications. This powerful tool gives you a lot of information that can help debug and tune your code.
DTrace is written in D language which is very much like C and uses the same syntax as C. You can use command-line calls for setting probes and logging the results onscreen. The tool also provides comprehensive help with testing and debugging scripts so that you can program your own probe.
Using DTrace for bug hunting in Windows 10
You can download the appropriate version of DTrace from the Microsoft website. Once downloaded, install the DTrace application and then use BCDEdit to add it to your Windows boot configuration. You may need to turn BitLocker off if you’re using it to protect your PC’s boot configuration before you do this. The second option is to enter your BitLocker key when you next boot.
Once installed, use the Windows PATH environment variable to reference DTrace, as well as adding a new environment variable for any debugging symbols. These will be downloaded from Microsoft when they’re needed. Finally, make sure that you’ve set up Virtual Secure Mode to trace on the Windows kernel boundary. You can run DTrace inside a VM as long as it supports nested virtualization. You can do this from PowerShell, enabling virtualization extensions and then rebooting the host PC.
Do remember to run DTrace from the local admin account to get proper results. Add a new local user instead of using the default Windows 10 user profile. Remember to re-enable DTrace via BCDEdit when you update Windows Insider builds.
Debugging with DTrace
If you are familiar with D language you can start off immediately. If you are not familiar with D, you can use the sample scripts provided by Microsoft on its DTrace GitHub page, which can help you get started with tracing across your applications.
You should read some study material for handling D coding language before venturing into complex traces. Dynamic Tracing Guide is one such source you can use.
The sample scripts are split into groups, looking at common Windows tracing scenarios. You’ll find some for looking at disk operations, others for files, for memory, and for use with ETW. Download the code and run it on your systems, before making your own versions targeting your specific needs.