gdb fails with “Unable to find Mach task port for process-id” error

后端 未结 12 2044
青春惊慌失措
青春惊慌失措 2020-11-28 19:02

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         


        
12条回答
  •  一整个雨季
    2020-11-28 19:12

    You need to create a certificate and sign gdb:

    • Open application “Keychain Access” (/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 “Continue”. You might want to extend the predefined 365 days period to 3650 days.
    • Click several times on “Continue” until you get to the “Specify a Location For The Certificate” screen, then set “Keychain to System”.
    • 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.
    • In keychains select “System”, and you should find your new certificate. Use the context menu for the certificate, select “Get Info”, open the “Trust” item, and set “Code Signing” to “Always Trust”.
    • You must quit “Keychain Access” application in order to use the certificate and restart “taskgated” service by killing the current running “taskgated” process. Alternatively you can restart your computer.
    • Finally you can sign gdb:

      sudo codesign -s gdb-cert /usr/local/bin/ggdb

      sudo ggdb ./myprog

提交回复
热议问题