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/compile: internal prefix paths leaking into generated DWARF #26311
Comments
Not going to happen in Go 1.12 |
I should point out that removing the mangling will make parsing the names (even) harder. Is |
Are clients (e.g. delve) actually relying on mangling to disambiguate names right now? |
Yes. Specifically on the fact that the last component of the package path doesn't contain periods. |
I assume that the DWARF will have whatever package path was passed to the compiler, so yes, it seems that you would need to know this. The question in my mind is: what should we tell users -- it seems unpleasant (to me) to leave the mangling in and tell users about it ("To print a global variable V in package P, form the string "P.V" but replace all dots in P with |
I don't disagree with this.
Delve can be changed. This issue just needs to be careful not to introduce ambiguities. Maybe always putting the receiver in parentheses is enough? |
I've moved to unplanned. I am now thinking that maybe this is best handled in delve, better to leave the mangling in place. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +c78b7693ab Tue Jul 10 05:08:40 2018 +0000 linux/amd64
however this same problem appears to be present in older released (1.10, 1.9 etc)
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?linux/amd64
What did you do?
Within my GOPATH, I have a subdir "b.v1" containing b.go:
then a main program that imports the package b:
When I compile this program and look at the generated DWARF, it appears that the package path for things in "b" have been mangled (for functions and variables -- compile unit still shows the correct path):
Note the "%2ev1". It looks like this mangling is being done in PathToPrefix() in cmd/internal/objabi, no doubt to hide/mangle the "." within the name.
While it seems fine to do mangling within the compiler, it doesn't seem as though the mangling should be leaking into the generated DWARF -- names there should reflect the original package path. If I build this program and run GDB on it, I can't print out the value of the variable 'q' without knowing the special mangled name, which seems unfriendly.
What did you expect to see?
(gdb) p b.v1.q
0
(gdb)
What did you see instead?
(gdb) p 'b.v1.q'
No symbol "b.v1.q" in current context.
The text was updated successfully, but these errors were encountered: