This is an archive of the discontinued LLVM Phabricator instance.

[lldb] fix stepping through POSIX trampolines
ClosedPublic

Authored by mdaniels on Jun 16 2022, 12:12 PM.

Details

Summary

The DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan() function was
doing the symbol lookup using the demangled name. This stopped working
with https://reviews.llvm.org/D118814. To get things working again, just
use the mangled name for the lookup instead.

Diff Detail

Event Timeline

mdaniels created this revision.Jun 16 2022, 12:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2022, 12:12 PM
mdaniels requested review of this revision.Jun 16 2022, 12:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2022, 12:12 PM

Is there a test that was failing with this? If not can we add one?

mdaniels updated this revision to Diff 437741.Jun 16 2022, 3:50 PM

Added a simple test case that reproduces the issue.

LGTM, just a question if we want to restrict this test to linux only.

lldb/test/API/lang/cpp/step-into-namespace/TestStepIntoNamespace.py
8 ↗(On Diff #437741)

Do we want to limit this to linux? I am not sure this will pass the windows buildbots if we don't restrict it

@JDevlieghere could you confirm my understanding of the issue here is correct?

It looks like https://github.com/llvm/llvm-project/issues/54250 is the same issue, and should be fix with this as well.

lldb/test/API/lang/cpp/step-into-namespace/TestStepIntoNamespace.py
8 ↗(On Diff #437741)

Looking at other tests that load a shared library, it seems I should have at least

@skipIfRemote
@skipIfWindows

But I can also just restrict it to the platforms I am able to test on locally, linux and darwin, if there is still concern that other platforms might fail.

labath accepted this revision.Jun 19 2022, 11:34 PM
labath added inline comments.
lldb/test/API/lang/cpp/step-into-namespace/TestStepIntoNamespace.py
5 ↗(On Diff #437741)

Am I correct in assuming that the "namespace" part here comes from the fact that global functions (e.g. _Z3foov aka foo()) would be found according to their base name (foo) or something?

If yes, that's fine, but it would still be nice to mention (say in a comment or something) that the shared library is an important aspect of the test ("TestStepIntoNamespace" does not convey that notion).

If this can also be reproduced with regular functions, then it'd be better to rename the test into something else (which includes the word "trampoline").

8 ↗(On Diff #437741)

Neither of these is strictly necessary. Remote shared library tests need additional care as one has to copy the shared library to the remote system, but afaik, you're using the correct incantation which should do that automatically.

Windows shared library support is not at the level of other platforms, but a simple setup like this should work. Or rather: if it fails, it will probably be due to the trampoline aspect, and not the shared library loading. So I think you don't need to add any decorators right now. We can add xfail-windows if it turns out to be failing.

This revision is now accepted and ready to land.Jun 19 2022, 11:34 PM
mdaniels updated this revision to Diff 438347.Jun 20 2022, 5:25 AM
mdaniels added inline comments.
lldb/test/API/lang/cpp/step-into-namespace/TestStepIntoNamespace.py
5 ↗(On Diff #437741)

The lookup will be done with the full demangled name, so in this case it would be "foo::foo()".

The namespace part was just because I had trouble reproducing when reducing the testcase to a plain function call. Though I tried it again and can reproduce the issue fine, so was likely user error on my part.

I will rename as suggested, thanks.

8 ↗(On Diff #437741)

Good to know, thanks for the feedback

labath accepted this revision.Jun 28 2022, 7:21 AM

Cool, thanks. So do you have commit access, or you need someone to commit this for you?

I do not have commit access, so I would need someone to commit for me.

This revision was automatically updated to reflect the committed changes.