<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ruslan&#39;s Tech Blog</title>
    <link>https://blog.bekenev.net/tags/gdb.html</link>
    <description>Software development related stuff</description>
    <language>en-us</language>
    <lastBuildDate>Sat, 24 Feb 2018 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.bekenev.net/tags/gdb/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>GDB oneliners</title>
      <link>https://blog.bekenev.net/2018/02/24/gdb-oneliners.html</link>
      <pubDate>Sat, 24 Feb 2018 00:00:00 +0000</pubDate>
      <guid>https://blog.bekenev.net/2018/02/24/gdb-oneliners.html</guid>
      <description>&lt;p&gt;Recently I wanted to print disassembled main funciton of the program to the file&#xA;so I can read it in my Emacs, but it turned out I can&amp;rsquo;t simply redirect the GDB output&#xA;to the file with &lt;code&gt;disassemble main &amp;gt; main.asm&lt;/code&gt; command in gdb command line.&lt;/p&gt;&#xA;&lt;p&gt;But there is &lt;code&gt;-ex&lt;/code&gt; option exists in gdb command so we can execute some gdb commands&#xA;right after gdb is initialized.&lt;/p&gt;&#xA;&lt;p&gt;Looks like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gdb &amp;lt;file&amp;gt; -ex &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;disassemble main&amp;#39;&lt;/span&gt; -ex &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;quit&amp;#39;&lt;/span&gt; &amp;gt; main.asm&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br/&gt;&#xA;As you can see we can chain multiple commands. It&#39;s important to have `quit` as the last one&#xA;to make sure we exit GDB.&#xA;</description>
    </item>
    <item>
      <title>GDB PEDA config</title>
      <link>https://blog.bekenev.net/2018/02/24/gdb-peda.html</link>
      <pubDate>Sat, 24 Feb 2018 00:00:00 +0000</pubDate>
      <guid>https://blog.bekenev.net/2018/02/24/gdb-peda.html</guid>
      <description>&lt;p&gt;Hey everyone.&lt;/p&gt;&#xA;&lt;p&gt;I already have a post about &lt;a href=&#34;https://blog.bekenev.net/2018/02/19/gdb-dashboard.html&#34;&gt;GDB Dashboard&lt;/a&gt; package which is cool but I&amp;rsquo;ve just found somethine even better.&lt;/p&gt;&#xA;&lt;p&gt;Meet &lt;a href=&#34;https://github.com/longld/peda&#34;&gt;PEDA&lt;/a&gt;. It looks really awesome. I wasn&amp;rsquo;t able to try all the commands&#xA;it provides but the interface looks pretty awesome.&lt;/p&gt;&#xA;&lt;p&gt;It shows stask in realtime which Dashboard package lack. Not just showing addresses but also strings&#xA;if any of them are on the address.&lt;/p&gt;&#xA;&lt;p&gt;Now my GDB looks like debuggers I have used to before like OllyDbg.&lt;/p&gt;&#xA;&lt;p&gt;If you use GDB a lot especially for software exploring you have to try the PEDA package.&lt;/p&gt;&#xA;&lt;p&gt;Here is screenshot from their repo.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a target=&#34;_blank&#34; href=&#34;https://blog.bekenev.net/assets/img/peda.png&#34;&gt;&lt;img width=&#34;600px&#34; src=&#34;https://blog.bekenev.net/assets/img/peda.png&#34;/&gt;&lt;/a&gt;&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>GDB print string from memory</title>
      <link>https://blog.bekenev.net/2018/02/24/show-string-in-memory.html</link>
      <pubDate>Sat, 24 Feb 2018 00:00:00 +0000</pubDate>
      <guid>https://blog.bekenev.net/2018/02/24/show-string-in-memory.html</guid>
      <description>&lt;p&gt;Hey,&#xA;just found a command for gdb that prints a string from memory address.&lt;/p&gt;&#xA;&lt;p&gt;Looks like this &lt;code&gt;x /s &amp;lt;addr&amp;gt;&lt;/code&gt;. Very useful if you need to print out the string that is in memory somewhere.&lt;/p&gt;&#xA;&lt;p&gt;Previously I&amp;rsquo;ve used other flags to print for example hex values but was pretty hard to read.&#xA;Glad there is special solution in GDB for this.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>GDB dashboard</title>
      <link>https://blog.bekenev.net/2018/02/19/gdb-dashboard.html</link>
      <pubDate>Mon, 19 Feb 2018 00:00:00 +0000</pubDate>
      <guid>https://blog.bekenev.net/2018/02/19/gdb-dashboard.html</guid>
      <description>&lt;p&gt;If you use GDB you definitely have to try &lt;a href=&#34;https://github.com/cyrus-and/gdb-dashboard&#34;&gt;Dashboard package&lt;/a&gt; by Andrea Cardaci.&lt;/p&gt;&#xA;&lt;p&gt;Here is how it looks like:&lt;/p&gt;&#xA;&lt;center&gt;&lt;a href=&#34;https://blog.bekenev.net/assets/img/gdb-dashboard.png&#34; target=&#34;_blank&#34;&gt;&lt;img width=&#34;600px&#34; src=&#34;https://blog.bekenev.net/assets/img/gdb-dashboard.png&#34;/&gt;&lt;/a&gt;&lt;/center&gt;&#xA;^ Click to make it bigger.&#xA;&lt;p&gt;Looks very nice, it updates itself each time when you &lt;code&gt;step&lt;/code&gt; or do another action.&#xA;It was confusing why Memory area is empty by default and shows nothing even when I try to &lt;code&gt;x &amp;lt;memory&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;It turned out I have to tell dashboard to watch for particular area of memory. Here is how to do it:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;dashboard memory watch &amp;lt;addr&amp;gt; &amp;lt;how many bytes&amp;gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;for example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;dashboard memory watch $ebp 42&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Now it looks awesome.&lt;/p&gt;&#xA;</description>
    </item>
  </channel>
</rss>
