Skip to content

Swift call site breakpoints #9493

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

Conversation

jimingham
Copy link

This is a cherry-pick of the main patch to add the ability to set breakpoints on call-site file & line numbers, and to handle hitting breakpoints in a virtual inlined call stack correctly.

This fixes the two test suite failures that I missed in the PR:

llvm#112939

One was a poorly written test case - it assumed that on connect to a
gdb-remote with a running process, lldb MUST have fetched all the frame
0 registers. In fact, there's no need for it to do so (as the CallSite
patch showed...) and if we don't need to we shouldn't. So I fixed the
test to only expect a `g` packet AFTER calling read_registers.

The other was a place where some code had used 0 when it meant
LLDB_INVALID_LINE_NUMBER, which I had fixed but missed one place where
it was still compared to 0.

(cherry picked from commit 7dbbd2b)
…l stack. (llvm#114337)

The computation of 'Thread::IsVirtualStep" was wrong - it called being
at the bottom of a virtual call stack a "virtual step" but that is
actually when you've gotten to concrete code and need to step for real.

I also added a test for this.

(cherry picked from commit 3243e3d)
The test is currently passing everywhere but this 32-bit arm ubuntu bot.
I don't have an easy way to debug this, so I'm skipping the test on that
platform till we get a chance to figure this out.

(cherry picked from commit a218f0f)
@jimingham
Copy link
Author

@swift-ci test

When you set a "next branch breakpoint" and run to it while stepping,
you have to claim the stop at that breakpoint to be the top of the
inlined call stack, or you will seem to "step in" and then plans might
try to step back out again.

This records the PrefferedLineEntry for next branch breakpoints and adds
a test to make sure this works.

(cherry picked from commit 23a01a4)
I have to check for the sc list size being changed by the call-site
search, not just that it had more than one element.

Added a test for multiple CU's with the same name in a given module,
which would have caught this mistake.

We were also doing all the work to find call sites when the found decl
and specified decl's only difference was a column, but the incoming
specification hadn't specified a column (column number == 0).

(cherry picked from commit 803f957)
@jimingham
Copy link
Author

@swift-ci please test

@jimingham
Copy link
Author

@swift-ci please test

self.assertIn("a.testStringify", thread.frames[0].name, "Step out back to origin")
thread.StepInto()
self.assertIn(
"freestanding macro expansion #1 of no_return in module a file main.swift line 6 column 3",

Choose a reason for hiding this comment

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

These demanglings may not be stable — but whoever changes them in the future can also update this test.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, it was so handy that these names had the compiler's view of both the call site and the expansion order to confirm we hit the right one, and it serves as a check against our reading of the line table. So I do think it's worth tracking changes in the demangling.

@jimingham
Copy link
Author

The Linux bot failed because the "set a breakpoint on a REPL defined function then call it" timed out without so far as I can tell producing anything to match against. Sounds like the REPL just never came up? I'll try again.

@jimingham
Copy link
Author

@swift-ci please test Linux

@jimingham jimingham merged commit 8c3e30e into swiftlang:stable/20240723 Nov 7, 2024
3 checks passed
@jimingham jimingham deleted the swift-call-site-breakpoints branch November 7, 2024 20:59
ahoppen added a commit that referenced this pull request Nov 8, 2024
…points"

This reverts commit 8c3e30e, reversing
changes made to ef32f25.
ahoppen added a commit that referenced this pull request Nov 8, 2024
Revert "Merge pull request #9493 from jimingham/swift-call-site-breakpoints"
jimingham added a commit to jimingham/from-apple-llvm-project that referenced this pull request Nov 8, 2024
…t-call-site-breakpoints""

This reverts commit c93fb6d.
jimingham pushed a commit that referenced this pull request Nov 8, 2024
…points"

This reverts commit 8c3e30e, reversing
changes made to ef32f25.

(cherry picked from commit c93fb6d)
jimingham added a commit that referenced this pull request Nov 8, 2024
Revert "Merge pull request #9493 from jimingham/swift-call-site-break…
jimingham added a commit to jimingham/from-apple-llvm-project that referenced this pull request Dec 14, 2024
…t-call-site-breakpoints""

This reverts commit c93fb6d.
@jimingham jimingham mentioned this pull request Dec 14, 2024
jimingham added a commit that referenced this pull request Jan 15, 2025
…te-breakpoints""

This reverts commit c93fb6d.

(cherry picked from commit 30dbbe2)
jimingham added a commit that referenced this pull request Jan 15, 2025
Revert "Revert "Merge pull request #9493 from jimingham/swift-call-si…
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.

2 participants