Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Mac OS Catalina all current documentation fails for Unable to find Mach task port for process-id, any advice?

Original form of question(not exactly a question per se): Unable to find Mach task port for process-id : (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))

I would love for someone to mention any information they have on gaining the ability to run gdb without sudo preferably, but just running would be fine.

I have followed the instructions at https://github.com/cs01/gdbgui/issues/55 and most every related stackoverflow and OSXdaily feed that I can find for about a week now. I know there is quite a lot of documentation about this error, but so far none have posted these outputs and are running Catalina. I'm running gdb 8.3 on Mac OSX Catalina 10.15.1, configured as "x86_64-apple-darwin19.0.0"

I have created certificates in System, and then in Login, with no change in outcome.

I have set startup-with-shell off both within gdb and within a .gdbinit file in my home directory.

I eventually been able to run gdb with sudo gdb ./a.out only to receive odd messages when I run the code with r inside of gdb:

  1. (No debugging symbols found in ./a.out)
    (gdb) r
    Starting program: /Users/zanekarl/Documents/Work-Documents//Programming/-code-snippets/a.out 
    [New Thread 0xc03 of process 906]
    [New Thread 0xf03 of process 906]
    During startup program terminated with signal SIGTRAP, Trace/breakpoint trap.```
    
  2. (No debugging symbols found in ./a.out)
    (gdb) b main
    Breakpoint 1 at 0x100000f64
    (gdb) r
    Starting program: /Users/zanekarl/Documents/Work-Documents//Programming/-code-snippets/a.out 
    [New Thread 0xd03 of process 768]
    [New Thread 0x1003 of process 768]
    During startup program terminated with signal ?, Unknown signal.```
    
  3. Reading symbols from /Users/zanekarl/Documents/Work-Documents//Programming/-code-snippets/a.out.dSYM/Contents/Resources/DWARF/a.out...
    (gdb) b main
    Breakpoint 1 at 0x100001753: file SSSv1-1.c, line 99.
    (gdb) r
    Starting program: /Users/zanekarl/Documents/Work-Documents//Programming/-code-snippets/a.out 
    [New Thread 0xb03 of process 717]```
    
  4. Reading symbols from /Users/zanekarl/Documents/Work-Documents//Programming/-code-snippets/a.out.dSYM/Contents/Resources/DWARF/a.out...
    (gdb) b main
    Breakpoint 1 at 0x100001753: file SSSv1-1.c, line 99.
    (gdb) r
    Starting program: /Users/zanekarl/Documents/Work-Documents//Programming/-code-snippets/a.out 
    Unable to find Mach task port for process-id 680: (os/kern) failure (0x5).
    (please check gdb is codesigned - see taskgated(8))```
    
like image 744
z.karl Avatar asked Oct 20 '25 03:10

z.karl


2 Answers

On my MacBook Pro (15-inch, 2016) running Catalina 10.15.2 (19C57), with sip enabled.

I installed gdb 8.3.1 by:

brew install gdb

Then on my home folder I created a gdb.xml file with the contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.cs.debugger</key>
    <true/>
</dict>
</plist>

I created the gdb-cert on the system keychain

To sign gdb, I enabled the root account, and being root, I used the command:

codesign --entitlements gdb.xml -fs gdb-cert /usr/local/Cellar/gdb/8.3.1/bin/gdb

Now I can use netbeans to debug my fortran codes.

like image 108
Marco Parente Avatar answered Oct 21 '25 17:10

Marco Parente


The entitlement xml was the missing piece for me:

  1. Launch /Applications/Utilities/Keychain Access.app
  2. Keychain Access->Certificate Assistant->Create a Certificate
    Name = gdb_codesign
    Identity Type = Self Signed Root
    Certificate Type = Code Signing
    
  3. Click on the "My Certificates"
  4. Double click on your new gdb_codesign certificate
  5. Turn down the "Trust" disclosure triangle Change: When using this certificate: Always Trust
  6. Option-drag the new gdb_codesign certificate from the login keychain to the System keychain
  7. Create codesign entitlement xml: gdb-entitlement.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>com.apple.security.cs.debugger</key>
        <true/>
    </dict>
    </plist>
    
  8. Open terminal
    $ codesign --entitlements gdb-entitlement.xml -fs gdb_codesign $(which gdb)
    $ sudo killall taskgated
    
like image 45
arcanereinz Avatar answered Oct 21 '25 18:10

arcanereinz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!