.if ($sicmp("${$arg1}", "-n") == 0) {
.if (@@(@$t0->_Isnil) == 0) {
.if (@$t2 == 1) {
.printf /D "
.printf "key = "
?? @$t0->_Myval.first
.printf "value = "
?? @$t0->_Myval.second
} .else {
r? $t9 = @$t0->_Myval
command
}
}
$$ Recurse into _Left, _Right unless they point to the root of the tree
.if (@@(@$t0->_Left) != @@(@$t1)) {
.push /r /q
r? $t0 = @$t0->_Left
$$>a< ${$arg0} -n
.pop /r /q
}
.if (@@(@$t0->_Right) != @@(@$t1)) {
.push /r /q
r? $t0 = @$t0->_Right
$$>a< ${$arg0} -n
.pop /r /q
}
} .else {
r? $t0 = ${$arg1}
.if (${/d:$arg2}) {
.if ($sicmp("${$arg2}", "-c") == 0) {
r $t2 = 0
aS ${/v:command} "${$arg3}"
}
} .else {
r $t2 = 1
aS ${/v:command} " "
}
.printf "size = %d\n", @@(@$t0._Mysize)
r? $t0 = @$t0._Myhead->_Parent
r? $t1 = @$t0->_Parent
$$>a< ${$arg0} -n
ad command
}
traverse_map.script
A WinDbg script that traverses std::map objects.
Usage:
$$>a< traverse_map.script
where cmd can reference @$t9, e.g. "?? @$t9.second" (this is the pair held by the map) and can also reference @$t0, which is the actual tree node pointer.
Examples:
$$>a< traverse_map.script my_map -c ".block { .echo ----; ?? @$t9.first; ?? @$t9.second; }"
$$>a< traverse_map.script m -c ".block { .if (@@(@$t9.first) == 8) { .echo ----; ?? @$t9.second } }"
$$>a< traverse_map.script my_map
Sample Program:-
class MapTest
{
public:
void PopulateMap();
private:
map
map
};
void MapTest::PopulateMap()
{
m_Map1[0] = 99;
m_Map1[1] = 100;
m_Map2[0] = wstring(L"Hello");
m_Map2[1] = wstring(L"World");
//stop the debugger here
__asm int 3
}
int _tmain(int argc, _TCHAR* argv[])
{
map
mm[1] = 1;
mm[2] = 2;
//stop the debugger
__asm int 3
MapTest mt;
mt.PopulateMap();
