{"id":543,"date":"2013-05-13T16:50:49","date_gmt":"2013-05-13T08:50:49","guid":{"rendered":"http:\/\/guoh.ai\/lifelog\/?p=543"},"modified":"2014-05-13T19:16:20","modified_gmt":"2014-05-13T11:16:20","slug":"debug-with-core-dump-on-linux","status":"publish","type":"post","link":"https:\/\/guoh.ai\/lifelog\/2013\/05\/debug-with-core-dump-on-linux\/","title":{"rendered":"\u5728Linux\u4e0a\u5f00\u542fCore dump\u6765\u8c03\u8bd5"},"content":{"rendered":"<p>\u8fd9\u662f\u4e00\u7bc7\u539f\u6765\u4f7f\u7528Core dump\u7684\u8bb0\u5f55\uff0c\u6574\u7406\u8d44\u6599\u7684\u65f6\u5019\u770b\u5230\u7684\uff0c\u6ca1\u6709\u6df1\u5165\u7684\u5206\u6790\uff0c\u53ea\u662f\u7528\u6cd5<\/p>\n<p>\u57fa\u672c\u77e5\u8bc6\u4e0d\u6e05\u695a\u7684\u8bdd\uff0c\u8bf7\u5728\u7f51\u7edc\u4e0a\u641c\u5bfb\u67e5\u9605<br \/>\nhttp:\/\/en.wikipedia.org\/wiki\/Core_dump<br \/>\nhttp:\/\/en.wikipedia.org\/wiki\/GNU_Debugger<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">guohai@KNIGHT:~$ ulimit -c\r\n0\r\nguohai@KNIGHT:~$ ulimit -c unlimited\r\nguohai@KNIGHT:~$ ulimit -c\r\nunlimited\r\nguohai@KNIGHT:~$ .\/a.out \r\nFloating point exception (core dumped)<\/pre>\n<p>a.out\u662f\u9700\u8981\u5206\u6790\u7684\u7a0b\u5e8f\uff0c\u4ee5\u4e0a\u547d\u4ee4\u5c31\u662fLinux\u4e0a\u4f7f\u7528\u65b9\u6cd5\uff0c\u5f88\u7b80\u5355<\/p>\n<p>\u66f4\u591a\u60c5\u51b5\u8bf7\u53c2\u8003<br \/>\nhttp:\/\/www.cppblog.com\/kongque\/archive\/2011\/03\/07\/141262.aspx<\/p>\n<p>\u90a3\u4e48\u5728Android\u4e0a\u600e\u4e48\u5f00\u542f\u5462(\u9996\u5148\u5f97\u6709root\u6743\u9650)\uff1f<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ adb remount\r\n$ adb shell\r\nroot@android:\/ # ulimit -c                                                     \r\nunlimited<\/pre>\n<p>\u66f4\u6539Core dump\u6863\u6848\u5b58\u50a8\u7684\u8def\u5f84(\u8fd9\u4e2a\u5b58\u50a8\u7684\u8def\u5f84\u53ef\u4ee5\u6839\u636e\u9700\u8981\u5b9a\u5236)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">root@android:\/ # echo &quot;\/data\/coredump\/%p_%e&quot; &gt; \/proc\/sys\/kernel\/core_pattern<\/pre>\n<p>\u8fd9\u6837\u5f53\u6709native crash\u5b58\u5728\u7684\u65f6\u5019\u5c31\u4f1a\u51fa\u73b0\u5bf9\u5e94\u7684Core dump\u6863\u6848\u4e86<br \/>\n(\u6709\u65f6\u5019\u6267\u884c\u6ca1\u6709\u751f\u6210Core dump\uff0c\u56e0\u4e3a\u6ca1\u6709\/data\/coredump\u6587\u4ef6\u5939\u4e5f\u53ef\u80fd\u5bfc\u81f4\u65e0\u6cd5\u751f\u6210Core dump\uff0c\u5927\u6982\u662f\u6ca1\u6709\u6743\u9650\u521b\u5efa)<\/p>\n<p>\u7136\u540e\u5c31\u628a\u6863\u6848\u62f7\u8d1d\u5230\u5bbf\u4e3b\u673a\u4e0a\uff0c\u7528GDB\u53bb\u8f7d\u5165\u6863\u6848\uff0c\u5206\u6790\u51fa\u9519\u7684\u539f\u56e0<\/p>\n<p>&#8212;&#8212;&#8212;&#8211;EOF&#8212;&#8212;&#8212;&#8211;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u4e00\u7bc7\u539f\u6765\u4f7f\u7528Core dump\u7684\u8bb0\u5f55\uff0c\u6574\u7406\u8d44\u6599\u7684\u65f6\u5019\u770b\u5230\u7684\uff0c\u6ca1\u6709\u6df1\u5165\u7684\u5206\u6790\uff0c\u53ea\u662f\u7528\u6cd5 \u57fa\u672c\u77e5\u8bc6\u4e0d\u6e05\u695a\u7684\u8bdd\uff0c\u8bf7\u5728\u7f51\u7edc\u4e0a\u641c\u5bfb\u67e5\u9605 http:\/\/en.wikipedia.org\/wiki\/Core_dump http:\/\/en.wikipedia.org\/wiki\/GNU_Debugger guohai@KNIGHT:~$ ulimit -c 0 guohai@KNIGHT:~$ ulimit -c unlimited guohai@KNIGHT:~$ ulimit -c unlimited guohai@KNIGHT:~$ .\/a.out Floating point exception (core dumped) a.out\u662f\u9700\u8981\u5206\u6790\u7684\u7a0b\u5e8f\uff0c\u4ee5\u4e0a\u547d\u4ee4\u5c31\u662fLinux\u4e0a\u4f7f\u7528\u65b9\u6cd5\uff0c\u5f88\u7b80\u5355 \u66f4\u591a\u60c5\u51b5\u8bf7\u53c2\u8003 http:\/\/www.cppblog.com\/kongque\/archive\/2011\/03\/07\/141262.aspx \u90a3\u4e48\u5728Android\u4e0a\u600e\u4e48\u5f00\u542f\u5462(\u9996\u5148\u5f97\u6709root\u6743\u9650)\uff1f $ adb remount $ adb shell root@android:\/ # ulimit -c unlimited \u66f4\u6539Core dump\u6863\u6848\u5b58\u50a8\u7684\u8def\u5f84(\u8fd9\u4e2a\u5b58\u50a8\u7684\u8def\u5f84\u53ef\u4ee5\u6839\u636e\u9700\u8981\u5b9a\u5236) root@android:\/ # echo &quot;\/data\/coredump\/%p_%e&quot; &gt; \/proc\/sys\/kernel\/core_pattern \u8fd9\u6837\u5f53\u6709native crash\u5b58\u5728\u7684\u65f6\u5019\u5c31\u4f1a\u51fa\u73b0\u5bf9\u5e94\u7684Core dump\u6863\u6848\u4e86 (\u6709\u65f6\u5019\u6267\u884c\u6ca1\u6709\u751f\u6210Core dump\uff0c\u56e0\u4e3a\u6ca1\u6709\/data\/coredump\u6587\u4ef6\u5939\u4e5f\u53ef\u80fd\u5bfc\u81f4\u65e0\u6cd5\u751f\u6210Core dump\uff0c\u5927\u6982\u662f\u6ca1\u6709\u6743\u9650\u521b\u5efa) \u7136\u540e\u5c31\u628a\u6863\u6848\u62f7\u8d1d\u5230\u5bbf\u4e3b\u673a\u4e0a\uff0c\u7528GDB\u53bb\u8f7d\u5165\u6863\u6848\uff0c\u5206\u6790\u51fa\u9519\u7684\u539f\u56e0 &#8212;&#8212;&#8212;&#8211;EOF&#8212;&#8212;&#8212;&#8211;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gfmr_meta_descriptions":[],"_gfmr_multilingual_taxonomy_terms":[],"footnotes":""},"categories":[7,28,6],"tags":[],"class_list":["post-543","post","type-post","status-publish","format-standard","hentry","category-android","category-cpp","category-linux"],"_links":{"self":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":4,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/543\/revisions"}],"predecessor-version":[{"id":545,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/543\/revisions\/545"}],"wp:attachment":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/media?parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/categories?post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/tags?post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}