Sometimes windbg will not be able to show a variable with its type correctly when you do dt. And it is not clear why windbg fails to do so from time to time. But generally this happens when the type is complex. So what do you do to dump a complex structure besides refreshing yourself on what offsets store what in the structure and switching to memory view ?

Watch window (alt+2) may come in handy and may work for you just fine in those cases. Of course watch window has its own oddities.

If you have watch window open and you are watching things change as you debug, things may become real slow because the watch window is getting updated every time you execute a bunch of code and stop in the debugger. So it is not a good idea to keep watch on too many things or couple of big structures/arrays for too long. Keeping watch to a few small items is ideal. Keeping a big item for the shortest time possible and removing it once it is irrelevant in the debug process, also helps. Of course if all of the watches are irrelevant in the current stage of debugging, close the watch window and things are snappy again and you do not have to reenter your watch entries because they will be there when you bring up the watch window again at a later point of time.

Now when you enter your variable to watch, it helps to put modulename! (globals) or $! (locals) before the variable name because otherwise the debugger tries to search for the symbol in all possible modules and that can take some time. In fact windbg will popup the message below when double clicking on a watch item takes a long time to process.

Windbg message with tips when watch window update takes too long

You cannot watch more than 16 levels deep in the watch window (windbg 6.8.4.0). The debugger does nothing if you attempt to go deeper.  So if you have a linked list, you can only explore first 15 items in the watch window. For the rest you need to find another way.

Windbg watch window can be buggy/clunky. Sometimes double clicking on a node does not expand the tree node correctly and works upon a second double click. Sometimes parts of tree are left hanging in the control. Some other times structure members may show up in the watch list and windbg goes on a doomed trip to locate them. It is not my first choice when I wish to look at a variable. But in some cases, it is easier to use than other ways of achieving the same through command line.

Tagged with →  
Share →

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Looking for something?

Use the form below to search the site:


Still not finding what you're looking for? Drop us a note so we can take care of it!

Visit our friends!

A few highly recommended friends...

Set your Twitter account name in your settings to use the TwitterBar Section.