{"id":1980,"date":"2018-12-14T16:31:52","date_gmt":"2018-12-14T16:31:52","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=1980"},"modified":"2025-12-05T14:42:11","modified_gmt":"2025-12-05T14:42:11","slug":"coredump-analysing-with-gdb","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=1980","title":{"rendered":"Coredump analysis (GDB)"},"content":{"rendered":"<h2>Setup<\/h2>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ cat \/proc\/sys\/kernel\/core_pattern ... get coredumps location\r\n$ ulimit -c                         ... check max coredump size\r\n$ gdb &lt;executable&gt; &lt;coredump&gt;       ... load coredump with GDB\r\n<\/pre>\n<details>\n<summary>Details \u25bc<\/summary>\n<p>  <strong>Activate cordumps for the current session<\/strong><\/p>\n<ol>\n<li>Set coredump size to unlimited\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ ulimit -c unlimited\r\n<\/pre>\n<\/li>\n<li>Set pattern to store coredump\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ sudo sysctl -w kernel.core_pattern=\/tmp\/core.%e.%p.%t\r\n<\/pre>\n<\/li>\n<\/ol>\n<\/details>\n<hr>\n<h2>Threads &#038; Stack<\/h2>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ninfo threads        ... show running threads\r\nthread apply all bt ... show the bt of all running threads\r\nthread &lt;idx&gt; bt     ... show the bt of specific thread\r\nthread &lt;idx&gt;        ... switch to other thread\r\n\r\nbt [&lt;lvl&#039;s&gt;]        ... show the bt of the current thread\r\nup                  ... move up in bt\r\ndown                ... move down in bt\r\nf &lt;idx&gt;             ... select frame &lt;idx&gt;\r\ninfo f              ... shows selected frame\r\n<\/pre>\n<details>\n<summary>Details \u25bc<\/summary>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nset debug frame &lt;0\/1&gt; ... De\/activate debug infos for frames\r\n                          (Shows for example:\r\n                          - types (INLINE_FRAME, NORMAL_FRAME, ...)\r\n                          - unwinder (inline, dwarf2, amd64 prologue, ...))\r\n<\/pre>\n<\/details>\n<hr>\n<h2>Functions &#038; Variables<\/h2>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\nlist [function]            ... show source code\r\ndisas [\/&lt;m&gt;] [function]    ... show disassembly\r\n\r\n&lt;m&gt; (mode)\r\n  - b ... prints bytes and instruction (in memory order)\r\n  - m ... prints assembly and sources (not useful with optimized code)\r\n  - r ... prints bytes and instruction (in instruction order)\r\n  - s ... prints assembly and sources\r\n\r\ninfo register              ... show registers\r\ninfo args                  ... show parameters\r\ninfo locals                ... show local variables\r\n\r\nptype [variable]           ... show type of variable\r\np[\/&lt;f&gt;] $&lt;register&gt;        ... print register\r\np[\/&lt;f&gt;] &lt;variable&gt;         ... print variable\r\np[\/&lt;f&gt;] &amp;&lt;variable&gt;        ... print address of variable\r\np[\/&lt;f&gt;] *&lt;variable&gt;        ... print dereferenced variable\r\np[\/&lt;f&gt;] *this              ... print member variables\r\np[\/&lt;f&gt;] sizeof(&lt;var|type&gt;) ... print size of variable\/type\r\n\r\n&lt;f&gt; (format)\r\n  - t ... binary\r\n  - x ... hexadecimal\r\n  - d ... signed decimal\r\n  - u ... unsigned decimal\r\n  - o ... octal\r\n  - a ... address\r\n  - c ... character\r\n  - f ... float point\r\n  - s ... string\r\n<\/pre>\n<details>\n<summary>Details \u25bc<\/summary>\n<p>  <strong>Convenience Variables<\/strong><\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\np $_siginfo ... show signal details\r\n<\/pre>\n<p>  <strong>Containers<\/strong><\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\np &lt;vec&gt;._M_impl._M_start+&lt;idx&gt; ... get item of vector\r\n<\/pre>\n<\/details>\n<hr>\n<h2>Memory<\/h2>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ninfo proc mappings ... show memory mapping\r\n\r\nx\/&lt;n&gt;&lt;f&gt;&lt;u&gt; &lt;addr&gt; ... print memory\r\n\r\n&lt;n&gt; (number)\r\n\r\n&lt;f&gt; (format)\r\n  - Basic types see &lt;f&gt; for print\r\n  - i ... instruction\r\n\r\n&lt;u&gt; (unit)\r\n  - b ... byte (8-bit integer)\r\n  - h ... half word (16-bit integer)\r\n  - w ... word (32-bit integer)\r\n  - g ... giant word (64-bit integer)\r\n<\/pre>\n<details>\n<summary>Details \u25bc<\/summary>\n<ul>\n<li>Print current instruction: x\/i $pc<\/li>\n<\/ul>\n<\/details>\n<hr>\n<h2>Additional<\/h2>\n<p>&#8211; <a href=\"http:\/\/www.max-sperling.bplaced.net\/?p=17945\">Basic assembler instructions (x64, A64)<\/a><br \/>\n&#8211; <a href=\"http:\/\/www.max-sperling.bplaced.net\/?p=14662\">Adding dependencies to coredump (GDB)<\/a><br \/>\n&#8211; <a href=\"http:\/\/www.max-sperling.bplaced.net\/?p=3988\">Unwind the stack even if GDB can\u2019t? (ARM)<\/a><br \/>\n&#8211; <a href=\"http:\/\/www.max-sperling.bplaced.net\/?p=18836\">Print stack frames from stack (GDB)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setup Details \u25bc Activate cordumps for the current session Set coredump size to unlimited Set pattern to store coredump Threads<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[28],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/1980"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1980"}],"version-history":[{"count":26,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/1980\/revisions"}],"predecessor-version":[{"id":19362,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/1980\/revisions\/19362"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1980"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1980"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}