Skip to content

[lldb] Add Swift exception breakpoint frame recognizer #11097

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

Open
wants to merge 2 commits into
base: swift/release/6.2
Choose a base branch
from

Conversation

kastiglione
Copy link

@kastiglione kastiglione commented Jul 31, 2025

Adds a frame recognizer for Swift breakpoint exceptions (break set -E swift).

This initial version does the following:

  • provides a stop description ("Swift exception breakpoint")
  • selects the frame which is throwing the exception

Selecting the frame where the throw occurs allows more direct inspection of the context that is throwing, and avoids displaying Swift's internal callback hook, which isa frame with no source and no variables – only disassembly.

rdar://156452605

@kastiglione
Copy link
Author

@swift-ci test

@kastiglione kastiglione requested a review from a team as a code owner July 31, 2025 17:21
@kastiglione
Copy link
Author

A follow up to this is to implement GetExceptionObject for the recognizer.

@kastiglione
Copy link
Author

@swift-ci test macOS

9 similar comments
@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test macOS

@kastiglione
Copy link
Author

@swift-ci test

@kastiglione
Copy link
Author

Depends on llvm#152201

@kastiglione kastiglione force-pushed the dl/lldb-Add-Swift-exception-breakpoint-frame-recognizer branch from 7a6b847 to 873a804 Compare August 6, 2025 16:19
@kastiglione
Copy link
Author

@swift-ci test

Fixes a bug that surfaces in frame recognizers.

Details about the bug:

A new frame recognizer is configured to match a specific symbol
(`swift_willThrow`). This is an `extern "C"` symbol defined in a C++
source file. When Swift is built with debug info, the function
`ParseFunctionFromDWARF` will use the debug info to construct a function
name that looks like a C++ declaration (`::swift_willThrow(void *,
SwiftError**)`). The `Mangled` instance will have this string as its
`m_demangled` field, and have _no_ string for its `m_mangled` field.

The result is the frame recognizer would not match the symbol to the
name (`swift_willThrow` != `::swift_willThrow(void *, SwiftError**)`.

By changing `ParseFunctionFromDWARF` to assign both a demangled name and
a mangled, frame recognizers can successfully match symbols in this
configuration.

(cherry picked from commit 2959051)
@kastiglione kastiglione force-pushed the dl/lldb-Add-Swift-exception-breakpoint-frame-recognizer branch from 873a804 to c32f0e8 Compare August 6, 2025 21:24
@kastiglione
Copy link
Author

@swift-ci test

@kastiglione
Copy link
Author

@swift-ci test windows

1 similar comment
@kastiglione
Copy link
Author

@swift-ci test windows

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.

1 participant