Click here to Skip to main content
15,071,581 members
Articles / All Topics
Technical Blog
Posted 13 Jan 2010

Tagged as

Stats

15.4K views
3 bookmarked

Visualizing MFC Containers in autoexp.dat

Rate me:
Please Sign up or sign in to vote.
4.88/5 (10 votes)
13 Jan 2010CPOL
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:

Image 1

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:

Image 2

Posted in CodeProject, Debugging, Visual Studio
Image 3 Image 4 Image 5 Image 6 Image 7 Image 8

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


Comments and Discussions

 
-- There are no messages in this forum --