Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

Visualizing MFC Containers in autoexp.dat

, 13 Jan 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
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....

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:

Posted in CodeProject, Debugging, Visual Studio

License

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

Share

About the Author

OfekSH
Engineer
Israel Israel
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.141015.1 | Last Updated 13 Jan 2010
Article Copyright 2010 by OfekSH
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid