Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging C++ STL containers in Windbg

Tags:

c++

stl

windbg

Windbg fans claim that it is quite powerful and I tend to agree. But when it comes to debugging STL containers, I am always stuck. If the variable is on the stack, the !stl extension sometimes figures it out, but when a container with a complex type (e.g. std::vector<TemplateField, std::allocator<TemplateField> >) is on the heap or part of some other structure, I just don't know how to view its contents.

Appreciate any tips, pointers.

like image 364
user15071 Avatar asked Sep 27 '08 05:09

user15071


3 Answers

I often find debugger support for STL data types inadequate. For this reason I'm increasingly using logging frameworks and logging statements. I used to think that these are for people who can't use a debugger, but I now realize that they offer real value. They allow you to embed portable debugging knowledge in your code and maintain it together with the code. In contrast, work you do in the debugger is typically ephemeral.

like image 97
Diomidis Spinellis Avatar answered Sep 22 '22 15:09

Diomidis Spinellis


You might also want to give this debugger extension a try. It is a library called SDbgExt, developed by Skywing.

like image 32
deemok Avatar answered Sep 25 '22 15:09

deemok


Python extension for WinDbg (pykd) have snippet stlp.py which can dump map contents.
Currently it supports STLPort map implementation. Tested on x86 and x64. This article demonstrates how to use it (its on Russian, but, examples are self-explanatory).

like image 43
airmax Avatar answered Sep 21 '22 15:09

airmax