<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Gdb on zhi</title><link>https://zhichen3.github.io/tags/gdb/</link><description>Recent content in Gdb on zhi</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 14 Apr 2026 00:00:00 -0400</lastBuildDate><atom:link href="https://zhichen3.github.io/tags/gdb/index.xml" rel="self" type="application/rss+xml"/><item><title>GDB Tutorial</title><link>https://zhichen3.github.io/posts/gdb-tutorial/</link><pubDate>Tue, 14 Apr 2026 00:00:00 -0400</pubDate><guid>https://zhichen3.github.io/posts/gdb-tutorial/</guid><description>&lt;p>&lt;a href="https://www.sourceware.org/gdb/" target="_blank" rel="noopener">GDB&lt;/a> , the GNU Project debugger, is a useful debugger for many
languages (C, C++, Fortran, etc). Here I keep a set of useful
commands for my records.&lt;/p>
&lt;h2 id="using-gdb">Using GDB&lt;/h2> &lt;p>To use GDB, compile the program with debugging information.
For standard C++ program, add &lt;code>-g&lt;/code> flag when compiling, i.e.
something like&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>g++ -g -o myprogram myprogram.cpp
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>For &lt;code>AMReX&lt;/code> related application codes like &lt;code>Castro&lt;/code>, compile with
&lt;code>DEBUG=TRUE&lt;/code>, i.e.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>make DEBUG&lt;span style="color:#f92672">=&lt;/span>TRUE
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now launch GDB with compiled program as the following.&lt;/p></description></item></channel></rss>