go: runtime: gdb command "goroutine 1 bt" fails on core file

What version of Go are you using (go version)?

go version go1.5.3 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH=“amd64” GOBIN=“” GOEXE=“” GOHOSTARCH=“amd64” GOHOSTOS=“linux” GOOS=“linux” GOPATH=“/ldata/comp/project/go” GORACE=“” GOROOT=“/ldata/bin/go” GOTOOLDIR=“/ldata/bin/go/pkg/tool/linux_amd64” GO15VENDOREXPERIMENT=“” CC=“gcc” GOGCCFLAGS=“-fPIC -m64 -pthread -fmessage-length=0” CXX=“g++” CGO_ENABLED=“1”

What did you do?

  1. export GOTRACEBACK=crash
  2. ulimit -c unlimited
  3. write a buggy program and run it to generate a core file
  4. use gdb to load core file
  5. source runtime-gdb.py
  6. run goroutine 1 bt

What did you expect to see?

print stack trace of goroutine 1

What did you see instead?

print error msg: Python Exception <class ‘gdb.error’> You can’t do that without a process to debug.: Error occurred in Python command: You can’t do that without a process to debug.

About this issue

  • Original URL
  • State: open
  • Created 10 years ago
  • Reactions: 2
  • Comments: 15 (8 by maintainers)

Most upvoted comments

For posterity, dlv should work fine for this. dlv core <binary> <core file>.

FWIW, I recently wrote a gdb script that addresses this by copying the core file and rewriting the PC/SP saved in the core file for thread 1. You can then open this new core file and backtrace from it. It’s awful, but it works (at least, on linux/amd64). https://gist.github.com/aclements/8d2d6a1d1ade4bc4fd492db6d3eb07a5