MacOs
并没哟预先安装gdb
,我们可以通过homebrew
来安装
brew tap homebrew/dupes
brew install gdb
gdb
被安装的位置在/usr/local/bin
文件夹目录下面
当我们调试一个程序的时候
或出现这样的错误
nable to find Mach task port for process-id 20974: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
这意味着我们必须签名才能进行进程的调试
首先我们 Keychain Access application. 选择栏目Keychain Access -> Certificate Assistant -> Create a Certificate…
现在我们需要为证书取一个名称(eg:gdb_signcode)
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.
如上操作。
codesign -fs gdb_signcode /usr/local/bin/gdb
重启即可