[cfe-dev] Easier debugging with Visual Studio Visualizers

Nikola Smiljanic popizdeh at gmail.com
Sat Jul 23 06:14:04 PDT 2011


Hello everyone, I've spent the last couple of days debugging Clang and
peeking inside SmallVector and Token really annoyed me so I decided to write
some visualizers to make my life easier. I hope somebody else finds this
useful and if you have any ideas about other types that should be supported
just ask and I'll try to add them.

There are two ways to make this work:

1. Put the path to clangVisualizer.txt in the environmental variable called
_vcee_autoexp and restart your Visual Studio. This method should work for
Visual Studio 2008 and 2010 and is less invasive.
2. Copy everything except the [Visualizer] tag from clangVisualizers.txt to
C:\Program Files\Microsoft Visual Studio
10.0\Common7\Packages\Debugger\autoexp.dat. Make sure you backup your
original autoexp.dat first. This should work for Visual Studio 2005 and
above.

Here are the visualizers in action:
Token Visualizer <http://img135.imageshack.us/img135/2977/token.png>
SmallVector Visualizer
<http://img9.imageshack.us/img9/7286/smallvector.png> (It
works just like the one for std::vector, displays size, capacity and
elements)

If you'd like to disable the visualizer for a specific variable just type
variable_name,! inside the watch window.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110723/a77acffc/attachment.html>
-------------- next part --------------

[Visualizer]

llvm::SmallVector<*,*>{
	preview (
		#(
			"[",
			($T1*)$e.EndX - ($T1*)$e.BeginX,
			"](",
			#array(
				expr: (($T1*)$e.BeginX)[$i],
				size: ($T1*)$e.EndX - ($T1*)$e.BeginX
			),
			")"
		)
	)

	children (
		#(
			#([size] : ($T1*)$e.EndX - ($T1*)$e.BeginX),
			#([capacity] : ($T1*)$e.CapacityX - ($T1*)$e.BeginX),
			#array(
				expr: (($T1*)$e.BeginX)[$i],
				size: ($T1*)$e.EndX - ($T1*)$e.BeginX
			)
		)
	)
}

clang::Token{
	preview((clang::tok::TokenKind)(int)$e.Kind)
}


More information about the cfe-dev mailing list