Wouldn't mind knowing the version of that Go compiler. What you see there is a bug in generated debugging information (DWARF). You might be better off using Delve; parts of the compiler are multithreaded (with goroutines, not necessarily threads that gdb understands) and that is not best case for gdb.
On Monday, March 11, 2019 at 7:01:04 PM UTC-4, MOHIT VERMA wrote: > > Thanks Ian. This helped me to identify what processes are launched when go > build is called. > I then ran gdb just for the process that compiled the file for which I > wanted to debug the compilation: > > gdb --args /home/administrator/Work/go/src/go/pkg/tool/linux_amd64/compile > -o /tmp/go-build037119929/b001/_pkg_.a -trimpath > /tmp/go-build037119929/b001 -p main -complete -buildid > Y52EEDh5fr669VPNVIvF/Y52EEDh5fr669VPNVIvF -D > _/home/administrator/Work/go/src/example_test -importcfg > /tmp/go-build037119929/b001/importcfg -pack -c=4 ./example.go > > Although I get this error when setting any breakpoint: > *Dwarf Error: Cannot find DIE at 0x182106 referenced from DIE at 0x1892a7* > > *Do I need to build the Go compiler differently to be able to debug it? * > Currently, I am just building it through make.bash from the src/ > directory. > > Thanks! > Mohit > > On Fri, Mar 8, 2019 at 4:29 PM Ian Lance Taylor <ia...@golang.org > <javascript:>> wrote: > >> On Fri, Mar 8, 2019 at 4:23 PM Mohit Verma <vmoh...@gmail.com >> <javascript:>> wrote: >> > >> > I was looking to see how the golang compiler works, and wanted to step >> in to the compilation process to see what happens. I am looking at the >> standard Go compiler in src/cmd/compile from https://github.com/golang/go >> . >> > >> > When I try to run the compilation process with gdb, I see I can put >> breakpoints for the code when the "go tool" is triggered (code in >> src/cmd/go), but not in the code inside cmd/compile/internal. >> > I can also put breakpoints for the code in runtime package, and I see >> runtime package has a special "runtime-gdb.py" file. >> > >> > Can anyone point me to what is going on here? And how can I step-in to >> the compiler code? >> >> The go tool invokes cmd/compile as a subprocess. To see exactly what >> the go tool does, run >> >> go tool -x -work >> >> That will show you an invocation of cmd/compile that you can run under >> the debugger. Using -work ensures that the temporary files passed to >> the compiler will be available; you will have to replace $WORK in the >> -x output with the temporary directory printed in the first line of >> the cmd/go output. >> >> Note that in general compilation are cached, so to get a useful >> cmd/compile execution you may have to first run "go clean -cache". >> >> Ian >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.