<?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>The Stata Things &#187; GNU debugger</title>
	<atom:link href="http://enoriver.net/index.php/tag/gnu-debugger/feed/" rel="self" type="application/rss+xml" />
	<link>http://enoriver.net</link>
	<description>computing for fun and profit</description>
	<lastBuildDate>Fri, 13 Aug 2010 20:42:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Debugging C++ code (UNIX)</title>
		<link>http://enoriver.net/index.php/2008/10/03/debugging-c-code-unix/</link>
		<comments>http://enoriver.net/index.php/2008/10/03/debugging-c-code-unix/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 03:16:15 +0000</pubDate>
		<dc:creator>Gabi Huiber</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[GNU debugger]]></category>

		<guid isPermaLink="false">http://enoriver.net/?p=189</guid>
		<description><![CDATA[This assumes you're inside a UNIX terminal window (e.g., PuTTY session to remote UNIX box). Compile a .cpp source file in the GNU debugger: g++ -g -Wall -o mysourcefile.out mysourcefile.cpp Before starting gdb, make sure you're in the same directory as the executable just compiled above. Then call gdb: add GNU Then start the gdb [...]]]></description>
			<content:encoded><![CDATA[<p>This assumes you're inside a UNIX terminal window (e.g., PuTTY session to remote UNIX box).</p>
<p>Compile a .cpp source file in the GNU debugger:</p>
<p><code>g++ -g -Wall -o mysourcefile.out mysourcefile.cpp</code></p>
<p>Before starting gdb, make sure you're in the same directory as the executable just compiled above. Then call gdb:</p>
<p><code>add GNU</code></p>
<p>Then start the gdb debugger:</p>
<p><code>gdb mysourcefile.out</code></p>
<p>Things you can do here:</p>
<p>1) Set a breakpoint at a given function (e.g., main):</p>
<p><code>break main</code></p>
<p>2) Set a breakpoint at a given line (e.g., line 12):</p>
<p><code>break mysourcefile.cpp:12</code></p>
<p>3) Set a watch point at a given expression:</p>
<p><code>watch x&gt;y</code></p>
<p>4) Find the type of that expression:</p>
<p><code>whatis x&gt;y</code></p>
<p>5) OK, that was trivial, clearly it's boolean. More usefully, you can find its value so far (true or false in the GNU C++ compiler, 1 or 0 in others, I guess) with</p>
<p><code>print x&gt;y</code></p>
<p>6) Step into the program (execute a certain number of lines after the debugger stopped at your breakpoint):</p>
<p><code>step &lt;number of lines&gt;</code></p>
<p>If you set a break point, <code>run</code> will execute the code up to then, at which point you can choose <code>next</code> to move on to the next line, or <code>continue</code>, for the thing to run until it exits normally or an error is found.</p>
]]></content:encoded>
			<wfw:commentRss>http://enoriver.net/index.php/2008/10/03/debugging-c-code-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
