解决MAC Eclipse CDT无法Debug的问题

Eclipse GDB MacOSX Mavericks [closed]

I have had terrible problems making an Application Debug using Eclipse C/C++ project with XCode 5.0 and I have finally made it. I have finally been able to successfully debug my application and that's why I decided to make this little tutorial hoping to save time to others.

When trying to debug and application written in C/C++ on Eclipse on Mavericks OS it comes up with "Error gdb -- version".

This is because Eclipse cannot find GDB debug on new Mac OSX because Apple discontinues GDB support in place of LLDB. To check if this is your case simply try to run from Terminal gdb and it will show up as file not found.

The problem is that LLDB is not configured for Eclipse yet (or the other way around). So how to make your Eclipse debug the application again as in previous 10.8 OS?

First get and compile the GDB. You have two possible options:

  • Macports (Unfortunately, the Mavericks release got stuck in Building getext library)
  • Homebrew

My suggestion is to get it from Homebrew. Check on their web site the download link and install using

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/hebrew/go/install)"

Let it install. After it successfully installed GDB you need to sign a certificate to make Eclipse able to use GDB otherwise it will show up the error:

Unable to find Mach task port for process-id 28885: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))

This means Eclipse can find the GDB now but cannot run it because of the Apple certificates issue.

To sign the GDB application and make it possible that Eclipse runs it follow the guide here:

https://sourceware.org/gdb/wiki/BuildingOnDarwin

which can be summarized in:

  1. Start Keychain Access application (/Applications/Utilities/Keychain Access.app)
  2. Open menu /Keychain Access/Certificate Assistant/Create a Certificate (TOP MENU BAR)

  3. Choose a name (gdb-cert in the example) 3.1 Set "Identity Type" to "Self Signed Root" 3.2 Set "Certificate Type" to "Code Signing" 3.3 Check the flag "Let me override defaults" 3.4 Click several times on "Continue" until you get to the "Specify a Location For The Certificate screen" then set Keychain to "System" 3.5 If you can't store the certificate in the "System" keychain, create it in the "login" keychain, then export it. You can then import it into the "System" keychain. 3.6 Make sure you have the "gdb-cert" in your "System" (left top window)

  4. Select "Get Info" by pressing twice on the fresh made certificate (gdb-cert),

  5. Open the "Trus"t item, and set "Code Signing to Always Trust"
  6. Close Keychain Access application
  7. Restart "taskgated" application from activity monitor

Now you need to sign the Certificated by doing from terminal

$ codesign -s gdb-cert ../path of GDB

Example:

$ codesign -s gdb-cert /usr/local/bin/gdb

You are all set now.... ready to debug you C/C++ application on Eclipse on MacOSX Mavericks

Make sure you have all set properly once again double check on Eclipse Menu Run->Debug Configuration->Debugger the line : GDB Debugger -> /usr/local/bin/gdb (or your local path, check it with "$ which gdb" to get the correct path) GDB Command file-> .gdbinit

Apple let GDB installed on the Mavericks but they like people squash their heads on the wall before doing a simple Hallo World program. No comment.

Have Fun and I hope to have saved you time!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值