Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac C++/Mars eclipse gdb debug hangs at Launching Test 96%

When I try to debug a simple c++ program in Eclipse Mars (4.5.2) on Mac El Capitan (10.11.5), it hangs on "Launching Test (96%)".

I have gdb installed with homebrew. When I type "which gdb" in terminal it says, "/usr/local/bin/gdb".

Here are screenshots of the problem and of my GDB settings: http://imgur.com/a/JrMjN

This is the same problem as Mac C++/Mars eclipse gdb debug launching stuck at 96% but it was never solved there.

like image 684
elvislives Avatar asked Jan 06 '23 20:01

elvislives


1 Answers

You have to sign gdb to be trusted to control the execution of another process. This is part of the security structures that are present in ElCapitan (have been like this since Mavericks).

You can do this by following the instructions below (extract from the blog post http://ntraft.com/installing-gdb-on-os-x-mavericks/ which contains more information on the topic).


Certifying GDB

Open up the Keychain Access application (/Applications/Utilities/Keychain Access.app). Navigate via the menu to Keychain Access > Certificate Assistant > Create Certificate...

Create certificate menu entry description

Enter a name for the certificate. For this how-to, I'll call it "gdb-cert". Set the fields exactly as shown below.

Create certificate step 1

The maximum validity period is 999 days. I don't really want to deal with this again, so I'm going to max it out. /* Addendum: this means that you will have to do this again in 999 days, i.e. 2.7 years. You might want to bookmark this page. */

Create certificate step 2

Keep clicking the "Continue" button until you are asked for a location. Set it to "System". If you are unable to save it to the System keychain, then save it to the login keychain. You can later export the cert, and then import it into the System keychain. I didn't have to do this, so comment if you have any problem.

Create certificate step 3

Success!

Create certificate step 4

Now make sure the cert is always trusted. Right-click the new certificate and select Get Info. Under the Trust section, set Code Signing to Always Trust.

Certificate Get info Always trust for code signing

Now that we have a certificate, we need to use it to sign GDB. First, we'll restart the taskgated process to make sure it picks up the new certificate. Quit Keychain Access (you must quit Keychain Access!) and return to the Terminal for these final commands.

Find the taskgated process.

$ ps -e | grep taskgated
56822 ??         0:03.11 /usr/libexec/taskgated -s
60944 ttys002    0:00.00 grep --color=auto taskgated

The first number in the above output is the PID. Use this to kill the process (it will immediately restart itself).

$ sudo kill -9 56822

Now you can finally code sign GDB.

# If installed through MacPorts
$ codesign -s gdb-cert $(which gdb-apple)
# If installed through Homebrew
$ codesign -s gdb-cert $(which gdb)
# For the settings posted by OP
$ codesign -s gdb-cert /usr/local/Cellar/gdb/7.11/bin/gdb

Now you should be all set! The OS X Keychain may ask for your password the first time you attempt to debug a program, but it should work!

/* Addendum: for me to be able to have full functionality I had to reboot the machine. */

like image 83
ramses728 Avatar answered Jan 11 '23 02:01

ramses728