{"id":3988,"date":"2019-12-13T09:41:05","date_gmt":"2019-12-13T09:41:05","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=3988"},"modified":"2025-06-30T10:56:04","modified_gmt":"2025-06-30T10:56:04","slug":"stacktrace-for-a-segfault-without-debug-info","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=3988","title":{"rendered":"Unwind the stack even if GDB can&#8217;t? (ARM)"},"content":{"rendered":"<h2>Reason<\/h2>\n<p>Since GCC 5.0 for ARM the default used ABI is AAPCS<sup>1<\/sup>. With AAPCS the stack unwinding works based on unwind tables. The GDB won&#8217;t provide a backtrace if these tables are missing in the binaries.<sup>2<\/sup><\/p>\n<p>Alternative: The stack is really corrupted. Then the following solution may not help.<\/p>\n<hr>\n<h2>Solution<\/h2>\n<p>The following user-defined command tries to unwind the stack based on the hope that GCC created the stack frames in the <a href=\"http:\/\/www.max-sperling.bplaced.net\/?p=2019\">common structure<\/a> even if not forced by AAPCS itself.<sup>3<\/sup><\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n(gdb) define stackwalker\r\n  set $a = $arg0\r\n  while $a &lt; *(long*) $a\r\n    x\/2a $a\r\n    set $a = *(long*) $a\r\n  end\r\nend\r\n(gdb) stackwalker $fp\r\n<\/pre>\n<hr>\n<h2>Drawback<\/h2>\n<p>This simple solution doesn&#8217;t provide the possibility to switch between frames (&#8216;(gdb) frame &lt;idx&gt;&#8217;).<\/p>\n<hr>\n<p><sup>1<\/sup> Procedure Call Standard for the Arm 64-bit Architecture<br \/>\n<sup>2<\/sup> GCC build flag: &#8216;-fno-asynchronous-unwind-tables&#8217;<br \/>\n<sup>3<\/sup> &#8220;It may elect not to maintain a frame chain and to use the frame pointer register as a general-purpose callee-saved register.&#8221; (<a href=\"https:\/\/github.com\/ARM-software\/abi-aa\/blob\/2022Q3\/aapcs64\/aapcs64.rst#646the-frame-pointer\">Link<\/a>, Spec on GitHub, Tag: 2022Q3)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Reason Since GCC 5.0 for ARM the default used ABI is AAPCS1. With AAPCS the stack unwinding works based on<\/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\/3988"}],"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=3988"}],"version-history":[{"count":3,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/3988\/revisions"}],"predecessor-version":[{"id":18898,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/3988\/revisions\/18898"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3988"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}