Unable to find Mach task port for process-id : (os/kern) failure (0x5). (please check gdb is codesi

(gdb) run
Starting program: /Users/lurongming/test/cpptest/main
Unable to find Mach task port for process-id 33242: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))

mac 下使用gdb调试出现问题。

https://opensource.apple.com/source/lldb/lldb-69/docs/code-signing.txt

打开启动台>>其他>>钥匙串访问>>证书助理>>创建证书:


创建证书:

一直继续。证书的位置需要为系统。

 

会提示你输入密码:


创建完毕后可以看到,钥匙串选择系统,种类选择我的证书:

打开显示简介:


选择始终信任:


然后打开终端,输入:

:sudo killall taskgated
:codesign -fs gdb_codesign gdb
gdb: No such file or directory
1
2
3
报错,查找gdb:

:which gdb
/usr/local/bin/gdb
1
2
然后执行:

:codesign -fs gdb_codesign /usr/local/bin/gdb
1
此时会要求你输入密码:

 

posted @ 2021-07-10 17:21  牧之丨  阅读(714)  评论(0编辑  收藏  举报