Skip to content

Debugging with WDF Source

Alex Margarit edited this page Jun 25, 2015 · 5 revisions

This page describes how you can step through WDF source code in the debugger while debugging your WDF driver. This will help you get better understanding of the failure being triaged.

OS Requirements

In order to perform debugging with WDF source, your target machine must be running one of the Windows 10 builds available through the Windows Insider Pro gram. The build must be from March 2015 or later.

Debugging in WinDbg

If you haven't used WinDbg before, we strongly recommend you start your learning with the MSDN documentation.

If you're familiar with the basics of WinDbg usage, then you'll find that debugging with the WDF source is very simple.

Option 1: Automatic Source-level Debugging

When debugging a WDF driver loaded on a Windows 10 target machine, WinDbg will automatically retrieve the framework source code. See our Source-level Debugging blog post for more details. Generally all you need to do is call the following commands:

kd> .symfix
kd> .reload
kd> .srcfix

These tell WinDbg to set the symbol path to the Microsoft Public Symbol Server, fetch the PDB symbol files, and read the source paths from the PDBs.

Option 2: Download the WDF Source Code Locally

Download the source from GitHub, either by cloning the repo or by downloading the repo as a zip and extracting it. In WinDbg, set the source path to point to your local copy of the WDF code. For example, if the source is located at c:\wdf-source, you can use the following command to set the source path.

.srcpath+ c:\wdf-source\src\framework

Now that the debugger is aware of the source, try breaking into a driver. If you see any WDF routines (those starting with wdf01000! or wudfx02000!) on the call stack, click one. A window with the source for that routine should appear.

That's it! Continue debugging as you normally would, but with the benefit of full transparency into WDF source.

Debugging in Visual Studio

Visual Studio 2015 supports a subset of the debugging functionality supported in WinDbg. You can use the same debugging commands in both Visual Studio and WinDbg.