This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Don't emit incorrect descriptions of thunk params (PR42627)
ClosedPublic

Authored by vsk on Jul 19 2019, 8:39 PM.

Details

Summary

The this parameter of a thunk requires adjustment. Stop emitting an
incorrect dbg.declare pointing to the unadjusted pointer.

We could describe the adjusted value instead, but there may not be much
benefit in doing so as users tend not to debug thunks.

Robert O'Callahan reports that this matches gcc's behavior.

Fixes PR42627.

Diff Detail

Repository
rL LLVM

Event Timeline

vsk created this revision.Jul 19 2019, 8:39 PM
vsk updated this revision to Diff 210946.Jul 19 2019, 9:09 PM
vsk edited the summary of this revision. (Show Details)
  • Fix a thinko in the test updates.
vsk added a subscriber: aprantl.Jul 29 2019, 10:22 AM

Ping. @aprantl, any thoughts on this one?

aprantl accepted this revision.Jul 29 2019, 1:41 PM

I agree, there seems not to be much value of generating debug info for the arguments of a thunk.

This revision is now accepted and ready to land.Jul 29 2019, 1:41 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2019, 3:52 PM

Should we describe thunks at all? (gcc 8.1 doesn't)

Interestingly gcc seems to include the thunk in the compile_unit address range, but doesn't have a subprogram for it...

vsk added a comment.Aug 5 2019, 1:48 PM

Should we describe thunks at all? (gcc 8.1 doesn't)

Interestingly gcc seems to include the thunk in the compile_unit address range, but doesn't have a subprogram for it...

That's a great question. That could save a little space, but it could also impair tools that treat dsyms as the source of truth for symbol information, like dtrace. I'd be open to it if the size savings were appreciable.

It's likely better for the tools to know where each function starts *and ends*.
More importantly though, if we don't generate debug info for the thunk, can we describe the function itself after it became inlined into the thunk?

It's likely better for the tools to know where each function starts *and ends*.

attribute((nodebug)) breaks that invariant (& I think there's other functions we emit without debug info too - maybe some things to do with global ctors?)

More importantly though, if we don't generate debug info for the thunk, can we describe the function itself after it became inlined into the thunk?

Not really, no - and GCC doesn't describe the inlining either. A backtrace would demangle the name of the thunk & that's about all it could show there.

It's likely better for the tools to know where each function starts *and ends*.

attribute((nodebug)) breaks that invariant (& I think there's other functions we emit without debug info too - maybe some things to do with global ctors?)

Correct, and the tools need to fall back to heuristics in these cases. I don't know whether this causes any problems in practice.

More importantly though, if we don't generate debug info for the thunk, can we describe the function itself after it became inlined into the thunk?

Not really, no - and GCC doesn't describe the inlining either. A backtrace would demangle the name of the thunk & that's about all it could show there.

*That* sounds like a good reason to keep the debug info for the thunks around.

It's likely better for the tools to know where each function starts *and ends*.

attribute((nodebug)) breaks that invariant (& I think there's other functions we emit without debug info too - maybe some things to do with global ctors?)

Correct, and the tools need to fall back to heuristics in these cases. I don't know whether this causes any problems in practice.

More importantly though, if we don't generate debug info for the thunk, can we describe the function itself after it became inlined into the thunk?

Not really, no - and GCC doesn't describe the inlining either. A backtrace would demangle the name of the thunk & that's about all it could show there.

*That* sounds like a good reason to keep the debug info for the thunks around.

Not sure I follow why demangling the symbol would result in a worse user experience than the debug info? About the only thing in the debug info is the mangled name that's in the symbol table too.

vsk added a comment.Aug 5 2019, 4:08 PM

It's likely better for the tools to know where each function starts *and ends*.

attribute((nodebug)) breaks that invariant (& I think there's other functions we emit without debug info too - maybe some things to do with global ctors?)

Correct, and the tools need to fall back to heuristics in these cases. I don't know whether this causes any problems in practice.

More importantly though, if we don't generate debug info for the thunk, can we describe the function itself after it became inlined into the thunk?

Not really, no - and GCC doesn't describe the inlining either. A backtrace would demangle the name of the thunk & that's about all it could show there.

*That* sounds like a good reason to keep the debug info for the thunks around.

Not sure I follow why demangling the symbol would result in a worse user experience than the debug info? About the only thing in the debug info is the mangled name that's in the symbol table too.

Oh, wouldn't the debugger lose the ability to synthesize an [inlined] frame for whatever is inlined into the thunk?

In D65035#1615906, @vsk wrote:

It's likely better for the tools to know where each function starts *and ends*.

attribute((nodebug)) breaks that invariant (& I think there's other functions we emit without debug info too - maybe some things to do with global ctors?)

Correct, and the tools need to fall back to heuristics in these cases. I don't know whether this causes any problems in practice.

More importantly though, if we don't generate debug info for the thunk, can we describe the function itself after it became inlined into the thunk?

Not really, no - and GCC doesn't describe the inlining either. A backtrace would demangle the name of the thunk & that's about all it could show there.

*That* sounds like a good reason to keep the debug info for the thunks around.

Not sure I follow why demangling the symbol would result in a worse user experience than the debug info? About the only thing in the debug info is the mangled name that's in the symbol table too.

Oh, wouldn't the debugger lose the ability to synthesize an [inlined] frame for whatever is inlined into the thunk?

True, true - you'd lose any variable descriptions etc. Fair point.

In D65035#1615906, @vsk wrote:

It's likely better for the tools to know where each function starts *and ends*.

attribute((nodebug)) breaks that invariant (& I think there's other functions we emit without debug info too - maybe some things to do with global ctors?)

Correct, and the tools need to fall back to heuristics in these cases. I don't know whether this causes any problems in practice.

More importantly though, if we don't generate debug info for the thunk, can we describe the function itself after it became inlined into the thunk?

Not really, no - and GCC doesn't describe the inlining either. A backtrace would demangle the name of the thunk & that's about all it could show there.

*That* sounds like a good reason to keep the debug info for the thunks around.

Not sure I follow why demangling the symbol would result in a worse user experience than the debug info? About the only thing in the debug info is the mangled name that's in the symbol table too.

Oh, wouldn't the debugger lose the ability to synthesize an [inlined] frame for whatever is inlined into the thunk?

True, true - you'd lose any variable descriptions etc. Fair point.

That's what I meant. Sorry for not expressing that better!