<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>GDB on _ov4 Press</title>
    <link>https://ov4.org/tags/gdb/</link>
    <description>Recent content in GDB on _ov4 Press</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Mon, 14 Sep 2026 18:32:41 +0800</lastBuildDate>
    <atom:link href="https://ov4.org/tags/gdb/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>GDB catch C&#43;&#43; `throw`</title>
      <link>https://ov4.org/posts/2026-09-14/gdb-cxx-catch/</link>
      <pubDate>Mon, 14 Sep 2026 18:32:41 +0800</pubDate>
      <guid>https://ov4.org/posts/2026-09-14/gdb-cxx-catch/</guid>
      <description>&lt;h2 id=&#34;intro&#34;&gt;intro&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;terminate called after throwing an instance of &amp;#39;std::logic_error&amp;#39;
  what():  basic_string: construction from null is not valid
[1]    441709 IOT instruction  build/ccshell
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;It&amp;rsquo;s so annoying that you don&amp;rsquo;t have any information regarding what&amp;rsquo;s wrong&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s usually a bad idea to binary search by adding print statements because it&amp;rsquo;s slow (log time), but gdb is instant&lt;/p&gt;
&lt;h2 id=&#34;compile-options&#34;&gt;compile options&lt;/h2&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-O0 &lt;span class=&#34;nv&#34;&gt;OPTFLAGS&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; -ggdb3 -fno-omit-frame-pointer -fno-inline -D_GLIBCXX_ASSERTIONS
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;gdb&#34;&gt;gdb&lt;/h2&gt;
&lt;p&gt;First run the program&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ gdb --args build/ccshell
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;gdb&amp;gt; catch throw
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;gdb&amp;gt; run
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When the program stops, check the status&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
