Improve Your Debugging with Debugger Markup Language
Debugging Tools for Windows is an incredibly powerful tool all developers should have in their knowledge base. Complicated and costly bugs can often be diagnosed in a time-efficient matter by knowing which tools and debuggers to use in the right scenario.
Even with this knowledge, however, debugging can be a daunting task, primarily due to the arcane command syntax and to the simple fact that it’s sometimes hard to remember what each command does. Fortunately, there is a little-known feature that was added to the debugger package starting in version 6.6.07 that enables a much more pleasant debugger experience by annotating debugger command output with additional information. The annotation comes in the form of a Debugger Markup Language (DML).
What Is DML?
DML can be thought of as a simple version of HTML that allows commands to link to additional information as well as aid in the discoverability and functionality of commands.
To get a better idea of how this can help, let’s take a look at a very common debugging task: dumping the call stack and local variables for each frame. In a non-DML world, that task would first involve using a version of the k command to get the call stack, followed by switching to a particular frame using the .frame command, and finally issuing the dv command to see the local variables. Quite a chore just to get an overview of what a thread is doing! Luckily, a DML version of the k command is now available called kM and is shown in Figure 1 in the context of WinDbg.
Figure 1 Example of DML-enabled command kM
The output of the kM command looks very similar to that of the regular k command, with the exception of the highlighted frame numbers that appear as clickable links. For example, if we click on frame 02, the information shown in Figure 2 appears.
Figure 2 Clicking on a frame
The action of clicking on the frame automatically translated into two debugger commands; the first one switched the frame using the .frame command, and the second dumped all the local variables using the dv command. kM is just one of the commands that has been made DML-aware.
In the next sections, we take a look at some of the other DML-enabled commands.