{"id":2089,"date":"2020-09-14T18:58:32","date_gmt":"2020-09-14T10:58:32","guid":{"rendered":"https:\/\/xbtzone.com\/blog\/?p=2089"},"modified":"2020-09-14T18:58:34","modified_gmt":"2020-09-14T10:58:34","slug":"macos-install-gdb","status":"publish","type":"post","link":"https:\/\/xbtzone.com\/blog\/macos-install-gdb\/","title":{"rendered":"macOS \u5b89\u88c5 GDB"},"content":{"rendered":"\n<p>\u5728 Linux \u7cfb\u7edf\u4e0b\uff0c\u5b89\u88c5 GDB \u8c03\u8bd5\u5de5\u5177\u53ef\u80fd\u4ec5\u4ec5\u53ea\u662f\u4e00\u884c Shell \u547d\u4ee4\u7684\u4e8b\u60c5\u3002<\/p>\n\n\n\n<p>\u5c3d\u7ba1 macOS \u548c Linux \u4e00\u6837\u90fd\u91c7\u7528\u4e86 POSIX \u6807\u51c6\uff0c\u4f46\u662f macOS \u81ea\u8eab\u5e76\u4e0d\u5e26\u6709\u8f6f\u4ef6\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u9700\u8981\u501f\u52a9\u7b2c\u4e09\u65b9\u7684\u5de5\u5177\u3002<\/p>\n\n\n\n<p>macOS \u6709\u4e00\u4e2a\u5f88\u6d41\u884c\u7684\u7b2c\u4e09\u65b9\u8f6f\u4ef6\u5305\u7ba1\u7406\u5de5\u5177 Brew\uff0c\u672c\u6587\u5173\u4e8e Brew \u7684\u5b89\u88c5\u5e76\u4e0d\u52a0\u4ee5\u53d9\u8ff0\u3002<\/p>\n\n\n\n<p>\u5728\u6709\u4e86\u8f6f\u4ef6\u5305\u7ba1\u7406\u5de5\u5177\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u7ec8\u7aef\u6267\u884c\u5982\u4e0b\u8fd9\u6761 Shell \u547d\u4ee4\u5373\u53ef\u5b89\u88c5 GDB \u8c03\u8bd5\u5de5\u5177\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">brew install gdb<\/pre>\n\n\n\n<p>\u6267\u884c\u7ed3\u679c\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1170\" height=\"1038\" src=\"https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_1.png\" alt=\"\" class=\"wp-image-2090\" srcset=\"https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_1.png 1170w, https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_1-768x681.png 768w\" sizes=\"(max-width: 1170px) 100vw, 1170px\" \/><figcaption>\u547d\u4ee4\u6267\u884c\u7ed3\u679c<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u6839\u636e Brew \u5728\u7ec8\u7aef\u4e2d\u7684\u63d0\u793a\uff0c\u6211\u4eec\u5df2\u7ecf\u6210\u529f\u5730\u5728 macOS \u4e0a\u5b89\u88c5\u4e86 GDB \u8c03\u8bd5\u5de5\u5177\u3002<\/p>\n\n\n\n<p><strong>\u4f46\u662f\u8bf7\u6ce8\u610f\u6700\u540e Caveats \u5230 Summary \u4e2d\u95f4\u7684\u63d0\u793a\u3002<\/strong><\/p>\n\n\n\n<p>\u5c3d\u7ba1\u6211\u4eec\u53ef\u4ee5\u5728 macOS \u548c Linux \u4e0b\u8f7b\u677e\u5730\u4f7f\u7528 GDB \u8c03\u8bd5\u5de5\u5177\uff0c\u4f46\u662f macOS \u4e0e Linux \u4e0d\u540c\u7684\u662f\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u989d\u5916\u5730\u4e3a GDB \u8c03\u8bd5\u5de5\u5177\u8d4b\u4e88\u7279\u6b8a\u6743\u9650\u3002<\/p>\n\n\n\n<p>macOS \u91c7\u7528\u7684\u662f\u7c7b Unix \u7684\u5185\u6838 Darwin\uff0c\u5b83\u8981\u6c42\u5176\u7cfb\u7edf\u4e0a\u7684\u8c03\u8bd5\u5de5\u5177\u5728\u4f7f\u7528\u65f6\u90fd\u8981\u6709\u7279\u6b8a\u7684\u7cfb\u7edf\u7ba1\u7406\u5458\u8bb8\u53ef\u8bc1\u4e66\uff0c\u56e0\u4e3a\u8c03\u8bd5\u5de5\u5177\u5176\u81ea\u8eab\u6d89\u53ca\u5230\u5bf9\u5176\u4ed6\u8fdb\u7a0b\u7684\u64cd\u7eb5\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u6765\u5bf9\u6211\u4eec\u5b89\u88c5\u7684 GDB \u8c03\u8bd5\u5de5\u5177\u5efa\u7acb\u7b7e\u540d\u3002<\/p>\n\n\n\n<p>\u542f\u52a8 macOS \u7cfb\u7edf\u81ea\u5e26\u7684\u300c\u94a5\u5319\u4e32\u8bbf\u95ee\u300d\u5de5\u5177\u3002<\/p>\n\n\n\n<p>\u70b9\u51fb\u5de6\u4e0a\u89d2\u83dc\u5355\u7684\u300c\u94a5\u5319\u4e32\u8bbf\u95ee\u300d\uff0c\u9009\u62e9\u300c\u8bc1\u4e66\u52a9\u7406\u300d\uff0c\u518d\u9009\u62e9\u300c\u521b\u5efa\u8bc1\u4e66\u300d\u3002<\/p>\n\n\n\n<p>\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u8f93\u5165\u540d\u79f0\u4e3a\uff1a\u300cgdb_codesign\u300d\u3002<\/p>\n\n\n\n<p>\u8bc1\u4e66\u7c7b\u578b\u9009\u62e9\u300c\u4ee3\u7801\u7b7e\u540d\u300d\uff0c\u5e76\u52fe\u9009\u300c\u8ba9\u6211\u8986\u76d6\u8fd9\u4e9b\u9ed8\u8ba4\u503c\u300d\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1232\" height=\"872\" src=\"https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_2.png\" alt=\"\" class=\"wp-image-2091\" srcset=\"https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_2.png 1232w, https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_2-768x544.png 768w\" sizes=\"(max-width: 1232px) 100vw, 1232px\" \/><figcaption>\uff08\u6ce8\uff1a\u8fd9\u4e2a\u540d\u79f0\u53ef\u4ee5\u81ea\u5df1\u5b9a\u4e49\uff09<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u4e00\u8def\u70b9\u51fb\u300c\u7ee7\u7eed\u300d\u6309\u94ae\uff0c\u76f4\u5230\u5411\u5bfc\u6765\u5230\u300c\u6307\u5b9a\u7528\u4e8e\u8be5\u8bc1\u4e66\u7684\u4f4d\u7f6e\u300d\u3002<\/p>\n\n\n\n<p>\u5728\u7a97\u53e3\u4e2d\u7684\u300c\u94a5\u5319\u4e32\u300d\u4e0b\u62c9\u9009\u9879\u4e2d\u9009\u62e9\u300c\u7cfb\u7edf\u300d\uff0c\u6700\u540e\u70b9\u51fb\u300c\u521b\u5efa\u300d\u6309\u94ae\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1252\" height=\"872\" src=\"https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_3.png\" alt=\"\" class=\"wp-image-2092\" srcset=\"https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_3.png 1252w, https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_3-768x535.png 768w\" sizes=\"(max-width: 1252px) 100vw, 1252px\" \/><\/figure>\n\n\n\n<p>\u90a3\u4e48\u7528\u6765\u7ed9 GDB \u8c03\u8bd5\u5de5\u5177\u63d0\u6743\u7684\u7b7e\u540d\u5c31\u521b\u5efa\u6210\u529f\u4e86\u3002<\/p>\n\n\n\n<p>\u56de\u5230\u300c\u94a5\u5319\u4e32\u8bbf\u95ee\u300d\u7a0b\u5e8f\uff0c\u5728\u5de6\u4fa7\u9009\u9879\u680f\u76ee\u7684\u300c\u79cd\u7c7b\u300d\u4e2d\u9009\u62e9\u300c\u6211\u7684\u8bc1\u4e66\u300d\uff0c\u53ef\u4ee5\u627e\u5230\u6211\u4eec\u521a\u521a\u521b\u5efa\u7684\u8bc1\u4e66\u300cgdb_codesign\u300d\u3002<\/p>\n\n\n\n<p>\u9009\u4e2d\u5b83\uff0c\u5355\u51fb\u53f3\u952e\uff0c\u5728\u5f39\u51fa\u7684\u83dc\u5355\u680f\u4e2d\u9009\u62e9\u300c\u663e\u793a\u7b80\u4ecb\u300d\u3002<\/p>\n\n\n\n<p>\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u627e\u5230\u300c\u4fe1\u4efb\u300d\u680f\u76ee\uff0c\u5c55\u5f00\u3002<\/p>\n\n\n\n<p>\u5728\u300c\u4f7f\u7528\u6b64\u8bc1\u4e66\u65f6\uff1a\u300d\u4e0b\u62c9\u9009\u9879\u4e2d\u9009\u62e9\u300c\u59cb\u7ec8\u4fe1\u4efb\u300d\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"956\" height=\"838\" src=\"https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_4-1.png\" alt=\"\" class=\"wp-image-2094\" srcset=\"https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_4-1.png 956w, https:\/\/xbtzone.com\/blog\/wp-content\/uploads\/2020\/09\/mac_install_gdb_4-1-768x673.png 768w\" sizes=\"(max-width: 956px) 100vw, 956px\" \/><\/figure><\/div>\n\n\n\n<p>\u6b64\u65f6\u4f1a\u5f39\u51fa\u7a97\u53e3\u63d0\u793a\u6211\u4eec\u8f93\u5165\u7528\u6237\u5bc6\u7801\u6216\u4f7f\u7528\u89e6\u63a7 ID \u8fdb\u884c\u9a8c\u8bc1\u3002<\/p>\n\n\n\n<p>\u81f3\u6b64\u6211\u4eec\u7684\u8bc1\u4e66\u5c31\u6210\u529f\u521b\u5efa\u5e76\u914d\u7f6e\u5b8c\u6210\u4e86\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u8981\u5c06\u8fd9\u4e2a\u8bc1\u4e66\u9881\u53d1\u7ed9 GDB \u8c03\u8bd5\u5de5\u5177\u3002<\/p>\n\n\n\n<p>\u5728\u9881\u53d1\u4e4b\u524d\u6211\u4eec\u8fd8\u9700\u8981\u5efa\u7acb\u4e00\u4e2a .xml \u6587\u4ef6\uff0c\u7528\u4e8e\u914d\u7f6e\u88ab\u9881\u53d1\u8bc1\u4e66\u7684 GDB \u8c03\u8bd5\u5de5\u5177\u5c06\u62e5\u6709\u7684\u6743\u9650\u3002<\/p>\n\n\n\n<p>\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6 gdb-entitlement.xml\u3002\u6587\u4ef6\u7684\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?>\n&lt;!DOCTYPE plist PUBLIC \"-\/\/Apple\/\/DTD PLIST 1.0\/\/EN\" \"http:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd\">\n&lt;plist version=\"1.0\">\n&lt;dict>\n    &lt;key>com.apple.security.cs.allow-jit&lt;\/key>\n    &lt;true\/>\n    &lt;key>com.apple.security.cs.allow-unsigned-executable-memory&lt;\/key>\n    &lt;true\/>\n    &lt;key>com.apple.security.cs.allow-dyld-environment-variables&lt;\/key>\n    &lt;true\/>\n    &lt;key>com.apple.security.cs.disable-library-validation&lt;\/key>\n    &lt;true\/>\n    &lt;key>com.apple.security.cs.disable-executable-page-protection&lt;\/key>\n    &lt;true\/>\n    &lt;key>com.apple.security.cs.debugger&lt;\/key>\n    &lt;true\/>\n    &lt;key>com.apple.security.get-task-allow&lt;\/key>\n    &lt;true\/>\n&lt;\/dict>\n&lt;\/plist>\n&lt;\/pre><\/pre>\n\n\n\n<p>\u5728\u7ec8\u7aef\u4e2d\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u9881\u53d1\u8bc1\u4e66\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">codesign --entitlements gdb-entitlement.xml -fs gdb_codesign $(which gdb)<\/pre>\n\n\n\n<p>\u6b64\u65f6\u7cfb\u7edf\u4f1a\u63d0\u793a\u8ba9\u6211\u4eec\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u7167\u505a\u5c31\u662f\u3002<\/p>\n\n\n\n<p>\u8fd9\u65f6\u6211\u4eec\u5c31\u6210\u529f\u5730\u628a\u521b\u5efa\u7684\u8bc1\u4e66\u9881\u53d1\u7ed9 GDB \u8c03\u8bd5\u5de5\u5177\u5e76\u4e3a\u5176\u8d4b\u4e88\u4e86\u8c03\u8bd5\u5668\u6743\u9650\u3002<\/p>\n\n\n\n<p>\u5728 macOS Sierra \u7248\u672c\u4ee5\u540e\uff0cGDB \u8c03\u8bd5\u5de5\u5177\u8fd8\u9700\u8981\u8fdb\u884c\u6700\u540e\u4e00\u9879\u914d\u7f6e\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u5728\u7ec8\u7aef\u6267\u884c\u4e00\u6761\u547d\u4ee4\uff0c\u6765\u7981\u6b62 GDB \u8c03\u8bd5\u5de5\u5177\u4ee5 Shell \u7684\u65b9\u5f0f\u8fd0\u884c\u7a0b\u5e8f\u3002\u5982\u679c\u4e0d\u7981\u6b62\uff0cGDB \u5de5\u5177\u5728\u6267\u884c run \u547d\u4ee4\u7684\u65f6\u5019\u88ab\u8c03\u8bd5\u7a0b\u5e8f\u4f1a\u505c\u4f4f\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">echo \"set startup-with-shell off\" >> ~\/.gdbinit<\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u91cd\u542f\u7535\u8111\uff0c\u4f7f\u4e0a\u6587\u4e2d\u7684\u8bbe\u7f6e\u751f\u6548\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u81f3\u6b64\u5462\uff0cGDB \u8c03\u8bd5\u5de5\u5177\u5728 macOS \u4e0a\u7684\u5b89\u88c5\u548c\u914d\u7f6e\u5c31\u5927\u529f\u544a\u6210\u4e86\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u540e\u8bb0<\/h2>\n\n\n\n<p>\u7b14\u8005\u60ca\u8bb6\u5730\u53d1\u73b0\uff0c\u76ee\u524d\u5728\u56fd\u5185\u7684\u7f51\u7ad9\u4e0a\u867d\u7136\u6709\u4e0d\u5c11\u5173\u4e8e\u5728 macOS \u7cfb\u7edf\u4e0b GDB \u8c03\u8bd5\u5de5\u5177\u7684\u5b89\u88c5\u548c\u914d\u7f6e\u3002\u4f46\u6ca1\u60f3\u5230\u7684\u662f\uff0c\u8fd9\u4e9b\u6559\u7a0b\u90fd\u5df2\u7ecf\u8fc7\u671f\u8fc7\u65f6\u3002\u82f9\u679c\u5728\u8f83\u65b0\u7684\u7248\u672c\u7cfb\u7edf\u4e2d\u52a0\u5f3a\u4e86\u5bf9\u8c03\u8bd5\u5668\u7a0b\u5e8f\u7684\u6743\u9650\u63a7\u5236\u548c\u7ba1\u7406\uff08SIP\uff09\uff0c\u9700\u8981\u91c7\u7528\u65b0\u7684\u65b9\u5f0f\u3002\u56e0\u6b64\u5199\u4e0b\u672c\u6587\uff0c\u4f9b\u5f00\u53d1\u8005\u4eec\u53c2\u8003\u5b66\u4e60\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Linux \u7cfb\u7edf\u4e0b\uff0c\u5b89\u88c5 GDB \u8c03\u8bd5\u5de5\u5177\u53ef\u80fd\u4ec5\u4ec5\u53ea\u662f\u4e00\u884c Shell \u547d\u4ee4\u7684\u4e8b\u60c5\u3002 \u5c3d\u7ba1 ma [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/xbtzone.com\/blog\/wp-json\/wp\/v2\/posts\/2089"}],"collection":[{"href":"https:\/\/xbtzone.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xbtzone.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xbtzone.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xbtzone.com\/blog\/wp-json\/wp\/v2\/comments?post=2089"}],"version-history":[{"count":2,"href":"https:\/\/xbtzone.com\/blog\/wp-json\/wp\/v2\/posts\/2089\/revisions"}],"predecessor-version":[{"id":2102,"href":"https:\/\/xbtzone.com\/blog\/wp-json\/wp\/v2\/posts\/2089\/revisions\/2102"}],"wp:attachment":[{"href":"https:\/\/xbtzone.com\/blog\/wp-json\/wp\/v2\/media?parent=2089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xbtzone.com\/blog\/wp-json\/wp\/v2\/categories?post=2089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xbtzone.com\/blog\/wp-json\/wp\/v2\/tags?post=2089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}