-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/link: support gdb debugging when hostlinking #5221
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Comments
I don't know if we can fix this for Go 1.1 but it would be great if somebody could take a look. I expect that we just need to emit an appropriate section into the go.o file generated by 6l before invoking gcc. And we need to find out why the script doesn't load properly. Labels changed: added go1.1. |
I have a similar problem with cgo-programs but without the host linker enabled. When running go build -x the last link step invokes "6l". os: osx 10.7.5 go: go version devel +1a196137ed09 Tue Apr 09 18:17:55 2013 +1000 darwin/amd64 gdb: 7.5 (compiled "manually") Steps to repro: 1. go tool cgo main.go && go build 2. gdb testcgo Output: BFD: /private/tmp/testcgo/testcgo: unknown load command 0x29 BFD: /private/tmp/testcgo/testcgo: unknown load command 0x29 Reading symbols from /private/tmp/testcgo/testcgo... warning: `/var/folders/73/ysvvspl16bj3pqjvyt5wr3cc0000gn/T/go-build152876071/_/tmp/testcgo/_obj/main.cgo2.o': can't open to read symbols: No such file or directory. ... similar warning emitted for main.o, gcc_amd64.o, gcc_darwin_amd64.o, gcc_setenv.o and gcc_util.o Attachments: |
I believe that on OS X the system linker by default leaves the debug info in the .o files and gdb fetches them from there. That will work poorly with the go tool because the go tool discards the .o files, hence the error message you are seeing. I believe this issue is unrelated to the main problem here. If you can open a new issue for the OS X specific problem, that would be helpful. It would also be helpful if you could look at the man page for the system linker and see if there is an option to tell it to pull in debug info from .o files into the final executable. |
I think this is somewhat important for 1.1. Lots of Go programs use cgo. With 1.0, those programs could be debugged using gdb. With 1.1, they can not. This is a significant regression for a common case. If it's too hard to fix then it's too hard to fix, but let's at least take the time to understand how hard it is to fix. |
A good place to start would probably be here: https://code.google.com/p/go/source/browse/src/cmd/ld/elf.c#1425 Not at a computer where I can test this, but I suspect it's just removing that conditional. |
I haven't looked into this deeply, but simply removing the conditional is not enough. gdb says, "Reading symbols from /home/awilkins/programming/go/src/github.com/pebbe/zmq2/version...DW_FORM_strp pointing outside of .debug_str section [in module /home/awilkins/programming/go/src/github.com/pebbe/zmq2/version]" |
Had a bit more of a look. Bear in mind that I'm no DWARF expert my any stretch of the imagination, so I could be full of crap. It appears the problem (or at least the problem I noted above) is that no relocation records are generated for .debug_info, .debug_abbrev, etc. If you move "go.o" so that it's the first object in the linker args, the error message goes away because the offsets are valid. ... however when I try to actually debug in gdb and hit a breakpoint, I now get a SIGSEGV in _dl_fixup. |
https://golang.org/cl/8858047/ Status changed to Started. |
This issue was updated by revision 825b1e1. This CL is tested lightly on 386 and amd64 and fixes the cases I tested. I have not tested it on Darwin or Windows. R=golang-dev, dave, daniel.morsing, rsc CC=golang-dev https://golang.org/cl/8858047 |
Not going to happen for 1.2. This works on ELF based systems. The issue remains open, or at any rate untested, for Darwin. It's not clear to me whether this will be an issue on Windows. I guess it depends on whether people use gdb with DWARF debug info on Windows. As of this writing external linking isn't implemented on Windows anyhow. Labels changed: added go1.3maybe, removed go1.2maybe. Status changed to Accepted. |
This was referenced Feb 18, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
The text was updated successfully, but these errors were encountered: