手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表2015年08月10日的文章

How to get a “codesigned” gdb on OSX?

这是一篇backup的文章。起因是我的命令行下的gdb出现了:

XML/HTML代码
  1. Starting program: /usr/local/Cellar/php56/5.6.9/bin/php /server/yii hprose  
  2. Unable to find Mach task port for process-id 30717: (os/kern) failure (0x5).  
  3.  (please check gdb is codesigned - see taskgated(8))  

于是google了一下,发现也有人在问类似的问题:

XML/HTML代码
  1. Because I need a Python-enabled gdb, I installed another version via  
  2.   
  3. brew tap homebrew/dupes  
  4. brew install gdb  
  5. I want to use this gdb with Eclipse CDT, where I entered the path to the binary in the Debugging settings. However, launching a program for debugging fails with the following message:  
  6.   
  7. Error in final launch sequence  
  8. Failed to execute MI command:  
  9. -exec-run  
  10. Error message from debugger back end:  
  11. Unable to find Mach task port for process-id 39847: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8))  
  12. Unable to find Mach task port for process-id 39847: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8))  
  13. What does "codesigned" mean in this context? How can I get this gdbrunning?  

有一个5个点赞的,我发现无效:

XML/HTML代码
  1. t would seem you need to sign the executable. See these links for more information. You should be able to get away with self signing if you don't plan on redistributing that version of gdb.  
  2.   
  3. https://developer.apple.com/library/mac/#documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html  
  4.   
  5. https://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man1/codesign.1.html  
  6.   
  7. Alternatively, you could disable code signing on your system, although this presents a security risk. To do so try running sudo spctl --master-disable in the Terminal.  

24人点赞的看上去不错:

XML/HTML代码
  1. I.1 Codesigning the Debugger  
  2.   
  3. The Darwin Kernel requires the debugger to have special permissions before it is allowed to control other processes. These permissions are granted by codesigning the GDB executable. Without these permissions, the debugger will report error messages such as:  
  4.   
  5. Starting program: /x/y/foo  
  6. Unable to find Mach task port for process-id 28885: (os/kern) failure (0x5).  
  7.  (please check gdb is codesigned - see taskgated(8))  
  8. Codesigning requires a certificate. The following procedure explains how to create one:  
  9.   
  10. Start the Keychain Access application (in /Applications/Utilities/Keychain Access.app)  
  11. Select the Keychain Access -> Certificate Assistant -> Create a Certificate... menu  
  12. Then:  
  13. Choose a name for the new certificate (this procedure will use "gdb-cert" as an example)  
  14. Set "Identity Type" to "Self Signed Root"  
  15. Set "Certificate Type" to "Code Signing"  
  16. Activate the "Let me override defaults" option  
  17. Click several times on "Continue" until the "Specify a Location For The Certificate" screen appears, then set "Keychain" to "System"  
  18. Click on "Continue" until the certificate is created  
  19. Finally, in the view, double-click on the new certificate, and set "When using this certificate" to "Always Trust"  
  20. Exit the Keychain Access application and restart the computer (this is unfortunately required)  
  21. Once a certificate has been created, the debugger can be codesigned as follow. In a Terminal, run the following command...  
  22.   
  23. codesign -f -s  "gdb-cert"  <gnat_install_prefix>/bin/gdb  
  24. ... where "gdb-cert" should be replaced by the actual certificate name chosen above, and should be replaced by the location where you installed GNAT.  
  25. source: https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gnat_ugn_unw/Codesigning-the-Debugger.html  

这个4人点赞的简洁明了:

XML/HTML代码
  1. I made gdb work on OSX 10.9 without codesigning this way (described here):  
  2.   
  3. Install gdb with macports. (may be you can skip it)  
  4.   
  5. sudo nano /System/Library/LaunchDaemons/com.apple.taskgated.plist  
  6. change option string from -s to -sp at line 22, col 27.  
  7.   
  8. reboot the computer.  
  9.   
  10. Use gdb  

然而这都没有什么卵用,这时候一个2人点赞的说了一个重点:

XML/HTML代码
  1. It's a very old topic, but I am adding a response, because out of many available instructions, only one contained just the right steps to make a self-signed debugger work.  
  2.   
  3. You have to create a self-signed root certificate and then sign the gdb executable with it, but many people complained that it did not work for them. Neither did it for me until I stumbled upon this link.  
  4.   
  5. The key point missing in other manuals is that you have to restart your computer for the changes to take effect. Once I did that, everything worked as intended.  
  6.   
  7. I hope, this will help others.  

是的,他在have to restart上加粗了!!!

最后一个回复表示使用了4人点赞的那个建议,并表示他就是这么完成的!原文来自:http://stackoverflow.com/questions/13913818/how-to-get-a-codesigned-gdb-on-osx