WinDbg Preview 1.0.1812.12001 and new extensibility interfaces

Hi everyone and happy holidays!

We've got a more extension focused release this time around, with a new C++ header, a new data model extension focusing around enabling easier JavaScript extensions, and a bunch of new samples!

Feel free to leave any questions or comments below or reach out to me on Twitter @aluhrs13. If you have feedback on our samples feel free to open a GitHub issue, or a PR if you want to contribute a fix or change.

Debugger data model C++ header

Last month we released a C++ header, DbgModel.h, as part of the Windows SDK for extending the debugger data model via C++. You can find more information in our official docs - https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/data-model-cpp-overview

The main page includes a great overview of how the debugger data model works and how extensions built on the new C++ header, JavaScript, NatVis, and the 'dx' command all inter-op and is work a read for anyone interested on ther internals of the debugger.

New Data Model API Extension

This release includes a new extension that adds some more "API style" features to the debugger data model that can be accessed through the 'dx' command, JavaScript, and the new DbgModel.h header. This extension extensions the data model to include knowledge about assembly and code execution through the Debugger.Utility.Code namespace, and the local file system through the Debugger.Utility.FileSystem namespace.

You can find the full docs for these new namespaces and the objects associated with them at:

Code

File System

The main goal of this extension is to improve the API surface available to JavaScript extensions, but all the functionality can be used via 'dx' and LINQ queries, for example:

0:000> dx Debugger.Utility.FileSystem.FileExists("C:\\Users\\aluhrs\\Desktop\\HelloWorld.txt") Debugger.Utility.FileSystem.FileExists("C:\\Users\\aluhrs\\Desktop\\HelloWorld.txt") : false

Or

0:000> dx Debugger.Utility.FileSystem.TempDirectory.Files.Count(),d Debugger.Utility.FileSystem.TempDirectory.Files.Count(),d : 110

This can be useful when writing scripts to quickly validate what a method might return in a REPL-like fashion. These extensions are also available in WinDbg and our command-line client in the latest Windows Insider SDK Preview - https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewSDK

Known issues

There are a couple known issues in this release that will be fixed in our next release:

  • Many of the iterable objects returned from properties on the disassembler can only safely be iterated once. It is perfectly fine to, in JavaScript, do: `var operandCount = instr.Operands.Count(); for (var operand of instr.Operands) { … }`. The following will have undefined results: `var operands = instr.Operands; var operandCount = operands.Count(); for (var operand of operands) { … }`.
  • There can be an incorrect flow graph produced from DisassembleFunction for some functions (overlapping basic blocks with incorrect flow links).

Synthetic types extension

With this new API extension, we have a new sample up on our GitHub repo here - https://github.com/Microsoft/WinDbg-Samples/tree/master/SyntheticTypes.

This JavaScript extension reads basic C header files and defines synthetic type information for the structures and unions defined in the header. Through the dx command, memory can then be viewed structured as if you had a PDB with type information for those types.

Other change and bug fixes

    • WinDbg Preview will now more intelligently handle bringing source windows or the disassembly window to the foreground when stepping.
    • Re-arranged WinDbgNext's window title to have more important information at the start when kernel debugging.
    • The alternating background contrast in the command window should be slightly more noticeable.