简体   繁体   中英

Trying to use gdb (and cgdb) for debugging programs in go (golang) but there seems to be problems

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM