问题:No symbol table is loaded. Use the “file” command.
参考:https://stackoverflow.com/questions/52534287/debug-go-program-with-gdb-on-macos
build时候加上-ldflags=-compressdwarf=false
或者
环境变量加上export GOFLAGS="-ldflags=-compressdwarf=false"(我还没试)
1、~/.gdbinit文件
set startup-with-shell off
set auto-load safe-path /
add-auto-load-safe-path /usr/local/Cellar/go/1.12.5/libexec/src/runtime/runtime-gdb.py
python
import sys
sys.path.append("/usr/local/Cellar/gdb/8.3/share/gdb/python")
end
2、go build -gcflags “-N -l” -ldflags=-compressdwarf=false
3、gdb hello
4、l main.main # 终于好使了。。。心好累。。。