{"id":269366,"date":"2023-04-11T20:11:59","date_gmt":"2023-04-11T12:11:59","guid":{"rendered":"https:\/\/lrxjmw.cn\/lyycxbkhqdwj.html"},"modified":"2023-04-11T20:11:59","modified_gmt":"2023-04-11T12:11:59","slug":"lyycxbkhqdwj","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lyycxbkhqdwj.html","title":{"rendered":"Linux\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\uff1f\u83b7\u53d6dump\u6587\u4ef6\u65b9\u6cd5\u5927\u63ed\u79d8\uff01"},"content":{"rendered":"

\u5728 Linux<\/a> \u7cfb\u7edf<\/a>\u4e2d\uff0cdump \u6587\u4ef6\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u627e\u51fa\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\u7684\u539f\u56e0\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728 Linux \u7cfb\u7edf\u4e2d\u83b7\u53d6 dump \u6587\u4ef6\u3002<\/p>\n

\u4e00\u3001\u8bbe\u7f6e\u7cfb\u7edf\u4ee5\u751f\u6210 dump \u6587\u4ef6<\/p>\n

\u8981\u751f\u6210 dump \u6587\u4ef6\uff0c\u5fc5\u987b\u5148\u8bbe\u7f6e\u7cfb\u7edf\u4ee5\u5141\u8bb8\u751f\u6210\u5b83\u4eec\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\/proc\/sys\/kernel\/core_pattern \u6587\u4ef6\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4<\/a>\uff1a<\/p>\n

\n

\necho "\/tmp\/core.%e.%p.%t">\/proc\/sys\/kernel\/core_pattern\n<\/pre>\n<\/p>\n

\u4e8c\u3001\u68c0\u67e5\u7cfb\u7edf\u662f\u5426\u8bbe\u7f6e\u4e3a\u751f\u6210 dump \u6587\u4ef6<\/p>\n

\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 sysctl \u547d\u4ee4\u6765\u68c0\u67e5\u7cfb\u7edf\u662f\u5426\u8bbe\u7f6e\u4e3a\u751f\u6210 dump \u6587\u4ef6\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\nsysctl kernel.core_pattern\n<\/pre>\n<\/p>\n

\u5982\u679c\u8f93\u51fa\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u5185\u5bb9\uff0c\u5219\u8868\u793a\u7cfb\u7edf\u5df2\u7ecf\u8bbe\u7f6e\u4e3a\u751f\u6210 dump \u6587\u4ef6\uff1a<\/p>\n

\n

\nkernel.core_pattern =\/tmp\/core.%e.%p.%t\n<\/pre>\n<\/p>\n

\u4e09\u3001\u4f7f\u7528 ulimit \u547d\u4ee4\u8bbe\u7f6e core \u6587\u4ef6\u5927\u5c0f<\/p>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cLinux \u7cfb\u7edf\u9650\u5236 core \u6587\u4ef6\u7684\u5927\u5c0f\u4e3a0\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u4e0d\u4f1a\u88ab\u521b\u5efa\u3002\u6211\u4eec\u9700\u8981\u4f7f\u7528 ulimit \u547d\u4ee4\u6765\u8bbe\u7f6e core \u6587\u4ef6\u7684\u6700\u5927\u5927\u5c0f\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

linux\u83b7\u53d6dump\u6587\u4ef6_linux\u751f\u6210dump\u6587\u4ef6_windbg\u5206\u6790dump\u6587\u4ef6<\/p>\n

\n

\nulimit -c unlimited\n<\/pre>\n<\/p>\n

\u56db\u3001\u91cd\u542f\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u8981\u4f7f\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\u5e76\u751f\u6210 dump \u6587\u4ef6\uff0c\u6211\u4eec\u9700\u8981\u91cd\u542f\u8be5\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\nsudo service <application_name> restart\n<\/pre>\n<\/p>\n

\u4e94\u3001\u67e5\u627e dump \u6587\u4ef6<\/p>\n

\u751f\u6210\u7684 dump \u6587\u4ef6\u5c06\u4fdd\u5b58\u5728\/tmp \u76ee\u5f55\u4e2d\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u627e\u5b83\u4eec\uff1a<\/p>\n

\n

\nls \/tmp\/core*\n<\/pre>\n<\/p>\n

\u516d\u3001\u4f7f\u7528 gdb \u8c03\u8bd5 dump \u6587\u4ef6<\/p>\n

\u4e00\u65e6\u6211\u4eec\u627e\u5230\u4e86 dump \u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528 gdb \u8c03\u8bd5\u5de5\u5177\u6765\u5206\u6790\u5b83\u4eec\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\ngdb <application_name><core_file>\n<\/pre>\n<\/p>\n

\u8fd9\u4f1a\u542f\u52a8 gdb \u5e76\u52a0\u8f7d dump \u6587\u4ef6\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd gdb \u547d\u4ee4\u6765\u5206\u6790 dump \u6587\u4ef6\u5e76\u627e\u51fa\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\u7684\u539f\u56e0\u3002<\/p>\n

\u4e03\u3001\u751f\u6210\u53ef\u8bfb\u53d6\u7684\u5806\u6808\u8ddf\u8e2a\u4fe1\u606f<\/p>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cdump \u6587\u4ef6\u4e2d\u5305\u542b\u7684\u5806\u6808\u8ddf\u8e2a\u4fe1\u606f\u53ef\u80fd\u5f88\u96be\u9605\u8bfb\u548c\u7406\u89e3\u3002\u4e3a\u4e86\u4f7f\u5b83\u4eec\u66f4\u52a0\u6613\u4e8e\u9605\u8bfblinux\u5165\u95e8\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u751f\u6210\u53ef\u8bfb\u53d6\u7684\u5806\u6808\u8ddf\u8e2a\u4fe1\u606f\uff1a<\/p>\n

\n

\ngdb <application_name><core_file>-ex "thread apply all bt"\n<\/pre>\n<\/p>\n

\u8fd9\u5c06\u751f\u6210\u6240\u6709\u7ebf\u7a0b\u7684\u5806\u6808\u8ddf\u8e2a\u4fe1\u606flinux\u83b7\u53d6dump\u6587\u4ef6<\/strong>\uff0c\u5e76\u5c06\u5176\u8f93\u51fa\u5230\u7ec8\u7aef\u3002<\/p>\n

\u516b\u3001\u5904\u7406\u7b26\u53f7\u8868<\/p>\n

\u8981\u4f7f gdb \u80fd\u591f\u6b63\u786e\u89e3\u91ca dump \u6587\u4ef6\u4e2d\u7684\u5806\u6808\u8ddf\u8e2a\u4fe1\u606f\uff0c\u6211\u4eec\u9700\u8981\u5904\u7406\u7b26\u53f7\u8868\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\ngdb <application_name><core_file>-ex "set solib-absolute-prefix \/path\/to\/application"-ex "thread apply all bt"\n<\/pre>\n<\/p>\n

\u8fd9\u4f1a\u5c06\u7b26\u53f7\u8868\u8def\u5f84\u8bbe\u7f6e\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u8def\u5f84\uff0c\u5e76\u751f\u6210\u53ef\u8bfb\u53d6\u7684\u5806\u6808\u8ddf\u8e2a\u4fe1\u606f\u3002<\/p>\n

\u4e5d\u3001\u7ed3\u8bba<\/p>\n

\u901a\u8fc7\u672c\u6587\uff0c\u4f60\u5df2\u7ecf\u5b66\u4f1a\u4e86\u5982\u4f55\u5728 Linux \u7cfb\u7edf\u4e2d\u83b7\u53d6 dump \u6587\u4ef6\u7ea2\u65d7linux\u5b89\u88c5\uff0c\u5e76\u4f7f\u7528 gdb \u8c03\u8bd5\u5de5\u5177\u5206\u6790\u5b83\u4eec\u3002\u8fd9\u4e9b\u6280\u80fd\u5bf9\u4e8e\u5f00\u53d1\u4eba\u5458\u6765\u8bf4\u975e\u5e38\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u627e\u51fa\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\u7684\u539f\u56e0linux\u83b7\u53d6dump\u6587\u4ef6<\/strong>\uff0c\u5e76\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6587\u4ef6\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u627e\u51fa\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\u7684\u539f\u56e0\u3002\u6587\u4ef6\uff0c\u6211\u4eec\u9700\u8981\u91cd\u542f\u8be5\u5e94\u7528\u7a0b\u5e8f\u3002\u6587\u4ef6\u5e76\u627e\u51fa\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\u7684\u539f\u56e0\u3002\u6587\u4ef6\u4e2d\u5305\u542b\u7684\u5806\u6808\u8ddf\u8e2a\u4fe1\u606f\u53ef\u80fd\u5f88\u96be\u9605\u8bfb\u548c\u7406\u89e3\u3002\u6587\u4ef6\u4e2d\u7684\u5806\u6808\u8ddf\u8e2a\u4fe1\u606f\uff0c\u6211\u4eec\u9700\u8981\u5904\u7406\u7b26\u53f7\u8868\u3002\u8fd9\u4f1a\u5c06\u7b26\u53f7\u8868\u8def\u5f84\u8bbe\u7f6e\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u8def\u5f84\uff0c\u5e76\u751f\u6210\u53ef\u8bfb\u53d6\u7684\u5806\u6808\u8ddf\u8e2a\u4fe1\u606f\u3002\u8fd9\u4e9b\u6280\u80fd\u5bf9\u4e8e\u5f00\u53d1\u4eba\u5458\u6765\u8bf4\u975e\u5e38\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u627e\u51fa\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\u7684\u539f\u56e0\uff0c\u5e76\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u3002<\/p>\n","protected":false},"author":1,"featured_media":269367,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-269366","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/269366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=269366"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/269366\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/269367"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=269366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=269366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=269366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}