My app runs fine but gdb fails to debug it with the following error
(gdb) run
Starting program: /path/to/app
Unable to find Mach task port for process-id 83
These instructions work for OSX High Sierra and avoid running gdb as root (yuck!). I recently updated from OSX 10.13.2 to 10.3.3. I think this is when gdb 8.0.1 (installed w/ homebrew) started failing for me.
I had difficulty with other people's instructions. After different instructions, everything was a mess. So I started a fresh. I more or less followed these instructions.
Clean the mess :
brew uninstall --force gdb # This deletes _all_ versions of gdb on the machineApplications -> Utilities -> Keychain Access, I deleted all previous gdb certificates and keys (be sure you know what you're doing here!). It's unclear if this is necessary, but since I'd buggered up trying to create those certificates and keys using other instructions I eliminated them anyways. I had keys and certificates in both login and system.Now reinstall gdb.
brew install gdbKeychain Access, go to menu Keychain Access-> Certificate Assistant -> Create a CertificateName : gdb-cert Identity Type: Self Signed Root Certificate Type : Code Signing [X] Let me override defaults
Serial Number : 1 Validity Period (days): 3650
On 2nd Certificate Information page, I left all fields blank except those already filled in.
On Key Pair Information page, I left the defaults
Key Size : 2048 Algorithm : RSA
[X] Include Key Usage Extension [X] This extension is critical Capabilities: [X] Signature
[X] Include Extended Key Usage Extension [X] This extension is critical Capabilities: [X] Code Signing
On Basic Constraints Extension Page, nothing was checked (default).
On Subject Alternate Name Extension page, I left the default checked and didn't add anything else.
[X] Include Subject Alternate Name Extension
Keychain: System
I clicked Create and was prompted for my password.
Back in the Keychain Access app, I went to System and right clicked on gdb-cert and under dropdown menu Trust, I changed all the fields to Always Trust.
Rebooted computer.
At the Terminal, I ran codesign -s gdb-cert /usr/local/bin/gdb. I entered my password when prompted.
At the Terminal, I ran echo "set startup-with-shell off" >> ~/.gdbinit
I ran gdb myprogram and then start within the gdb console. Here, I believe, it prompted for me for my password. After that, all subsequent runs, it did not prompt for my password.