Skip to content

[Syntax Highlighting] Add name and parameters syntax highlighting in Swift backtraces #10710

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 3 commits into
base: swift/release/6.2
Choose a base branch
from

Conversation

charles-zablit
Copy link

This PR adds function name syntax highlighting in LLDB Swift backtraces.

Motivation

In this patch, @Michael137 implemented name highlighting for methods in the C++ plugin of LLDB. This results in better readability when reading backtraces of functions with long scopes.

Please find below an example of the same feature, ported to Swift (which this patch implements):
Before:
Screenshot 2025-05-19 at 18 25 55

After:
Screenshot 2025-05-19 at 18 25 34

Implementation details

swiftlang/swift#81511 implements a way to override the NodePrinter, which allows to track relevant ranges. Once the correct ranges are tracked, we return a slice of the demangled string for the relevant part of the highlighting query.

The rest of the implementation is a close copy of @Michael137 's work.

Testing

The tests are implemented using the manglings.txt file in the swift repo.

Follow ups

  • This patch only tracks the name and parameters of the function. In order to display the scope and qualifiers of the function, we mark them in the catch all prefix and suffix ranges. We could track those ranges as well to grey out some information that are not important, eg the fact the function is fileprivate.

@charles-zablit charles-zablit requested a review from a team as a code owner May 20, 2025 16:36
@charles-zablit charles-zablit changed the title Charles zablit/lldb/swift mangling [Syntax Highlighting] Add name and parameters syntax highlighting in Swift backtraces May 20, 2025
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