今天折騰了下 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