Visualizing MFC Containers in autoexp.dat






4.88/5 (10 votes)
How to visualize MFC containers in autoexp.dat
MFC containers are more or less officially deprecated in favor of STL. Even so, when navigating in legacy code, the need often arises to watch CArrays
, CLists
, CMaps
and the like. autoexp.dat provides only STL visualizers out of the box, but you can just paste the lines below into autoexp’s [Visualizer]
section, and have a similar debugging experience with MFC code:
[Visualizer]
; This section contains visualizers for STL and ATL containers
; DO NOT MODIFY (HAAAAAAAAA. -o.s.)
...
;---------------------------------------------------------------------
; MFC Types
;---------------------------------------------------------------------
CArray<*,*>|CObArray|CByteArray|CDWordArray|
CPtrArray|CStringArray|CWordArray|CUIntArray|CTypedPtrArray<*,*>{
preview([$c,!])
children(
#(
#array (
expr: $c.m_pData[$i],
size: $c.m_nSize
),
#(raw : [$c,!])
)
)
}
CList<*,*>|CObList|CPtrList|CStringList|CTypedPtrList<*,*>{
preview([$c,!])
children(
#(
#list (
head: $c.m_pNodeHead,
next: pNext
) : $e.data,
#(raw : [$c,!])
)
)
}
CMap<*,*,*,*>::CAssoc{
preview(#("key= ",$e.key,", value= ", $e.value))
}
CMap<*,*,*,*>|CMapPtrToWord|CMapPtrToPtr|CMapStringToOb|CMapStringToPtr|
CMapStringToString|CMapWordToOb|CMapWordToPtr|CTypedPtrMap<*,*,*>{
children (
#(
#array (
expr : ($c.m_pHashTable)[$i],
size : $c.m_nHashTableSize
) : #(
#list (
head : $e,
next : pNext
)
)
)
)
}
Here’s what you’d get:
I'm aware of the formatting issues in the snippet above, but the autoexp parser is notoriously fragile and I didn’t want to risk extra spaces for proper line-wrapping.
And BTW, unlike Avery (the original autoexp Jedi), I prefer to avoid cluttering the visualizers with ‘raw’ watch entries. If you ever need to watch into, say, raw members of a CList
, just postfix the variable with ‘,!’ , as in: