1、先按照csdn上面的这边文章进行添加证书,名称设为 code_gdbsign
https://blog.csdn.net/LU_ZHAO/article/details/104803399/
2、假如你的mac系统大于Mac OS X 10.14,则
vim 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.allow-jit</key>
    <true/>
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
    <key>com.apple.security.cs.disable-executable-page-protection</key>
    <true/>
    <key>com.apple.security.cs.debugger</key>
    <true/>
    <key>com.apple.security.get-task-allow</key>
    <true/>
</dict>
</plist>
</pre>

然后执行
codesign --entitlements gdb-entitlement.xml -fs code_gdbsign $(which gdb)
3、如果mac系统早于10.14,则执行以下命令即可
codesign -fs code_gdbsign $(which gdb)