今天折腾了下 Golang的调试工具gdb和lldb, 遇到了一些问题, 在这里记录下方便之后查找,也给遇到的小伙伴门一些参考。(只针对macOS系统)macos
mac 建立证书 未知错误 = -2147414007
app
能够先生成一个登录证书,而后将证书移动到系统那一类就好了工具
gdb调试报错debug
Unable to find Mach task port for process-id 23330: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))
若是是 Mojave (10.14) 以前的系统调试
codesign -fs gdb-cert $(which gdb) #gdb-cert为证书名
若是是 Mojave (10.14) 以后的系统,先建立一个文件 gdb-entitlement.xml,内容为:code
<?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.debugger</key> <true/> </dict> </plist> </pre>
而后执行xml
codesign --entitlements gdb-entitlement.xml -fs gdb-cert $(which gdb)
lldb 加断点报错get
WARNING: Unable to resolve breakpoint to any actual locations.
it
gdb加断点报错io
No symbol table is loaded. Use the "file" command.
打包时加上 -ldflags=-compressdwarf=false
参考资料:
https://stackoverflow.com/questions/52534287/debug-go-program-with-gdb-on-macos