Developing Drivers with the Windows Driver Foundation (Pro Developer)

Of the variety of tools for locating bugs in WDF drivers, the primary tool is WinDbg, a debugger with a graphical UI that can be used for both KMDF and UMDF drivers. Several other tools are used for more specialized purposes. This section discusses the available tools and how they are used to debug WDF drivers.

 Note  The Debugging Tools for Windows package can be downloaded from the WHDC Web site. The package includes the tools and documentation on how to use them.

Chapter 1, "Introduction to WDF," provides information about obtaining Debugging Tools for Windows.

WinDbg

The preferred debugger for both UMDF and KMDF drivers is WinDbg. This stand-alone debugger is used with a driver that has already been built and installed. WinDbg has a graphical user interface that supports the usual debugging features, such as setting breakpoints, examining variables, displaying the call stack, stepping through source code, and so on. In addition, WinDbg can run command-line debugger commands and debugger extensions that provide detailed information about many driver-specific issues.

 Note  Although it might be technically possible to use the Visual Studio debugger with UMDF drivers, this debugger is not designed for driver debugging and is not supported by Microsoft for this purpose. In addition, the WDK includes a collection of useful UMDF debugger extensions that can be used only with WinDbg.

The following are the basic ways to use WinDbg with WDF drivers:

Although the same tool is used to debug both types of WDF drivers, the approach is different:

Other Tools

The Debugging Tools for Windows package has several other debugging tools that can be useful adjuncts to WinDbg, including the following:

WDF includes two sets of debugger extensions, one for each framework. These extensions are small utility programs that can be run within WinDbg to provide WDF-specific information. See "Debugger Extensions" later in this chapter for more information.

Debugging is commonly done as part of the testing process. Although test and verification tools such as PREfast and Driver Verifier are not part of the debugging package, they are typically an integral part of the debugging process.

Chapter 21, "Tools for Testing WDF Drivers," presents a discussion of testing tools for drivers.

WPP Tracing

WPP tracing is commonly used with WDF drivers to help locate and characterize bugs. Most of the WDF samples use WPP tracing, so numerous examples are available.

Chapter 11, "Driver Tracing and Diagnosability," provides details about WPP tracing.

Debugging Macros and Routines

Several debugging macros and routines can be added to driver code to aid in locating and characterizing bugs. Some, such as the ASSERT macro, can be used in either UMDF or KMDF drivers, whereas others can be used only in one type of driver. Some debugging features are specific to WDF, as discussed in this chapter.

Категории