1
votes

I have my Eclipse Kepler and my simple HelloWorld C-program, where I wanted to learn how to debug a C-program. When clicking on the debug-button, I get the following error message:

Error in final launch sequence Failed to execute MI command: -exec-run Error message from debugger back end: Unable to find Mach task port for process-id 359: (os/kern) failure (0x5). Unable to find Mach task port for process-id 359: (os/kern) failure (0x5).

I searched the whole day and didn't find any solution. I already did all of the recommended things in this post Eclipse GDB MacOSX Mavericks and still get this error.

It would be really great, if somebody could help me out setting up the debugger in Eclipse.

Oh and I downloaded and installed gdb-apple via macports and I had to use the "-f" option with the codesign command as it didn't work without. Maybe these are important information.

3

3 Answers

1
votes

Keep using gdb (not gdb-apple) and just do the following steps:

1- Create a certificate:

  • Start Keychain Access application (/Applications/Utilities/Keychain Access.app)
  • Open menu /Keychain Access/Certificate Assistant/Create a Certificate...
  • Choose a name (gdb-cert in the example), 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.
  • Using the contextual menu for the certificate, select "Get Info", open the Trust item, and set Code Signing to "Always Trust".

2- You must quit Keychain Access application (named "taskgated",from activity monitor) and open it again in order to use the certificate.

3- Assign the certificate to gdb:

  • using the following command: $ codesign -s gdb-cert gdb

For more details, check this link: http://sourceware.org/gdb/wiki/BuildingOnDarwin

if any of these steps are not clear, feel free to ask.

1
votes

This may happen if you signed 'gdb' before making all changes to 'gdb-cert'. Then you can restart 'taskgated' and then re-sign the 'gdb' executable.

  1. ps -e | grep taskgated
  2. sudo kill -9 <pid of taskgated>
  3. codesign -f -s gdb-cert $(which gdb)

This worked for me.

0
votes

If you get this below error, don't forget to add sudo in front of the command:

sudo codesign -s gdb-cert $(which gdb-apple)

codesign -s gdb-cert $(which gdb-apple)

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate: can't create output file: /opt/local/bin/gdb-apple.cstemp (Permission denied)
/opt/local/bin/gdb-apple: the codesign_allocate helper tool cannot be found or used