{"id":357,"date":"2017-06-19T04:36:46","date_gmt":"2017-06-19T04:36:46","guid":{"rendered":"http:\/\/emacslisp.com\/?p=357"},"modified":"2017-06-19T04:54:11","modified_gmt":"2017-06-19T04:54:11","slug":"gdb-enable-gdb-on-mac-os","status":"publish","type":"post","link":"http:\/\/emacslisp.com\/?p=357","title":{"rendered":"gdb &#8211; enable gdb on mac os"},"content":{"rendered":"<p>Mac OS X 10.10.2 does not come with gdb pre installed. It is available on homebrew:<\/p>\n<p>$ brew tap homebrew\/dupes<br \/>\n$ brew install gdb<br \/>\nThe binary is installed on \/usr\/local\/bin<\/p>\n<p>When initializing gdb on a program (a.out) it will produce the following error:<\/p>\n<p>    Starting program: a.out<br \/>\n    Unable to find Mach task port for process-id XXXXX: (os\/kern) failure (0x5).<br \/>\n     (please check gdb is codesigned &#8211; see taskgated(8))<br \/>\nStart Keychain Access application (\/Applications\/Utilities\/Keychain Access.app)<br \/>\nThis error occurs because OSX implements a pid access policy which requires a digital signature for binaries to access other processes pids. To enable gdb access to other processes, we must first code sign the binary. This signature depends on a particular certificate, which the user must create and register with the system.<\/p>\n<p><strong>To create a code signing certificate, open the Keychain Access application. Choose menu Keychain Access -> Certificate Assistant -> Create a Certificate\u2026<\/p>\n<p>Choose a name for the certificate (e.g., gdb-cert), set Identity Type to Self Signed Root, set Certificate Type to Code Signing and select the Let me override defaults. Click several times on Continue until you get to the Specify a Location For The Certificate screen, then set Keychain to System.<\/strong><\/p>\n<p>Double click on the certificate, open Trust section, and set Code Signing to Always Trust. Exit Keychain Access application.<\/p>\n<p>Restart the taskagted service, and sign the binary.<\/p>\n<p>$ sudo killall taskgated<br \/>\n$ codesign -fs gdb-cert \/usr\/local\/bin\/gdb<\/p>\n<p>update:<br \/>\nmac os sierra, gdb will show following error.<br \/>\nDuring startup program terminated with signal ?, Unknown signal.<\/p>\n<p>touch ~\/.gdbinit<br \/>\nvim ~\/.gdbinit<br \/>\ncopy &#8220;set startup-with-shell off&#8221; into the file and save<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mac OS X 10.10.2 does not come with gdb pre installed. It is available on homebrew: $ brew tap homebrew\/dupes $ brew install gdb The binary is installed on \/usr\/local\/bin When initializing gdb on a program (a.out) it will produce the following error: Starting program: a.out Unable to find Mach task port for process-id XXXXX: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-357","post","type-post","status-publish","format-standard","hentry","category-mac-os"],"_links":{"self":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=357"}],"version-history":[{"count":3,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/357\/revisions"}],"predecessor-version":[{"id":360,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/357\/revisions\/360"}],"wp:attachment":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=357"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}