1

I am aware that the go team will not support GDB very well. However, it seems it works sometimes so before I give up I want to see if it works on this program.

I was trying to use it to debug my program in mac os x mavericks and I wasn't able to inspect my program at run time unfortunately. I am using mac os x mavericks 10.9.4 and my go version is go version go1.2.2 darwin/amd64.

Here is what happens if I do gdb my_binary on my binary and then try to run it:

Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hydra...
warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/crypto/x509/_obj/root_darwin.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/net/_obj/cgo_unix.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/runtime/cgo/_obj/gcc_amd64.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/runtime/cgo/_obj/gcc_darwin_amd64.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/runtime/cgo/_obj/gcc_setenv.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build728316890/runtime/cgo/_obj/gcc_util.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/m9/3tx5tfkx02z9jkwdz0lkg85cj4gbmq/T/go-build297950324/github.com/alecthomas/gozmq/_obj/zmq.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/m9/3tx5tfkx02z9jkwdz0lkg85cj4gbmq/T/go-build297950324/github.com/alecthomas/gozmq/_obj/zmq_3_x.cgo2.o': can't open to read symbols: No such file or directory.
(no debugging symbols found)...done.

The line I want to focus on is the last one:

(no debugging symbols found)...done.

Did I compile my go program wrongly? Are there any flags that could have made this work?

I only did go build my_program but it seems that maybe some flags or something could have made it work?

I have been able to make gdb work on very simple programs but on this much larger one it fails and throws the above error. Does someone know why might it be? Has someone been able to make it work for large programs with lots of libraries and packages and stuff like that?

I understand it might not work, but I wanted to give it a try by asking the community.

(I would be willing to also use a different debugger if there is one).

(I also had the same issue with cgdb).

(I am also open for using any other debugger that allows me to see values of variables, breakpoints and basic functionality like that, maybe also explore go-routines would be awesome. For mac, of course)

Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
  • go version go1.2.2 darwin/amd64 – Charlie Parker Aug 09 '14 at 19:21
  • I'm not familiar with OS X but [this](https://gist.github.com/Pallinder/6426936) might give you some help, personally I gave up on using a debugger with Go, I just use a crap ton of `log.Printf`'s. – OneOfOne Aug 09 '14 at 19:24
  • @OneOfOne I don't understand why there isn't *some* or *any* debugger for Go. Anything. I wish i understood why there doesn't exist one (not even open source I believe). – Charlie Parker Aug 09 '14 at 19:27
  • Gdb works sometimes, but yeah they will eventually figure something out for it. Check [this](https://code.google.com/p/go/issues/list?can=2&q=gdb&colspec=ID+Status+Stars+Release+Owner+Repo+Summary&cells=tiles) bug list. – OneOfOne Aug 09 '14 at 19:34
  • I gave up on using gdb too. Its was so very very flakey. I've turned to unit tests to give me the results I require. It feels nicer than littering the code with logging calls and I haven't really come across anything I couldn't debug with a test yet (although I'm sure once I ramp up my concurrency I will..). – Simon Whitehead Aug 10 '14 at 12:20
  • Just FYI, if gdb doesn't work, cgdb won't work either. cgdb is just a wrapper around gdb. – Mike Mueller Aug 12 '14 at 23:22

1 Answers1

0

GDB is telling you that the files and directories where it thinks it might find the debug symbols are not there. From the names, these are Go's temporary work directories.

There is a command-line option -work to go build that is described as follows:

print the name of the temporary work directory and do not delete it when exiting.

so this might work, at the cost of some periodic manual clean-up.

Bryan
  • 11,398
  • 3
  • 53
  • 78