-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: the DW_AT_location of the return value is empty when its name is not specified #28416
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
Comments
/cc @heschik @dr2chase @aclements |
I think fa31093 came very close to fixing this, but it only adds names for PPARAM, not PPARAMOUT. |
There were random scary words around PPARAMOUT that made me decide that discretion was the better part of valor. I can look into PPARAMOUT in a bit, but I have actual debugging lies that need to be removed or corrected first. |
@ks888, can I ask what the use case is here? If there's a strong requirement I can take a quick shot at getting something in before the code freeze. |
@heschik I'm now working on the function tracer project for golang (here is the project page). The tracer traces the specified function and prints its actual input arguments when the function is called. As well, the actual output arguments are printed when the function is returned. The location information of output arguments is important to print the correct values here. |
Yeah, okay, #14762 makes this pretty hard. I don't think it's possible to fix this until that's done, because the location list generation code is primarily interested in register contents, and it can't see those because of that bug. @ks888, if you can build your binaries in "debug" mode, i.e. with |
Thank you for finding it out. I'm going to ask my users to compile the binary in debug mode for now. |
Actually, I was able to get a tiny little location list for the return value. It only exists for the moment right before the return, and unfortunately it looks like our CFA information is wrong after $rsp is adjusted in the exit. It might be better than nothing? @aarzilli @derekparker, does this sound interesting at all to you? Right now I don't think it's worth it but I'd be curious to hear your thoughts. |
It actually looks good to me, at least for main.fib above. How is it wrong? GNU objdump seems to print nonsensical values for all arguments of DW_CFA_def_cfa_offset_sf but the bytes are good (it seems that objdump is interpreting the argument of DW_CFA_def_cfa_offset_sf as ULEB128 but the standard clearly says that it's signed and if objdump was right nothing would ever work with gdb). diexplorer gives me this instructions for main.fib:
it's switching between a frame size of 28 (-0xa * -4) and a frame size of 8 (-0x2 * -4) corresponding to the places where the return instructions are.
If it's there delve will use it for its own function tracing, I wouldn't exactly put it at the top of the list of problems with debugging optimized programs and weight it against increased binary size. @ks888 you might be interested in knowing that delve also has a function tracing feature, albeit with a different interface. You could benefit from using delve as your backend, unless your objective is reimplementing a debugger backend, of course. |
Interesting. Maybe it's actually a gdb bug -- when I stop at
in Delve, it prints n fine. When I do it in gdb:
I get gibberish. Fair enough. Thanks. |
What's your gdb version? I spent some time trying to figure out why gdb wouldn't debug (on a Mac) my test binary, but when I lit up 8.2 in a Docker (to eliminate the Mac craziness) it worked fine. But perhaps 8.1 or 8.0, etc. |
@aarzilli Thank you. Yeah, I should definitely consider using the delve as the backend at some point. |
The fact that gdb disagrees on this is worrying, but I can't see why delve interpretation would be wrong and lldb agrees with us, so I'm going to provisionally agree that it's a gdb bug. |
What version of Go are you using (
go version
)?go version devel +66bb8ddb95 Thu Oct 25 13:37:38 2018 +0000 darwin/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
In the sample program below, the DW_AT_location of the return value
~r1
is empty. It's nice to provide the information about the location here because the value is present on the stack and is used later.I'm not sure it's helpful, but I noticed the DW_AT_location is not empty if the name of the return value is specified in the source:
What did you expect to see?
The DW_AT_location of the return value
~r1
provides the information about the location.What did you see instead?
The DW_AT_location of the return value
~r1
is empty.The text was updated successfully, but these errors were encountered: