<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Umair&#039;s Blog &#187; Debugging</title>
	<atom:link href="http://umairsaeed.com/category/debugging/feed/" rel="self" type="application/rss+xml" />
	<link>http://umairsaeed.com</link>
	<description></description>
	<lastBuildDate>Fri, 20 Jan 2012 16:28:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='umairsaeed.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Umair&#039;s Blog &#187; Debugging</title>
		<link>http://umairsaeed.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://umairsaeed.com/osd.xml" title="Umair&#039;s Blog" />
	<atom:link rel='hub' href='http://umairsaeed.com/?pushpress=hub'/>
		<item>
		<title>Visualizing STLPort data structures in Visual Studio Debugger</title>
		<link>http://umairsaeed.com/2009/11/23/visualizing-stlport-data-structures-in-visual-studio-debugger/</link>
		<comments>http://umairsaeed.com/2009/11/23/visualizing-stlport-data-structures-in-visual-studio-debugger/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 16:55:57 +0000</pubDate>
		<dc:creator>Umair</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://umairsd.wordpress.com/2009/11/23/visualizing-stlport-data-structures-in-visual-studio-debugger/</guid>
		<description><![CDATA[Recently, I had to use STL Port for a particular project. While debugging, I was hampered by the fact that my data structures were not providing as much information in the watch window as I would have hoped. Using std::vector &#8230; <a href="http://umairsaeed.com/2009/11/23/visualizing-stlport-data-structures-in-visual-studio-debugger/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=umairsaeed.com&amp;blog=9333327&amp;post=37&amp;subd=umairsd&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently, I had to use <a href="http://stlport.sourceforge.net/Home.shtml" target="_blank">STL Port</a> for a particular project. While debugging, I was hampered by the fact that my data structures were not providing as much information in the watch window as I would have hoped. Using std::vector as an example, here&#8217;s a screen shot that highlights the problem.</p>
<div id="attachment_49" class="wp-caption alignnone" style="width: 510px"><a href="http://umairsd.files.wordpress.com/2009/11/screen_before_l.png"><img class="size-full wp-image-49" title="screen_BEFORE_l" src="http://umairsd.files.wordpress.com/2009/11/screen_before_l.png?w=500&#038;h=528" alt="Screentshot before modifications to autoexp.bat file" width="500" height="528" /></a><p class="wp-caption-text">Screentshot before modifications to autoexp.bat file</p></div>
<p>After a bit of investigation I disovered the wonderful autoexp.dat file for Visual Studio. Visual studio 2005 and 2008 allow you to customize native variable watch: i.e. how a variable previews in the watch window and tooltips. This is done via a file called autoexp.dat (auto-expand), which is hidden deep inside the VS installation (%VS_INSTALL_DIR%\Common7\Packages\Debugger). Official documentation on the specifics of the scripting language is sparse, and Microsoft&#8217;s <a href="http://msdn.microsoft.com/en-us/library/zf0e8s14.aspx" target="_blank">MSDN article</a> contains the disclaimer &#8220;The structure of this file and syntax of autoexp rules might change from one release of visual studio to the next&#8221;.</p>
<p>For most part, the instructions on how to write auto-expand rules for native types are located in the file itself. There are some <a href="http://www.virtualdub.org/blog/pivot/entry.php?id=120" target="_blank">other resources that are great to get started</a></p>
<p>Anyway, back to my predicament. After some research and some trial and error, the following visualizer worked for STLPort&#8217;s std::vector.</p>
<p><span style="font-family:Courier New;">;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
;  STLPORT visualizer<br />
;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; </span></p>
<p><span style="font-family:Courier New;">;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; </span></p>
<p><span style="font-family:Courier New;">;  stlp_std::vector<br />
;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
stlp_std::vector&lt;*&gt;{<br />
children<br />
(<br />
#array<br />
(<br />
expr :    ($c._M_start)[$i], </span></p>
<p><span style="font-family:Courier New;"> size :    $c._M_finish-$c._M_start<br />
)<br />
)<br />
preview<br />
(<br />
#(<br />
&#8220;[",<br />
$e._M_finish - $e._M_start ,<br />
"](&#8220;, </span></p>
<p><span style="font-family:Courier New;"> #array<br />
(<br />
expr :     ($c._M_start)[$i],<br />
size :     $c._M_finish-$c._M_start<br />
),<br />
&#8220;)&#8221;<br />
) </span></p>
<p><span style="font-family:Courier New;"> )<br />
} </span></p>
<p>I copied the above block in the autoexp.dat file of my Visual Studio installation, and tried to look at the data structures again. I discovered that I had to make a slight modification to the above visualiser for it to work properly in the<strong> debug</strong> mode. STLPort uses debug versions of data structures in debug builds, and as a result I had to rename <span style="font-family:Courier;">stlp_std::vector</span> to <span style="font-family:Courier New;">stlpd_std::vector</span> for things to work as expected. Here&#8217;s the visualiser for debug builds, followed by the screenshot of how things acually look in the watch window.</p>
<p><span style="font-family:Courier New;">;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; </span></p>
<p><span style="font-family:Courier New;">;  stlpd_std::vector<br />
;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
stlpd_std::vector&lt;*&gt;{<br />
children<br />
(<br />
#array<br />
(<br />
expr :    ($c._M_start)[$i], </span></p>
<p><span style="font-family:Courier New;"> size :    $c._M_finish-$c._M_start<br />
)<br />
)<br />
preview<br />
(<br />
#(<br />
&#8220;[",<br />
$e._M_finish - $e._M_start ,<br />
"](&#8220;, </span></p>
<p><span style="font-family:Courier New;"> #array<br />
(<br />
expr :     ($c._M_start)[$i],<br />
size :     $c._M_finish-$c._M_start<br />
),<br />
&#8220;)&#8221;<br />
) </span></p>
<p><span style="font-family:Courier New;"> )<br />
} </span></p>
<div id="attachment_48" class="wp-caption alignnone" style="width: 510px"><a href="http://umairsd.files.wordpress.com/2009/11/screen_after_l.png"><img class="size-full wp-image-48" title="screen_AFTER_l" src="http://umairsd.files.wordpress.com/2009/11/screen_after_l.png?w=500&#038;h=528" alt="Screentshot after modifications to autoexp.bat file" width="500" height="528" /></a><p class="wp-caption-text">Screentshot after modifications to autoexp.bat file</p></div>
<p>The resources linked above should be a great place if you want to experiment with autoexp.dat file.</p>
<p>I must point out that there is a potentially better way to create visualizers for custom types. MSDN has a couple of good articles to get you started, particularly <a href="http://msdn.microsoft.com/en-us/library/zayyhzts.aspx" target="_blank">Visualizers</a> and <a href="http://msdn.microsoft.com/en-us/library/e2zc529c.aspx" target="_blank">How to: Write a Visualizer</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/umairsd.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/umairsd.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/umairsd.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/umairsd.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/umairsd.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/umairsd.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/umairsd.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/umairsd.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/umairsd.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/umairsd.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/umairsd.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/umairsd.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/umairsd.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/umairsd.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=umairsaeed.com&amp;blog=9333327&amp;post=37&amp;subd=umairsd&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://umairsaeed.com/2009/11/23/visualizing-stlport-data-structures-in-visual-studio-debugger/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3d8419a4ace3305d6791158454f7f874?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">umairsd</media:title>
		</media:content>

		<media:content url="http://umairsd.files.wordpress.com/2009/11/screen_before_l.png" medium="image">
			<media:title type="html">screen_BEFORE_l</media:title>
		</media:content>

		<media:content url="http://umairsd.files.wordpress.com/2009/11/screen_after_l.png" medium="image">
			<media:title type="html">screen_AFTER_l</media:title>
		</media:content>
	</item>
	</channel>
</rss>
