Skip to content

Handle stepping through language thunks that call other functions than the target #10145

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

Merged
merged 3 commits into from
Mar 4, 2025

Conversation

jimingham
Copy link

We have a general feature of "stepping out past language thunks". But we also have a strategy for resolving the target of a thunk which involves stepping through it, stepping in one level deep, and if we get somewhere interesting we stop. If we try to do the latter maneuver, we need to turn off the stepping out past thunks or the first time we step out of something "not interesting" we'll also step past the thunk, defeating the strategy.

The fixes that by adding a way to say "this plan should or should not do the step out past thunk, then setting that for the step through plan.

Also added tests for this.

…read plans (llvm#129301)

Jonas recently added a trampoline handling strategy for simple language
thunks that does: "step through language thunks stepping in one level
deep and stopping if you hit user code". That was actually pulled over
from the swift implementation. However, this strategy and the strategy
we have to "step out past language thunks" when stepping out come into
conflict if the thunk you are stepping through calls some other function
before dispatching to the intended method. When you step out of the
called function back into the thunk, should you keep stepping out past
the thunk or not?

In most cases, you want to step out past the thunk, but in this
particular case you don't.

This patch adds a way to inform the thread plan (or really it's
ShouldStopHere behavior) of which behavior it should have, and passes
the don't step through thunks to the step through plan it uses to step
through thunks.

I didn't add a test for this because I couldn't find a C++ thunk that
calls another function before getting to the target function. I asked
the clang folks here if they could think of a case where clang would do
this, and they couldn't. If anyone can think of such a construct, it
will be easy to write the step through test for it...

This does happen in swift, however, so when I cherry-pick this to the
swift fork I'll test it there.

(cherry picked from commit ddbce2f)
@jimingham jimingham requested a review from a team as a code owner March 1, 2025 01:53
@jimingham jimingham requested review from felipepiovezan and adrian-prantl and removed request for a team March 1, 2025 01:53
Copy link

@felipepiovezan felipepiovezan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one question, but this LGTM either way

self.assertEqual(var.GetSummary(), '"foo"')

# Now make sure that stepping out steps past the thunk:
thread.StepOut()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any benefit in also branching on use_api here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I changed the test to use use_api consistently for all the steps.

@jimingham
Copy link
Author

@swift-ci please test

2 similar comments
@jimingham
Copy link
Author

@swift-ci please test

@jimingham
Copy link
Author

@swift-ci please test

@jimingham jimingham merged commit 2b92dd1 into swiftlang:stable/20240723 Mar 4, 2025
2 of 3 checks passed
@jimingham jimingham deleted the alloc_init-step branch March 4, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants