<?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/"
	>

<channel>
	<title>console-dev.de</title>
	<atom:link href="http://www.console-dev.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.console-dev.de</link>
	<description>Home of VsTortoise, VisualHAM, N3D and HEL Library</description>
	<lastBuildDate>Mon, 27 Sep 2010 17:54:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>VsTortoise, Build 28 beta released</title>
		<link>http://www.console-dev.de/2010/09/27/vstortoise-build-28-beta-released/</link>
		<comments>http://www.console-dev.de/2010/09/27/vstortoise-build-28-beta-released/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 17:54:04 +0000</pubDate>
		<dc:creator>Peter Schraut</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[add-in]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[TortoiseSVN]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VsTortoise]]></category>

		<guid isPermaLink="false">http://www.console-dev.de/?p=903</guid>
		<description><![CDATA[VsTortoise is an add-in for Microsoft Visual Studio that provides an  interface to perform the most common revision control operations  directly from inside the Visual Studio IDE. It uses TortoiseSVN to execute the Subversion commands.
Existing users of VsTortoise receive an update notification if  the option &#8220;Also check for beta versions&#8221; is checked. New [...]]]></description>
			<content:encoded><![CDATA[<p>VsTortoise is an add-in for Microsoft Visual Studio that provides an  interface to perform the most common revision control operations  directly from inside the Visual Studio IDE. It uses <a href="http://tortoisesvn.net/">TortoiseSVN</a> to execute the Subversion commands.</p>
<p>Existing users of VsTortoise receive an update notification if  the option &#8220;<a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_options.png">Also check for beta versions</a>&#8221; is checked. New users can download it from <a href="http://vstortoise.codeplex.com/releases/view/53005">http://vstortoise.codeplex.com/releases/view/53005</a></p>
<p>Here is an overview about the recent changes:</p>
<ul>
<li>New: Added refresh button to context menu in Open modified File dialog, to refresh the list. Rather than using the button, you can also use F5 as shortcut.</li>
<li>Fix: Pass filenames to TortoiseSVN through a pathfile rather than over the command-line (via CreateProcess). This should remove once and for all the &#8220;<a href="http://vstortoise.codeplex.com/workitem/6667">TortoiseSVN not showing up</a>&#8221; problems, which were usually caused by exceeding the supported OS&#8217;s command-line length.</li>
<li>Fix: Missing command &#8220;Show Log&#8221; in filter context menu <a href="http://vstortoise.codeplex.com/workitem/6956">Issue #6956</a> (thanks mikeplex)</li>
<li>Fix: Installer not working correctly on Windows 32bit in some places. <a href="http://vstortoise.codeplex.com/workitem/7239">Internal error: Cannot acces 64 bit registry keys on this version of Windows</a> (thanks mneu)</li>
<li>Fix: ActiveProject commands respect paths of all project items now, rather than the directory where the .vcproj is located only. (thanks Julien)</li>
<li>Fix: On some systems, mainly with other add-ins installed, VsTortoise buttons in the Solution Explorer context menu have been placed below the Properties button. This was incorrect behavior and now placed above Properties instead.
<p>For the full log, including older versions, please see <a href="http://vstortoise.codeplex.com/wikipage?title=Changelog">here</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.console-dev.de/2010/09/27/vstortoise-build-28-beta-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VsTortoise, Build 24 beta released</title>
		<link>http://www.console-dev.de/2010/05/14/vstortoise-build-24-beta-released/</link>
		<comments>http://www.console-dev.de/2010/05/14/vstortoise-build-24-beta-released/#comments</comments>
		<pubDate>Fri, 14 May 2010 07:15:01 +0000</pubDate>
		<dc:creator>Peter Schraut</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[add-in]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[TortoiseSVN]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VsTortoise]]></category>

		<guid isPermaLink="false">http://www.console-dev.de/?p=892</guid>
		<description><![CDATA[VsTortoise is an add-in for Microsoft Visual Studio that provides an interface to perform the most common revision control operations directly from inside the Visual Studio IDE. It uses TortoiseSVN to execute the Subversion commands.
Existing users of VsTortoise receive an update notification if  the option &#8220;Also check for beta versions&#8221; is checked. New users can [...]]]></description>
			<content:encoded><![CDATA[<p>VsTortoise is an add-in for Microsoft Visual Studio that provides an interface to perform the most common revision control operations directly from inside the Visual Studio IDE. It uses <a href="http://tortoisesvn.net">TortoiseSVN</a> to execute the Subversion commands.</p>
<p>Existing users of VsTortoise receive an update notification if  the option &#8220;<a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_options.png">Also check for beta versions</a>&#8221; is checked. New users can download it from <a href="http://vstortoise.codeplex.com/releases/view/45202">http://vstortoise.codeplex.com/releases/view/45202</a>.</p>
<p>VsTortoise Build 24 beta changelog:</p>
<ul>
<li>New: Added &#8220;Open Modified File&#8230;&#8221; to Solution Explorer context menus. VsTortoise.SolutionExplorerSelectedItemsOpenModifiedFile command.</li>
<li>New: Added &#8220;Repository Browser&#8221; to Solution Explorer context menus. VsTortoise.SolutionExplorerSelectedItemsRepoBrowser command.</li>
<li>New: Added default shortcuts to various VsTortoise commands (ActiveDocumentDiff, ActiveDocumentDiffWithPreviousVersion, ActiveDocumentBlame, ActiveDocumentFindNextModification, ActiveDocumentFindPreviousModification, OpenModifiedFile). In case the particular shortcut is used by another Command already, VsTortoise will not steal the others shortcut and will not provide a default shortcut. Existing users of VsTortoise would need to uninstall / install the new version for this feature to take effect.</li>
<li>New: Added VsTortoise.SolutionExplorerSelectedItemsUpdateToRevision command to Solution Explorer context menus. <a href="http://vstortoise.codeplex.com/WorkItem/View.aspx?WorkItemId=6305">Issue: update to revision</a></li>
<li>New: Added options to enable/disable various VsTortoise menu integrations. Options located under Mainmenu -&gt; Tools -&gt; Options -&gt; VsTortoise -&gt; Integration. <a href="http://vstortoise.codeplex.com/WorkItem/View.aspx?WorkItemId=6306">Issue: additional code editor context menu</a></li>
<li>New: Added VsTortoise to text/code editor context menu. <a href="http://vstortoise.codeplex.com/WorkItem/View.aspx?WorkItemId=6306">Issue: additional code editor context menu</a></li>
<li>New: Assigned accelerator keys to VsTortoise menu items. You can open the VsTortoise main menu bar without using the mouse now. Just press Alt key, then use the underlined key in the VsTortoise main menu item to open it. The preferred accelerator key is Alt+S, but this can change when it is used by another menu item already.</li>
<li>New: OpenModifiedDocumentDialog: added support for &#8220;Ctrl+Enter&#8221; within filter textbox and listview to execute &#8220;Compare with base&#8221;</li>
<li>New: OpenModifiedDocumentDialog: added support for PageUp/PageDown keys in filter textbox to navigate the listview, so far only up/down were supported</li>
<li>Rem: OpenModifiedDocumentDialog: removed &#8220;select all&#8221; shortcut from listview, never used this</li>
<li>Fix: Fixed <a href="http://vstortoise.codeplex.com/WorkItem/View.aspx?WorkItemId=6310">Issue: Labels not properly sized in the options page</a></li>
<li>Fix: Fixed Webupdate &#8220;Interval in days&#8221;. An interval of 1 day should check for updates every day (when day of year changed). In earlier versions, at least 24hrs had to elapse, not taking the day of year in to account.</li>
<li>Fix: OpenModifiedDocumentDialog: List uses Windows Explorer visual style information (Windows XP or later)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.console-dev.de/2010/05/14/vstortoise-build-24-beta-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VsTortoise, Build 23 stable released</title>
		<link>http://www.console-dev.de/2010/04/07/vstortoise-build-23-stable-released/</link>
		<comments>http://www.console-dev.de/2010/04/07/vstortoise-build-23-stable-released/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 18:27:42 +0000</pubDate>
		<dc:creator>Peter Schraut</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[add-in]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[TortoiseSVN]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.console-dev.de/?p=882</guid>
		<description><![CDATA[I just uploaded VsTortoise Build 23. After more than a month of testing Build 22 Beta and fixing just one simple problem, I&#8217;m pretty confident this version is stable.
Existing users of VsTortoise should receive an update notification via the webupdate feature. New users can download it from http://vstortoise.codeplex.com/releases/view/43201.
Here is the changelog:

Fix: Executing &#8220;Blame&#8221; through the [...]]]></description>
			<content:encoded><![CDATA[<p>I just uploaded VsTortoise Build 23. After more than a month of testing Build 22 Beta and fixing just one simple problem, I&#8217;m pretty confident this version is stable.</p>
<p>Existing users of VsTortoise should receive an update notification via the <a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_webupdate.PNG">webupdate feature</a>. New users can download it from <a href="http://vstortoise.codeplex.com/releases/view/43201">http://vstortoise.codeplex.com/releases/view/43201</a>.</p>
<p>Here is the changelog:</p>
<ul>
<li>Fix: Executing &#8220;Blame&#8221; through the Solution Explorer on a file  opens TortoiseMerge rather than TortoiseBlame.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.console-dev.de/2010/04/07/vstortoise-build-23-stable-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VsTortoise, Build 22 beta available</title>
		<link>http://www.console-dev.de/2010/03/04/vstortoise-build-22-beta-available/</link>
		<comments>http://www.console-dev.de/2010/03/04/vstortoise-build-22-beta-available/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 22:08:38 +0000</pubDate>
		<dc:creator>Peter Schraut</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[TortoiseSVN]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VsTortoise]]></category>

		<guid isPermaLink="false">http://www.console-dev.de/?p=876</guid>
		<description><![CDATA[Today I uploaded VsTortoise build 22 beta to codeplex. The most significant changes are support for Visual Studio 2010RC and the Solution Explorer integration.
Here is the complete changelog:

New: Visual Studio 2010 RC support (VsTortoise  for Visual Studio 2010 RC screenshots)
New: VsTortoise integrates in to Solution Explorer context menus.  The following commands can be [...]]]></description>
			<content:encoded><![CDATA[<p>Today I uploaded VsTortoise build 22 beta to codeplex. The most significant changes are support for Visual Studio 2010RC and the Solution Explorer integration.</p>
<p>Here is the complete changelog:</p>
<ul>
<li>New: Visual Studio 2010 RC support (<a href="http://vstortoise.codeplex.com/wikipage?title=VsTortoise%20for%20Visual%20Studio%202010%20RC%20screenshots">VsTortoise  for Visual Studio 2010 RC screenshots</a>)</li>
<li>New: <a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/02/vstortoise_solutionexplorer_file_2010.png">VsTortoise integrates in to Solution Explorer context menus</a>.  The following commands can be found when you right click an item in the  Solution Explorer now: Update, Commit, Add, Blame, Diff, Diff with  previous version, Show Log, Resolve, Revert, Properties.</li>
<li>New: <a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/02/vstortoise_openmodifiedfile_2010.png">OpenModifiedFileDialog</a>: Assigned icons to context menu items</li>
<li>Fix: Icons for VsTortoise Commands using a non en-US version of  Visual Studio</li>
<li>Fix: Hide VsTortoise.ActiveDocumentDiff Command when active document  is unmodified instead of disabling it. This mimics the TortoiseSVN  explorer context menu behavior.</li>
<li>Fix: Don&#8217;t disable VsTortoise.ActiveDocumentCommit Command when  active document is unmodified. This mimics the TortoiseSVN explorer  context menu behavior.</li>
<li>Fix: VsTortoise.ActiveDocumentBlame Command is not required to save  the active document when executed</li>
<li>Fix: VsTortoise.ActiveDocumentProperties Command is not required to  save the active document when executed</li>
<li>Fix: OpenModifiedFileDialog: Rearranged order of items to more match  the TortoiseSVN commits context menu</li>
<li>Fix: OpenModifiedFileDialog: No context menu when no item is  selected</li>
<li>Fix: OpenModifiedFileDialog: Slightly optimized scanning for  modifications.</li>
<li>Fix: Typo in Webupdate diagnostics output fixed (thanks Björn)</li>
<li>Fix: The installer now also detects when Visual Studio is running on  Windows Vista / Windows 7. (contributed by Malte)</li>
</ul>
<p>Download the new version from <a href="http://vstortoise.codeplex.com/releases/view/41394">http://vstortoise.codeplex.com/releases/view/41394</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.console-dev.de/2010/03/04/vstortoise-build-22-beta-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VsTortoise, source code available at codeplex.com</title>
		<link>http://www.console-dev.de/2010/02/01/vstortoise-source-code-available-at-codeplex-com/</link>
		<comments>http://www.console-dev.de/2010/02/01/vstortoise-source-code-available-at-codeplex-com/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 20:47:49 +0000</pubDate>
		<dc:creator>Peter Schraut</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[add-in]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[TortoiseSVN]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.console-dev.de/?p=857</guid>
		<description><![CDATA[VsTortoise went open source under Apache License 2.0 (Apache) and the source code (C#) and installer scripts are available at codeplex.com now.

Project website: http://vstortoise.codeplex.com


Discussions: http://vstortoise.codeplex.com/Thread/List.aspx


Issue Tracker: http://vstortoise.codeplex.com/WorkItem/List.aspx

I also wrote a document how  to build and debug the add-in.
If anyone is interested in the project, feel free to contribute. Patches for the resources problem are [...]]]></description>
			<content:encoded><![CDATA[<p>VsTortoise went open source under <span id="currentLicense">Apache License 2.0 (Apache)</span> and the <a href="http://vstortoise.codeplex.com/sourcecontrol/changeset/view/34782?projectName=vstortoise">source code</a> (C#) and installer scripts are available at codeplex.com now.</p>
<ul>
<li>Project website: <a href="http://vstortoise.codeplex.com">http://vstortoise.codeplex.com</a></li>
</ul>
<ul>
<li>Discussions: <a href="http://vstortoise.codeplex.com/Thread/List.aspx">http://vstortoise.codeplex.com/Thread/List.aspx</a></li>
</ul>
<ul>
<li>Issue Tracker: <a href="http://vstortoise.codeplex.com/WorkItem/List.aspx">http://vstortoise.codeplex.com/WorkItem/List.aspx</a></li>
</ul>
<p>I also wrote a document <a href="http://vstortoise.codeplex.com/wikipage?title=Developer%20Installation&amp;referringTitle=Documentation">how  to build and debug the add-in</a>.</p>
<p>If anyone is interested in the project, feel free to contribute. Patches for the <a href="http://www.console-dev.de/2010/01/24/vstortoise-need-feedback/">resources problem</a> are welcome. <img src='http://www.console-dev.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I don&#8217;t have a german Visual Studio version which I could use to debug and identify the problem, it&#8217;s more like poking around in the dark for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.console-dev.de/2010/02/01/vstortoise-source-code-available-at-codeplex-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VsTortoise, need feedback</title>
		<link>http://www.console-dev.de/2010/01/24/vstortoise-need-feedback/</link>
		<comments>http://www.console-dev.de/2010/01/24/vstortoise-need-feedback/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 15:17:25 +0000</pubDate>
		<dc:creator>Peter Schraut</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[add-in]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[TortoiseSVN]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.console-dev.de/?p=838</guid>
		<description><![CDATA[VsTortoise has been downloaded about 100 times so far. One user reported VsTortoise displays a &#8220;Resource not found&#8221; error when he starts his german Visual Studio 2005 standard edition. I don&#8217;t understand what causes the problem yet, since I specified the en-US satellite DLL that comes with VsTortoise as ultimate resource fallback. I wonder whether [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.console-dev.de/page_vstortoise/">VsTortoise</a> has been downloaded about 100 times so far. One user reported VsTortoise displays a <em>&#8220;Resource not found&#8221;</em> error when he starts his <em>german</em> Visual Studio 2005 standard edition. I don&#8217;t understand what causes the problem yet, since I specified the en-US satellite DLL that comes with VsTortoise as ultimate resource fallback. I wonder whether this is a common problem or occurs on his computer only.</p>
<p><em><strong>Does VsTortoise works with your (non-english) Visual Studio version?</strong></em></p>
<p>Please leave a comment with your Visual Studio version, Visual Studio language and if it works for you. (javascript must be enabled to post comments)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.console-dev.de/2010/01/24/vstortoise-need-feedback/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>VsTortoise, a TortoiseSVN add-in for Microsoft Visual Studio</title>
		<link>http://www.console-dev.de/2010/01/08/vstortoise-a-tortoisesvn-add-in-for-microsoft-visual-studio/</link>
		<comments>http://www.console-dev.de/2010/01/08/vstortoise-a-tortoisesvn-add-in-for-microsoft-visual-studio/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 20:59:24 +0000</pubDate>
		<dc:creator>Peter Schraut</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[add-in]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[TortoiseSVN]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.console-dev.de/?p=821</guid>
		<description><![CDATA[Introduction
Over the past months I&#8217;ve worked on a TortoiseSVN add-in for Microsoft Visual Studio 2005/2008 called VsTortoise. I work with Visual Studio and TortoiseSVN every day. Since TortoiseSVN integrates in the Windows Explorer, I&#8217;ve to switch from Visual Studio to Windows Explorer alot.
This is when VsTortoise add-in comes into play. You can use VsTortoise to [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>Over the past months I&#8217;ve worked on a TortoiseSVN add-in for Microsoft Visual Studio 2005/2008 called <a href="http://www.console-dev.de/page_vstortoise/">VsTortoise</a>. I work with <a href="http://www.microsoft.com/visualstudio/en-us/howtobuy/default.mspx">Visual Studio</a> and <a href="http://tortoisesvn.net">TortoiseSVN</a> every day. Since TortoiseSVN integrates in the Windows Explorer, I&#8217;ve to switch from Visual Studio to Windows Explorer alot.</p>
<p>This is when VsTortoise add-in comes into play. You can use VsTortoise to invoke TortoiseSVN commands directly from the IDE, you don&#8217;t have to switch between Visual Studio and Windows Explorer for a lot of tasks anymore. Beside TortoiseSVN specific commands, VsTortoise provides features to help you to find uncommited modifications in your source code faster.</p>
<p>I&#8217;ve created a new page for <a href="http://www.console-dev.de/page_vstortoise/">VsTortoise</a> where you can <a href="http://www.console-dev.de/page_vstortoise/#download">download</a> it.</p>
<h3>Screenshots</h3>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_activedocument.png"><img class="alignnone size-medium wp-image-773" title="VsTortoise ActiveDocument Popup Menu" src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_activedocument-300x216.png" alt="VsTortoise ActiveDocument Popup Menu" width="300" height="216" /></a></p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_activeproject.png"><img class="alignnone size-medium wp-image-774" title="VsTortoise ActiveProject Popup Menu" src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_activeproject-300x216.png" alt="VsTortoise ActiveProject Popup Menu" width="300" height="216" /></a></p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_tools.png"><img class="alignnone size-medium wp-image-776" title="VsTortoise Tools Popup Menu" src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_tools-300x216.png" alt="VsTortoise Tools Popup Menu" width="300" height="216" /></a></p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_openmodifiedfile.png"><img class="alignnone size-medium wp-image-775" title="VsTortoise OpenModifiedFile Dialog" src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_openmodifiedfile-300x216.png" alt="VsTortoise OpenModifiedFile Dialog" width="300" height="216" /></a></p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_keyboard.png"><img class="alignnone size-medium wp-image-777" title="VsTortoise commands in Visual Studio Keyboard options" src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_keyboard-300x216.png" alt="VsTortoise commands in Visual Studio Keyboard options" width="300" height="216" /></a></p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_options.png"><img class="alignnone size-medium wp-image-806" title="VsTortoise - Options integration in to the standard Microsoft Visual Studio Options dialog" src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_options-299x205.png" alt="VsTortoise - Options integration in to the standard Microsoft Visual Studio Options dialog" width="299" height="205" /></a></p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_webupdate.PNG"><img class="alignnone size-medium wp-image-804" title="VsTortoise - Webupdate notification" src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/12/vstortoise_webupdate-299x205.PNG" alt="VsTortoise - Webupdate notification" width="299" height="205" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.console-dev.de/2010/01/08/vstortoise-a-tortoisesvn-add-in-for-microsoft-visual-studio/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>guru meditation error (data abort exception)</title>
		<link>http://www.console-dev.de/2009/09/20/guru-meditation-error-data-abort-exception/</link>
		<comments>http://www.console-dev.de/2009/09/20/guru-meditation-error-data-abort-exception/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 08:06:25 +0000</pubDate>
		<dc:creator>Peter Schraut</dc:creator>
				<category><![CDATA[NDS]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.console-dev.de/?p=751</guid>
		<description><![CDATA[The processors built-in the Nintendo DS, an ARM946E-S and ARM7TDMI, support hardware exceptions such as &#8220;Data Abort &#8211; accessing invalid memory addresses&#8221; and &#8220;Undefined Instruction&#8221;. The Nintendo DS homebrew library libnds includes exception handling and comes with a default handler that displays the exception type, at which address in the instruction sequence the exception occured [...]]]></description>
			<content:encoded><![CDATA[<p>The processors built-in the <a href="http://en.wikipedia.org/wiki/Nintendo_DS">Nintendo DS</a>, an <a href="http://en.wikipedia.org/wiki/ARM9">ARM946E-S</a> and <a href="http://en.wikipedia.org/wiki/ARM7">ARM7TDMI</a>, support hardware exceptions such as <em>&#8220;Data Abort &#8211; accessing invalid memory addresses&#8221;</em> and <em>&#8220;Undefined Instruction&#8221;</em>. The Nintendo DS homebrew library <a href="http://en.wikipedia.org/wiki/Libnds">libnds</a> includes exception handling and comes with a default handler that displays the exception type, at which address in the instruction sequence the exception occured and a dump of all registers.</p>
<p>In this article I show what you can do with this information and why it is useful during development.</p>
<h3>libnds exceptionTest example</h3>
<p>If you installed the libnds examples, you should find the <em>exeptionTest</em> example in <em>devkitPro\examples\nds\debugging\exceptionTest</em>.</p>
<p>Copy&#038;Paste from exceptionTest.c:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;nds.h&gt;</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">/*---------------------------------------------------------------------------------
&nbsp;
 The default exception handler displays the exception type - data abort or undefined
 instruction you can relate the exception to your code using
&nbsp;
    arm-eabi-addr2line -e &lt;elf file&gt; &lt;address&gt;
&nbsp;
 assuming you built with debug info this will display a source file and a line number
 The address of the instruction is shown as pc, beside the address which faulted
 the rest of the screen is a dump of the registers.
&nbsp;
---------------------------------------------------------------------------------*/</span>
&nbsp;
<span style="color: #666666;">//---------------------------------------------------------------------------------</span>
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #666666;">// install the default exception handler</span>
  defaultExceptionHandler<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #666666;">// generate an exception</span>
  <span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #208080;">0xFA</span> <span style="color: #000080;">=</span> <span style="color: #208080;">0x64</span><span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #666666;">// never comes here</span>
  <span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span>
    swiWaitForVBlank<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>When you build and run the example project, it displays:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/libnds_guru_meditation_data.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/libnds_guru_meditation_data.png" alt="Guru Meditation Error! - Data Abort" title="Guru Meditation Error! - Data Abort" width="286" height="443" class="alignnone size-full wp-image-755" /></a></p>
<p>This is actually a fake screenshot. I rebuilt the <em>Guru Meditation Error</em> with printf, because the example didn&#8217;t behave in any emulator as on actual hardware. I tested <a href="http://nocash.emubase.de/gba.htm">no$gba 2.6a</a>, <a href="http://www.ideasemu.org">iDeaS 1.0.3.3 beta</a> and <a href="http://sourceforge.net/projects/desmume/">DeSmeME 0.9.5</a>, none of them displayed the error report as on the real Nintendo DS hardware.</p>
<h3>guru meditation origin</h3>
<p><a href="http://en.wikipedia.org/wiki/Guru_meditation">Guru Meditation</a> is the name of the error that occurred on early versions of the <a href="http://en.wikipedia.org/wiki/Commodore_Amiga">Commodore Amiga</a> computer when they crashed. It is analogous to the &#8220;Blue Screen Of Death&#8221; in Microsoft Windows operating systems.</p>
<p>The Guru Meditation error message was a black screen with the following animation at the top:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/amiga_guru_meditation.gif"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/amiga_guru_meditation.gif" alt="Commodore Amiga - Guru Meditation error message" title="Commodore Amiga - Guru Meditation error message" width="652" height="93" class="alignnone size-full wp-image-756" /></a></p>
<h3>decode nds guru meditation data abort message</h3>
<p>One of the Nintendo DS variants of the Guru Meditation error message is the data abort, which includes the following information:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">     Guru Meditation Error!    
          data abort!          
&nbsp;
  pc: 02000386 addr: 000000FA  
&nbsp;
  r0: 020005BD   r8 : 00000000 
  r1: 00000000   r9 : 00000000 
  r2: 00000064   r10: 00000000 
  r3: 000000FA   r11: 00000000 
  r4: 0B000000   r12: 02000000 
  r5: 00000000   sp : 0B003CF8 
  r6: 00000000   lr : 020005B5 
  r7: 00000000   pc : 0200038E 
&nbsp;
  0B003CF8: 0B000000 02000180  
  0B003D00: 00000000 00000000  
  0B003D08: 00000000 00000000  
  0B003D10: 00000000 00000000  
  0B003D18: 00000000 00000000  
  0B003D20: 00000000 00000000  
  0B003D28: 00000000 00000000  
  0B003D30: 00000000 00000000  
  0B003D38: 00000000 00000000  
  0B003D40: 00000000 00000000</pre></td></tr></table></div>

<p>The first line is always &#8220;Guru Meditation Error!&#8221;, followed by the type of the exception:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">     Guru Meditation Error!    
          data abort!</pre></td></tr></table></div>

<p>The libnds default exception handler displays &#8220;Data Abort&#8221; and &#8220;Undefined Instructions&#8221; exceptions.</p>
<p>Below the exception type is <em>pc</em> and <em>addr</em> displayed, which I guess is not very obvious for many novice programmers:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">  pc: 02000386 addr: 000000FA</pre></td></tr></table></div>

<p><em>pc</em> is short for <a href="http://en.wikipedia.org/wiki/Program_counter">Program Counter</a>. The Program Counter register indicates where the processor is in its instruction sequence. In this case, it&#8217;s the address of the instruction that caused the exception.</p>
<p><em>addr</em> represents the exception address. In this case, writing to the memory address 0xFA:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">  <span style="color: #666666;">// generate an data abort exception</span>
  <span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #208080;">0xFA</span> <span style="color: #000080;">=</span> <span style="color: #208080;">0x64</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>This again is followed by a register dump:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">  r0: 020005BD   r8 : 00000000 
  r1: 00000000   r9 : 00000000 
  r2: 00000064   r10: 00000000 
  r3: 000000FA   r11: 00000000 
  r4: 0B000000   r12: 02000000 
  r5: 00000000   sp : 0B003CF8 
  r6: 00000000   lr : 020005B5 
  r7: 00000000   pc : 0200038E</pre></td></tr></table></div>

<ul>
<li><em>r0</em> &#8211; <em>r12</em> are the so called <a href="http://en.wikipedia.org/wiki/Processor_register">General Purpose Registers</a>.</li>
<li><em>sp</em> (r13) is the <a href="http://en.wikipedia.org/wiki/Call_stack#Structure">Stack Pointer Register</a>, which indicates the current top of stack memory.</li>
<li><em>lr</em> (r14) represents the <a href="http://en.wikipedia.org/wiki/Link_register">Link Register</a>, which holds the return address when the current function completes (it&#8217;s the address of the caller).</li>
<li><em>pc</em> (r15) is short for <a href="http://en.wikipedia.org/wiki/Program_counter">Program Counter</a>. The Program Counter register indicates where the processor is in its instruction sequence.</li>
</ul>
<p>The last information in the error report is a memory dump of the top 80 bytes of stack memory:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">  0B003CF8: 0B000000 02000180  
  0B003D00: 00000000 00000000  
  0B003D08: 00000000 00000000  
  0B003D10: 00000000 00000000  
  0B003D18: 00000000 00000000  
  0B003D20: 00000000 00000000  
  0B003D28: 00000000 00000000  
  0B003D30: 00000000 00000000  
  0B003D38: 00000000 00000000  
  0B003D40: 00000000 00000000</pre></td></tr></table></div>

<ul>
<li>First column specifies the stack address (0B003CF8)</li>
<li>Second column shows the 32bit value from the stack address (0B000000)</li>
<li>Third column shows the 32bit value from the stack address + 4 bytes (02000180)</li>
</ul>
<h3>how to make use of all this</h3>
<p>This information is informative only when the output file was built with debug information. You can include debug information by adding the <a href="http://gcc.gnu.org/onlinedocs/gcc-4.4.1/gcc/Debugging-Options.html#Debugging-Options">-g option (produce debugging information)</a> to CFLAGS in the project makefile:</p>
<p>Copy&#038;Paste from <em>exceptionTest</em> makefile:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">CFLAGS	:= -g -Wall -O2\
		-march=armv5te -mtune=arm946e-s \
 		-fomit-frame-pointer\
		-ffast-math \
		$(ARCH)</pre></td></tr></table></div>

<p><a href="http://www.devkitpro.org">devkitARM</a> includes an application named <em>&#8220;arm-eabi-addr2line.exe&#8221;</em>, located in <em>devkitPro\devkitARM\bin</em>, that can be used to convert addresses into line number/file name pairs. It supports the following command line options:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">Usage: arm-eabi-addr2line.exe [option(s)] [addr(s)]
 Convert addresses into line number/file name pairs.
 If no addresses are specified on the command line, they will be read from stdin
&nbsp;
 The options are:
  @&lt;file&gt;                Read options from &lt;file&gt;
  -b --target=&lt;bfdname&gt;  Set the binary file format
  -e --exe=&lt;executable&gt;  Set the input file name (default is a.out)
  -i --inlines           Unwind inlined functions
  -j --section=&lt;name&gt;    Read section-relative offsets instead of addresses
  -s --basenames         Strip directory names
  -f --functions         Show function names
  -C --demangle[=style]  Demangle function names
  -h --help              Display this information
  -v --version           Display the program's version</pre></td></tr></table></div>

<p>We are interested in the address where the Data Abort exception occured, named <em>pc</em> here:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">     Guru Meditation Error!    
          data abort!          
&nbsp;
  pc: 02000386 addr: 000000FA</pre></td></tr></table></div>

<p>I used the following commandline for conversion:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">arm-eabi-addr2line.exe -f -C -e  -s -i exceptionTest.elf 02000386</pre></td></tr></table></div>

<p>The output is:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">main
exceptionTest.c:23</pre></td></tr></table></div>

<p>When you scroll at the beginning of this article, where I present the source code of the exceptionTest example, you see line 23 is inside main(), which is stored in exceptionTest.c and contains the code that writes to the address 0xFA.</p>
<h3>conclusion</h3>
<p>Make sure to install an exception handler in your projects. It&#8217;s very helpful to actually see that an error occured rather than a freeze. libnds makes it enormously easy, it&#8217;s just one line of code!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.console-dev.de/2009/09/20/guru-meditation-error-data-abort-exception/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>create nintendo ds applications with visual studio 2008</title>
		<link>http://www.console-dev.de/2009/09/03/create-nintendo-ds-applications-with-visual-studio-2008/</link>
		<comments>http://www.console-dev.de/2009/09/03/create-nintendo-ds-applications-with-visual-studio-2008/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 07:43:00 +0000</pubDate>
		<dc:creator>Peter Schraut</dc:creator>
				<category><![CDATA[NDS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Homebrew]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VisualHAM]]></category>

		<guid isPermaLink="false">http://www.console-dev.de/?p=712</guid>
		<description><![CDATA[introduction
In this article I show how to set up Microsoft Visual Studio 2008 to use the devkitARM compiler to create applications for the Nintendo DS. After you have read this article, you are able to use Visual Studio 2008 to build, rebuild, clean and execute your Nintendo DS application.
Visual Studio 2008 Express can be downloaded [...]]]></description>
			<content:encoded><![CDATA[<h3>introduction</h3>
<p>In this article I show how to set up <a href="http://www.microsoft.com/express/">Microsoft Visual Studio 2008</a> to use the <a href="http://www.devkitpro.org">devkitARM</a> compiler to create applications for the Nintendo DS. After you have read this article, you are able to use Visual Studio 2008 to build, rebuild, clean and execute your Nintendo DS application.</p>
<p>Visual Studio 2008 Express can be downloaded for free at microsoft.com, you want to have the C++ edition: <a href="http://www.microsoft.com/express/download/">Download Visual C++ 2008 Express Edition</a>.</p>
<h3>prerequisites</h3>
<p>I assume you already have devkitARM and Visual Studio 2008 installed and both function correctly. I further assume you have a project that you want to migrate from e.g. VisualHAM, Programmers Notepad, etc&#8230; to Visual Studio, so I use the <em>hello world</em> example from libnds as existing project reference, which is located in <em>devkitPro\examples\nds\hello_world</em>.</p>
<h3>create new visual studio project</h3>
<p>We need to create an empty makefile project. You can find this in Visual Studio 2008 under <em>Main menu -> New -> Project</em>:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_new_project.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_new_project-300x252.png" alt="Visual Studio 2008 - Showing the path to create a new project" title="Visual Studio 2008 - Showing the path to create a new project" width="300" height="252" class="alignnone size-medium wp-image-717" /></a></p>
<p>Select the project template and target location:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_new_project_dialog.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_new_project_dialog-300x201.png" alt="Visual Studio 2008 - Create new project dialog" title="Visual Studio 2008 - Create new project dialog" width="300" height="201" class="alignnone size-medium wp-image-718" /></a></p>
<p>Rather than selecting the <em>hello_world</em> directory, we specify its parent, because Visual Studio creates a sub directory in the specified location with the specified name. This configuration will save the project file directly in the existing <em>hello_world</em> directory.</p>
<p>Click OK to continue.</p>
<h3>configure new project</h3>
<p>A new dialog pops up, the <em>New Project Wizard</em>:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_new_project_wizard1.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_new_project_wizard1-300x253.png" alt="Visual Studio 2008 - Create new project wizard" title="Visual Studio 2008 - Create new project wizard" width="300" height="253" class="alignnone size-medium wp-image-719" /></a></p>
<p>Just click <em>Next</em> here to move on to the next page.</p>
<p>The following page looks more like fun! Settings specified in this <em>New Project Wizard</em> can be changed at any time in the <em>Project Settings</em> as well:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_new_project_wizard2.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_new_project_wizard2-300x253.png" alt="Visual Studio 2008 - Create new project wizard" title="Visual Studio 2008 - Create new project wizard" width="300" height="253" class="alignnone size-medium wp-image-720" /></a></p>
<p>Please note that none of these settings have influence on the build process: <em>Output, Preprocessor definitions, Include search path, Forced include files, CMR assembly search path and Forced using .NET assemblies</em>.</p>
<p>We set <em>Preprocessor definitions</em> so Visual Studio knows which ARM9/ARM7 #if&#8217;s to syntax highlight differently. This is <strong>not</strong> passed to devkitARM.</p>
<p>We set <em>Include search path</em> so Visual Studio knows where to look for the libnds headers to provide code completion and intellisense, it will <strong>not</strong> add it to the search path used by devkitARM.</p>
<p>Here is an example what code completion and intellisense look like, first code completion:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_codecompletion.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_codecompletion-300x252.png" alt="Visual Studio 2008 - Code completion (with Visual AssistX add-in activated)" title="Visual Studio 2008 - Code completion (with Visual AssistX add-in activated)" width="300" height="252" class="alignnone size-medium wp-image-738" /></a></p>
<p>Intellisense:<br />
<a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_intellisense.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_intellisense-300x252.png" alt="Visual Studio 2008 - Showing intellisense (with Visual AssistX add-in activated)" title="Visual Studio 2008 - Showing intellisense (with Visual AssistX add-in activated)" width="300" height="252" class="alignnone size-medium wp-image-739" /></a></p>
<p>The remaining commands in the <em>New Project Wizard</em> are what you typically use when working via the command prompt or shell. Now click <em>Finish</em> to complete the Wizard.</p>
<p>The <em>New Project Wizard</em> closes and Visual Studio shows an empty workspace now:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_empty_project.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_empty_project-300x252.png" alt="Visual Studio 2008 - Showing an empty project" title="Visual Studio 2008 - Showing an empty project" width="300" height="252" class="alignnone size-medium wp-image-716" /></a></p>
<h3>add files to project</h3>
<p>It&#8217;s essential to know that Visual Studio will just invoke the commands specified in the <em>New Project Wizard</em> to build the project.</p>
<p><strong>Compiling and linking your Nintendo DS application is entirely handled by devkitARM, NOT Visual Studio!</p>
<p></strong> Visual Studio is only the graphical front-end that triggers these devkitARM build processes and serves as code editor.</p>
<p>The devkitPro makefile system has a feature to add directories that are supposed to contain source code to the so called <em>SOURCES</em> variable. All source files in those directories, added to this variables, are being compiled and considered during the link process.</p>
<p>Copied from <em>devkitPro\examples\nds\hello_world\Makefile</em>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files &amp; intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET		:=	$(shell basename $(CURDIR))
BUILD		:=	build
SOURCES		:=	gfx source data  
INCLUDES	:=	include build</pre></td></tr></table></div>

<p>This means that source files don&#8217;t get compiled when you add them to the Visual Studio project, but when you store them in the <em>source</em> directory of your file system!</p>
<h3>add files to project, really</h3>
<p>Now that you know your files don&#8217;t get compiled when you only add them to the <em>Visual Studio Project</em>, let&#8217;s really add them. You can do this via drag&#038;drop operations from the Windows Explorer or via the <em>Visual Studio Project</em> context menu:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_add_existing_item.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_add_existing_item-300x252.png" alt="Visual Studio 2008 - Menu path to add an existing item to a project file" title="Visual Studio 2008 - Menu path to add an existing item to a project file" width="300" height="252" class="alignnone size-medium wp-image-722" /></a></p>
<p>A new &#8220;File Open&#8221; dialog appears, which you have to navigate to your source files, select them and click <em>Add</em>. I recommend you add the <em>makefile</em> too.</p>
<p>Once done, your <em>Visual Studio Project</em> should look similar to this:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_code_editor.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_code_editor-300x252.png" alt="Visual Studio 2008 - Editing a .cpp file" title="Visual Studio 2008 - Editing a .cpp file" width="300" height="252" class="alignnone size-medium wp-image-723" /></a></p>
<h3>compile project</h3>
<p>The magic moment has arrived, to compile the project you can use the <em>Build</em> sub-menu from the mainbar or hit CTRL+SHIFT+B:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_build_popup.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_build_popup-300x252.png" alt="Visual Studio 2008 - Showing the Build sub-menu in the mainbar" title="Visual Studio 2008 - Showing the Build sub-menu in the mainbar" width="300" height="252" class="alignnone size-medium wp-image-725" /></a></p>
<p>When everything is configured properly, the project should build just fine and the output looks like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">1&gt;------ Build started: Project: hello_world, Configuration: Debug Win32 ------
1&gt;Performing Makefile project actions
1&gt;main.cpp
1&gt;arm-eabi-g++ -MMD -MP -MF /c/devkitPro/examples/nds/hello_world/build/main.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -I/c/devkitPro/examples/nds/hello_world/include -I/c/devkitPro/examples/nds/hello_world/build -I/c/devkitPro/libnds/include -I/c/devkitPro/libnds/include -I/c/devkitPro/examples/nds/hello_world/build -DARM9 -fno-rtti -fno-exceptions -c /c/devkitPro/examples/nds/hello_world/source/main.cpp -o main.o
1&gt;linking hello_world.elf
1&gt;built ... hello_world.arm9
1&gt;Nintendo DS rom tool 1.41 - May  1 2009
1&gt;by Rafael Vuijk, Dave Murphy, Alexei Karpenko
1&gt;built ... hello_world.nds
1&gt;Build log was saved at &quot;file://c:\devkitPro\examples\nds\hello_world\Debug\BuildLog.htm&quot;
1&gt;hello_world - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========</pre></td></tr></table></div>

<h3>compile project, the Vista barrier</h3>
<p>I use Microsoft Vista and have to run Visual Studio 2008 as administrator, otherwise it outputs this error:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">1&gt;------ Build started: Project: hello_world, Configuration: Debug Win32 ------
1&gt;Performing Makefile project actions
1&gt;      0 [main] us 0 init_cheap: VirtualAlloc pointer is null, Win32 error 487
1&gt;AllocationBase 0x0, BaseAddress 0x71110000, RegionSize 0x2C0000, State 0x10000
1&gt;c:\devkitPro\msys\bin\make.exe: *** Couldn't reserve space for cygwin's heap, Win32 error 0
1&gt;Project : error PRJ0019: A tool returned an error code from &quot;Performing Makefile project actions&quot;
1&gt;Build log was saved at &quot;file://c:\devkitPro\examples\nds\hello_world\Debug\BuildLog.htm&quot;
1&gt;hello_world - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</pre></td></tr></table></div>

<p>If you encounter the same problem, see if it fixes the problem when you start Visual Studio 2008 with administrator privileges. You can do this when you right-click the Visual Studio 2008 startmenu entry and select &#8220;Run as administrator&#8221;.</p>
<h3>add a rebuild target</h3>
<p>We specified &#8220;make rebuild&#8221; in the <em>New Project Wizard</em>, but this target does not exist by default, so we have to create it first. Basically it should perform:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">make clean
make</pre></td></tr></table></div>

<p>Open the <em>makefile</em> and add this below <em>clean</em>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">rebuild: clean $(BUILD)</pre></td></tr></table></div>

<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_makefile_rebuild.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_makefile_rebuild-300x252.png" alt="Visual Studio 2008 - Adding a &#039;rebuild&#039; target to makefile" title="Visual Studio 2008 - Adding a &#039;rebuild&#039; target to makefile" width="300" height="252" class="alignnone size-medium wp-image-729" /></a></p>
<p>Select <em>Build -> Rebuild Solution</em> and see the output if it&#8217;s performing correctly.</p>
<h3>add run target</h3>
<p>So far we were able to compile, clean and rebuild the Nintendo DS project out of Visual Studio, but how to run it? We use a software emulator! I use <a href="http://nocash.emubase.de/gbapics.htm">no$gba</a> to run my Game Boy Advance and Nintendo DS applications, so I want Visual Studio to start no$gba as well!</p>
<p>We do this like we did with <em>rebuild</em>, we add a new target to <em>makefile</em> which is responsible to start and pass the filename to the Nintendo DS emulator, in my case no$gba.</p>
<p>Put this below our earlier added <em>rebuild</em> target:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">run: $(BUILD)
	$(DEVKITPRO)/utilities/nogba/nogba.exe $(TARGET).nds</pre></td></tr></table></div>

<p>The tab at the beginning at the 2nd line is important and must not be removed, you also want to modify the path to where the emulator of your choice is located.</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_makefile_run.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_makefile_run-300x252.png" alt="Visual Studio 2008 - Adding a target to run the output in an emulator" title="Visual Studio 2008 - Adding a target to run the output in an emulator" width="300" height="252" class="alignnone size-medium wp-image-734" /></a></p>
<p>Now open the <em>Visual Studio Project Properties</em>:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_project_popup.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_project_popup-300x252.png" alt="Visual Studio 2008 - Project context menu" title="Visual Studio 2008 - Project context menu" width="300" height="252" class="alignnone size-medium wp-image-727" /></a></p>
<p>Select <em>Debugging</em> in the following dialog and fill out the <em>Command</em> and <em>Command Argument</em> text boxes:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_project_debugging_proper.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_project_debugging_proper-300x209.png" alt="Visual Studio 2008 - Project debugging properties" title="Visual Studio 2008 - Project debugging properties" width="300" height="209" class="alignnone size-medium wp-image-736" /></a></p>
<p>Confirm the dialog with OK and select <em>Debug -> Start Debugging</em>, the project should build and start in the specified emulator!</p>
<h3>Visual Studio compatible build messages</h3>
<p>All build messages are redirected to the Visual Studio output &#8220;Build&#8221; pane. Warnings and errors include the filename and line number, but those are in the GCC format and when you double click them, Visual Studio is smart enough to open this file, but not to go to the line.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">1&gt;c:/devkitPro/examples/nds/hello_world/source/main.cpp:17: error: expected constructor, destructor, or type conversion before 'void'</pre></td></tr></table></div>

<p>Double clicking this line opens main.cpp, but keeps the cursor at line 1.</p>
<p>Fortunalety, <a href="http://www.coranac.com">Jasper &#8216;cearn&#8217; Vijn</a> once had a regular expression on his website that transforms GCC messages in to Visual Studio format and I was clever enough to make a backup before the information went offline:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">'s/\(\w\+\):\([0-9]\+\):/\1(\2):/'</pre></td></tr></table></div>

<p>We can redirect the build output to <a href="http://en.wikipedia.org/wiki/Sed">sed.exe (stream editor)</a>, which uses this regular expresssion to transform and output the text so Visual Studio can handle it.</p>
<p>We do this by extending the commands earlier specified in the <em>New Project Wizard</em>.</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_project_popup.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_project_popup-300x252.png" alt="Visual Studio 2008 - Project context menu" title="Visual Studio 2008 - Project context menu" width="300" height="252" class="alignnone size-medium wp-image-727" /></a></p>
<p>In the following dialog select <em>NMake</em> and modify the settings as shown below:</p>
<p><a href="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_project_nmake_properties.png"><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/09/vs_project_nmake_properties-300x209.png" alt="Visual Studio 2008 - Makefile Project properties" title="Visual Studio 2008 - Makefile Project properties" width="300" height="209" class="alignnone size-medium wp-image-728" /></a></p>
<p>Build Command line:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">make 2&gt;&amp;1 | sed -e 's/\(\w\+\):\([0-9]\+\):/\1(\2):/'</pre></td></tr></table></div>

<p>Rebuild All Command line:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">make rebuild 2&gt;&amp;1 | sed -e 's/\(\w\+\):\([0-9]\+\):/\1(\2):/'</pre></td></tr></table></div>

<p>If you have never seen this <strong>2>&#038;1</strong> before, it&#8217;s called <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true">command redirection operator</a> and a feature of Microsoft Windows. <strong>>&#038;</strong> writes the output from one handle to the input of another handle. Next comes <strong>|</strong>, the pipe operator. It takes the output of one command and directs it into the input of another command.</p>
<p>Confirm the Project Properties Dialog with OK, add an invalid line of code to one source file and build. The error message should look like this now and is clickable:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">1&gt;c:/devkitPro/examples/nds/hello_world/source/main.cpp(17): error: expected constructor, destructor, or type conversion before 'void'</pre></td></tr></table></div>

<h3>we are done</h3>
<p>Happy compiling!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.console-dev.de/2009/09/03/create-nintendo-ds-applications-with-visual-studio-2008/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>callstack trace on the nintendo ds</title>
		<link>http://www.console-dev.de/2009/08/16/callstack-trace-on-the-nintendo-ds/</link>
		<comments>http://www.console-dev.de/2009/08/16/callstack-trace-on-the-nintendo-ds/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 23:00:38 +0000</pubDate>
		<dc:creator>Peter Schraut</dc:creator>
				<category><![CDATA[GBA]]></category>
		<category><![CDATA[NDS]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.console-dev.de/?p=675</guid>
		<description><![CDATA[introduction
I was experimenting how I could retrieve a stack trace on the Nintendo DS, using the devkitARM compiler, recently. A callstack is a list of active subroutines of a computer program. This can be used to identify from which code-path a particular subroutine was called, which is enormously helpful when detecting logical errors at run-time.
I [...]]]></description>
			<content:encoded><![CDATA[<h3>introduction</h3>
<p>I was experimenting how I could retrieve a <a href="http://en.wikipedia.org/wiki/Backtrace">stack trace</a> on the Nintendo DS, using the <a href="http://www.devkitpro.org">devkitARM</a> compiler, recently. A callstack is a list of active subroutines of a computer program. This can be used to identify from which code-path a particular subroutine was called, which is enormously helpful when detecting logical errors at run-time.</p>
<p>I tend to flood my code with &#8220;ASSERT&#8217;s&#8221;. ASSERT is used to identify logic errors during program development by implementing the expression argument to evaluate to FALSE only when the program is operating incorrectly and then calling a function to report the error:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> Vector2Add<span style="color: #008000;">&#40;</span>Vector2 <span style="color: #000040;">*</span>dest, <span style="color: #0000ff;">const</span> Vector2 <span style="color: #000040;">*</span>v0, <span style="color: #0000ff;">const</span> Vector2 <span style="color: #000040;">*</span>v1<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  ASSERT<span style="color: #008000;">&#40;</span>dest <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  ASSERT<span style="color: #008000;">&#40;</span>v0 <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  ASSERT<span style="color: #008000;">&#40;</span>v1 <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
  dest<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>x <span style="color: #000080;">=</span> v0<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>x <span style="color: #000040;">+</span> v1<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>x<span style="color: #008080;">;</span>
  dest<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>y <span style="color: #000080;">=</span> v0<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>y <span style="color: #000040;">+</span> v1<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>y<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>When any of the incoming arguments point to NULL, ASSERT will call a subroutine to report the error. Typically the report includes the filename, line number and functionname. This information is helpful, but lacks of information from where the function was called.</p>
<p>I use Vector2Add all over the place, how should I know what part in my program code does not work, when I only know at some point a NULL argument is passed to Vector2Add?</p>
<p>Right, I need to know from where Vector2Add was called, I need a callstack trace!</p>
<h3>my earlier instrumentation approach</h3>
<p>Around 2005-2006 I implemented a <a href="http://www.console-dev.de/hel/docs/group__helDebugAssert.html">callstack trace feature in HEL Library</a>. HEL Library is a middleware solution to ease development of Game Boy Advance titles.</p>
<p>The callstack trace was displayed together with an assertion-report, that looked like:<br />
<img src="http://www.console-dev.de/hel/docs/assert_01.png" alt="HEL Library assertion report" /></p>
<p><img src="http://www.console-dev.de/hel/docs/assert_02.png" alt="HEL Library callstack trace" /></p>
<p>Back then I used function instrumentation (<a href="http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Code-Gen-Options.html">-finstrument-functions</a>) to build a list of subroutine calls at run-time. It was basically a callback that was called for every function that is about to be entered (__cyg_profile_func_enter) and left (__cyg_profile_func_exit).</p>
<p>This was a huge overhead and slowed down program-execution dramatically, but the callstack trace was so precious, that the performance penalty didn&#8217;t matter for the <a href="http://www.console-dev.de/hel/docs/PageLibraries.html#SectionLibhel2_dcs">debug library</a>.</p>
<h3>fail does not mean to stop</h3>
<p>When I started the Nintendo DS version, one goal was to use an approach which does not have any impact on run-time performance! I have tried several libraries, unfortunalety I didn&#8217;t find anything that worked for me.</p>
<p>This includes <a href="http://www.nongnu.org/libunwind/">libunwind</a>, <a href="http://www.gnu.org/s/libc/manual/html_node/Backtraces.html">backtrace</a>, several GCC builtin-keywords to get return addresses of different calldepths, just to name a few.</p>
<p>I gave all up. It was either a never ending story to integrate the library in to the project or headers / functions were missing in libraries that come with devkitARM.</p>
<h3>hacking to success, then fail</h3>
<p>Rather than giving up, I decided to accept it as challenge and come up with my own callstack trace code. It was a long and rocky journey, but at the end I had something that worked suprisingly well.</p>
<p>What I do is basically pretty simple, I interpret instructions of interest to simulate the beaviour of the <a href="http://en.wikipedia.org/wiki/Program_counter">Program Counter (PC)</a> and <a href="http://en.wikipedia.org/wiki/Stack_pointer">Stack Pointer (SP)</a>.  The Program Counter indicates where the program is in its intruction sequence. Stack Pointer indicates the current top of stack memory. The stack this is where local variables are located.</p>
<p>Armed with my own Program Counter and Stack Pointer variables, I can traverse program code and react when Program Counter is assigned a new value, which basically means to jump to a different address and continue to operate there.</p>
<p>Example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> FirstFunc<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  SecondFunc<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> SecondFunc<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #666666;">// Program Counter is located here  &lt;--</span>
  ThirdFunc<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Let&#8217;s presume the Program Counter is located in SecondFunc, which was previously called by FirstFunc.</p>
<p>The thumb assembler version of this looks like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="asm" style="font-family:monospace;">FirstFunc<span style="color: #339933;">:</span>
  <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #009900; font-weight: bold;">&#123;</span>lr<span style="color: #009900; font-weight: bold;">&#125;</span>       <span style="color: #666666; font-style: italic;">; Push Link Register (LR) on stack</span>
  <span style="color: #00007f; font-weight: bold;">sub</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> #<span style="color: #0000ff;">4</span>  <span style="color: #666666; font-style: italic;">; Update Stack Pointer by 4bytes because LR was pushed</span>
  <span style="color: #00007f;">bl</span>  SecondFunc  <span style="color: #666666; font-style: italic;">; Call to SecondFunc()</span>
  <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> #<span style="color: #0000ff;">4</span>  <span style="color: #666666; font-style: italic;">; Update Stack Pointer to point to pushed LR again</span>
  <span style="color: #00007f; font-weight: bold;">pop</span> <span style="color: #009900; font-weight: bold;">&#123;</span>pc<span style="color: #009900; font-weight: bold;">&#125;</span>        <span style="color: #666666; font-style: italic;">; Pop LR from stack and store in Program Counter, this will return to caller</span>
&nbsp;
SecondFunc<span style="color: #339933;">:</span>
  <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #009900; font-weight: bold;">&#123;</span>lr<span style="color: #009900; font-weight: bold;">&#125;</span>       <span style="color: #666666; font-style: italic;">; Push Link Register (LR) on stack</span>
  <span style="color: #00007f; font-weight: bold;">sub</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> #<span style="color: #0000ff;">4</span>  <span style="color: #666666; font-style: italic;">; Update Stack Pointer by 4bytes because LR was pushed</span>
  <span style="color: #00007f;">bl</span>  ThirdFunc   <span style="color: #666666; font-style: italic;">; Call to ThirdFunc()</span>
  <span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> #<span style="color: #0000ff;">4</span>  <span style="color: #666666; font-style: italic;">; Update Stack Pointer to point to pushed LR again</span>
  <span style="color: #00007f; font-weight: bold;">pop</span> <span style="color: #009900; font-weight: bold;">&#123;</span>pc<span style="color: #009900; font-weight: bold;">&#125;</span>        <span style="color: #666666; font-style: italic;">; Pop LR from stack and store in Program Counter, this will return to caller</span></pre></td></tr></table></div>

<p>I need to get my hands on the <a href="http://en.wikipedia.org/wiki/Link_register">Link Register (LR)</a> to return to SecondFunc&#8217;s caller (*1). Since LR was being pushed on the stack, I know where to look! What is left is to traverse the program code in reversed order and interpret the &#8220;sub&#8221; and &#8220;push&#8221; instructions.</p>
<p>Moving the Program Counter in reversed order, which actually would be a backtrace imo, didn&#8217;t work out for some reasons and I wasn&#8217;t able to solve those problems. It did, however, worked in some cases, unfortunalety too unreliable.</p>
<h3>when in doubt, try it out</h3>
<p>I stayed away from this problem for week and then had the idea why not trying to simulate the Program Counter the same way it would walk along when it continues program execution normally. It means rather then traversing program code backwards, I tried what happens, when I forward advance PC. Now I have to interpret &#8220;add&#8221; and &#8220;pop&#8221; instructions and this works suprisingly well!</p>
<p>From here on it took a few hours to come up with a version that is robust enough to work in all places that I tested with my code base, which consists of both, C and C++ source code.</p>
<p>Obviously it does not mean it always works in every sitiuation with all source code in the world. For example, optimization level -O0 generates so many unconditional branches and places return code all over the place, that the <em>Stacktrace</em> function fails. It supports thumb code only and has problens with hand written/optimized assembler routines (when LR is not push&#8217;ed and PC not pop&#8217;ed).</p>
<p>I added a couple of more instruction <em>Stacktrace</em> looks out for:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #00007f; font-weight: bold;">pop</span> <span style="color: #009900; font-weight: bold;">&#123;</span><span style="color: #339933;">...</span>pc<span style="color: #009900; font-weight: bold;">&#125;</span> <span style="color: #666666; font-style: italic;">; adjust PC to the pop'ed value</span>
<span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> nn  <span style="color: #666666; font-style: italic;">; adjust SP by nn</span>
<span style="color: #00007f; font-weight: bold;">sub</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> nn  <span style="color: #666666; font-style: italic;">; adjust SP by nn</span>
b   ofs     <span style="color: #666666; font-style: italic;">; set PC to the addr PC+ofs</span>
<span style="color: #00007f; font-weight: bold;">add</span> <span style="color: #00007f;">sp</span><span style="color: #339933;">,</span> rn  <span style="color: #666666; font-style: italic;">;  adjust SP by the value rn points to</span></pre></td></tr></table></div>

<p>The unconditional branch instruction &#8220;b&#8221; is from hell, because it could lead to an infinite loop in <em>Stacktrace</em>, such as <em>while(1) {}</em>. For this reason I added two special cases:</p>
<ul>
<li>Limit how many instructions are allowed to touch</li>
<li>Branch only to the target address when it&#8217;s different from PC</li>
</ul>
<p>When any of the conditions evaluates to true, <em>Stacktrace</em> aborts and outputs the callstack only to this position. It will, however, report that an error occured.</p>
<p>Support for the unconditional branch was important, because the compiler generates code like this sometimes:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="asm" style="font-family:monospace;">ExampleFunc<span style="color: #339933;">:</span>
  <span style="color: #00007f; font-weight: bold;">push</span>   <span style="color: #009900; font-weight: bold;">&#123;</span>lr<span style="color: #009900; font-weight: bold;">&#125;</span>
  <span style="color: #339933;">...</span>
  tst    r0<span style="color: #339933;">,</span> #<span style="color: #0000ff;">2</span>
  bne    <span style="color: #339933;">.</span>L92 <span style="color: #666666; font-style: italic;">; if r0 is not 2 then jump to L92</span>
  <span style="color: #339933;">...</span>
<span style="color: #339933;">.</span>L90<span style="color: #339933;">:</span>
  <span style="color: #00007f; font-weight: bold;">pop</span>    <span style="color: #009900; font-weight: bold;">&#123;</span>pc<span style="color: #009900; font-weight: bold;">&#125;</span> <span style="color: #666666; font-style: italic;">; returns to caller</span>
&nbsp;
<span style="color: #339933;">.</span>L92<span style="color: #339933;">:</span>
  <span style="color: #00007f;">bl</span>     AnotherFunction
  b      <span style="color: #339933;">.</span>L90 <span style="color: #666666; font-style: italic;">; jump to L90 (above)</span></pre></td></tr></table></div>

<p>When we return from <em>AnotherFunction</em> we must jump to <em>L90</em> to pop the return address from the stack and return to the caller. This is the reason why I added support for unconditional branches. I haven&#8217;t noticed other branches that are of importance for <em>Stacktrace</em> yet.</p>
<p>At this point of time I was able to return to each function-caller and have the return addresses, e.g:</p>
<p><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/08/stacktrace1.png" alt="Stacktrace output with return addresses only" title="Stacktrace output with return addresses only" width="286" height="443" class="alignnone size-full wp-image-692" /></p>
<h3>resolving function names by hand</h3>
<p>In order to map the memory address to an actual function, we have to look up the address in the so called Map file. Map files are typically plain text files that indicate the relative offsets of functions for a given version of a compiled binary. This file is generated by the <a href="http://en.wikipedia.org/wiki/Linker">linker</a> when you pass <em>-Map</em> to it, here is a part of it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">.text   0x02000310    0xdf28
.text   0x02000380    0x1ac main.o
        0x02000394      PrintStacktrace
        0x0200046c      FirstFunc
        0x0200040c      ThirdFunc
        0x020004c8      main
        0x02000450      SecondFunc</pre></td></tr></table></div>

<p>Line 1 specifies where the .text section (program code) starts and its size. Line 2 specifies the start address of the <a href="http://en.wikipedia.org/wiki/OBJ_file">object file</a> <em>main.o</em> followed by all functions it contains. While writing this article, I have learned <em>static</em> functions are not listed in the map file.</p>
<p>In order to find the function name of the memory address <em>0&#215;02000458</em> (from screenshot above), we have to check in which range it is located. But it would be too simple when the .map file has everything sorted by addresses, so we have to do this instead.</p>
<p>Here is a sorted list by addresses:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">.text   0x02000380    0x1ac main.o
        0x02000394      PrintStacktrace
        0x0200040c      ThirdFunc
        0x02000450      SecondFunc
        0x0200046c      FirstFunc
        0x020004c8      main</pre></td></tr></table></div>

<p>The memory address <em>0&#215;02000458</em> is between:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">        0x02000450      SecondFunc
        0x0200046c      FirstFunc</pre></td></tr></table></div>

<p>So <em>0&#215;02000458</em> belongs to <em>SecondFunc</em>. While this approach seems to work, it is complicated and really only works when you have the exact .map file available that was used to build the project. You can&#8217;t use a .map file of a different version of your code, this is very unlikely to work.</p>
<p>It would be so much better when the actual function name could be displayed instead!</p>
<h3>what is your function name, dear memory address</h3>
<p>Fortunalety, the compiler has an option to insert function names in plain-text infront of each function. This can be activated by adding <em>-mpoke-function-name</em> to the <em>CFLAGS</em> variable in your makefile.</p>
<p>But it not only inserts the name, it also inserts a bit-pattern to recognize that there is a function name as well as a relative offset to the name from this pattern.</p>
<p>What <em>Stacktrace</em> function does, it takes a memory address and then decreases this address until it detects the bit-pattern of the function name and we have it!</p>
<p><img src="http://www.console-dev.de/wordpress/wp-content/uploads/2009/08/stacktrace2.png" alt="Stacktrace without functio names and return addresses" title="Stacktrace without functio names and return addresses" width="286" height="443" class="alignnone size-full wp-image-695" /></p>
<p>Well, there is of course a special case again. When <em>-mpoke-function-name</em> has not been specified, the function name bit-pattern is missing, thus <em>Stacktrace</em> would try to find it until it reaches the start of the text section. While this makes little sense, I added a limit how many 32bit words the &#8220;GetFunctionnameTag&#8221; function is allowed to touch before it returns &#8220;did not find&#8221;.</p>
<h3>how to integrate in your own project</h3>
<p>The stacktrace.zip archive contains the entire source code, you only need those two files:</p>
<ul>
<li>stacktrace.h</li>
<li>stacktrace.c</li>
</ul>
<p>Copy them to your source code directory. Then open the makefile file which should be located in your project directory also. You have to adjust the following variables:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">ARCH   <span style="color: #008080;">:</span><span style="color: #000080;">=</span> <span style="color: #000040;">-</span>mthumb <span style="color: #000040;">-</span>mthumb<span style="color: #000040;">-</span>interwork
CFLAGS <span style="color: #008080;">:</span><span style="color: #000080;">=</span> <span style="color: #000040;">-</span>O2 <span style="color: #000040;">-</span>mpoke<span style="color: #000040;">-</span>function<span style="color: #000040;">-</span>name</pre></td></tr></table></div>

<p>Now do a rebuild, rather than a regular build. You can do this by performing a “make clean” first, then a “make”. Don’t forget to include <em>stacktrace.h</em> in that file where you want to use <em>Stacktrace</em>.</p>
<p>Optimization level -O2 worked best with <em>Stacktrace</em> so far. When you use more aggressive optimization levels the compiler also starts to inline code heavily, which can be quite confusing when the <em>Stacktrace</em> output does not reflect what you see in your high level code.</p>
<h3>stacktrace interface and usage</h3>
<p>The usage of <em>Stacktrace</em> function is fairly simple.</p>
<p>All it expects is an array of <em>StacktraceEntry</em> elements and the count of it. Here is the interface from stacktrace.h:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">typedef</span> <span style="color: #0000ff;">struct</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> addr<span style="color: #008080;">;</span>  <span style="color: #666666;">//!&lt; Return address</span>
  <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>name<span style="color: #008080;">;</span>   <span style="color: #666666;">//!&lt; Name of function</span>
<span style="color: #008000;">&#125;</span> StacktraceEntry<span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> Stacktrace<span style="color: #008000;">&#40;</span>StacktraceEntry<span style="color: #000040;">*</span> dest, <span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> count<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>Use it like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> OutputStacktrace<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> n<span style="color: #008080;">;</span>
  <span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> count<span style="color: #008080;">;</span>
  StacktraceEntry entries<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">32</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// allocate memory for 32 stacktrace entries</span>
&nbsp;
  <span style="color: #666666;">// get only the 10 deepest stacktrace entries</span>
  count <span style="color: #000080;">=</span> Stacktrace<span style="color: #008000;">&#40;</span>entries, <span style="color: #0000dd;">10</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span>n<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> n<span style="color: #000080;">&lt;</span>count<span style="color: #008080;">;</span> <span style="color: #000040;">++</span>n<span style="color: #008000;">&#41;</span>
    <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;0x%08x: %s&quot;</span>, entries<span style="color: #008000;">&#91;</span>n<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">addr</span>, entries<span style="color: #008000;">&#91;</span>n<span style="color: #008000;">&#93;</span>.<span style="color: #007788;">name</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<h3>improving stacktrace</h3>
<p>If you want to improve <em>Stacktrace</em>, I recommend to read through the comments in <em>stacktrace.c</em> and enable <em>STACKTRACE_VERBOSE</em>, by setting it to 1.</p>
<p>This will, as far as <em>OutputDebugString</em> (also in stacktrace.c) uses a debug message type your Nintendo DS software emulator understands, output what instructions <em>Stacktrace</em> comes across and interprets.</p>
<p>I&#8217;ve added an opcode structure for all instructions <em>Stacktrace</em> interprets as well as print-routines to dump the contents.</p>
<p>I have used <a href="http://nocash.emubase.de/gba.htm">no$gba</a> during development, which was of great help because of its &#8220;<a href="http://nocash.emubase.de/gbapics.htm">debugger</a>&#8220;. Usually I yell about only see the assembler code in the shareware version of no$gba, but for this project it was exactly what I needed <img src='http://www.console-dev.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>conclusion</h3>
<p>The <em>Stacktrace</em> function&#8230;</p>
<ul>
<li>works suprisingly well for being such a hack</li>
<li>does not need debugging information/symbols</li>
<li>it runs directly on the target device, not needed to be connected to GDB or a similar debugger</li>
<li>does not come with any run-time performance penalty</li>
<li>works best with optimization level -O2</li>
<li>is most informative when adding -mpoke-function-name to CFLAGS in your makefile</li>
<li>comes with full documented source code</li>
<li>uses very little Nintendo DS specifics, except the text section start and length (portable to other ARM devices?)</li>
<li>works with thumb code only</li>
<li>does not detect when switching from thumb to arm mode</li>
<li>depends on LR / PC being push&#8217;ed and pop&#8217;ed, hand-written assembler routine can cause trouble</li>
<li>is tested in/with my code base only</li>
</ul>
<h3>frequently asked questions (faq)</h3>
<p><i>Q</i>: Why do I see so weird function names, like _<em>ZN13DEMOPARTQUEUE9CutToPartEj</em> and the like?</p>
<p><i>A</i>: Because in C++, the function names go through <a href="http://en.wikipedia.org/wiki/Name_mangling">name mangling</a>. Name mangling is a technique used to solve various problems caused by the need to resolve unique names for programming entities.</p>
<h3>download</h3>
<p><a href="http://www.console-dev.de/news/2009/stacktrace.zip">Dear visiter, 100% OFF on console-dev.de, take your chance and download stacktrace.zip now!</a> <img src='http://www.console-dev.de/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<h3>what I didn&#8217;t tell you yet</h3>
<p>*1) LR does not always contains the address from where it was being called, but it holds the address where to return when the function completes. When using code optimization levels above -O2 the compiler e.g. generates code that does not return to functions where it was the last instruction involved anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.console-dev.de/2009/08/16/callstack-trace-on-the-nintendo-ds/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

