Skip to content

[lldb] fix cropped demangled names in Swift backtraces #11068

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 1 commit into
base: swift/release/6.2.1
Choose a base branch
from

Conversation

charles-zablit
Copy link

@charles-zablit charles-zablit commented Jul 28, 2025

This PR fixes TestSwiftAsyncHiddenFrames.py which had been failing since #10710 was merged.

This PR introduces a new entity formatting attribute: function.name-qualifiers. It's a catch all for any characters between the function's name and its arguments/template arguments. For instance, for the closure below, in C.run is the name qualifier.

closure #1 in C.run<τ_0_0>(action=0x00000001000080c0 async function pointer to closure #1 @Sendable () async -> Swift.Int in static a.Main.main() async -> ())

This PR depends on:

@charles-zablit charles-zablit self-assigned this Jul 28, 2025
@charles-zablit charles-zablit requested a review from a team as a code owner July 28, 2025 15:12
@charles-zablit charles-zablit changed the title [draft] [lldb] fix cropped demangled names in Swift backtraces [lldb] fix cropped demangled names in Swift backtraces Aug 1, 2025
charles-zablit added a commit to llvm/llvm-project that referenced this pull request Aug 5, 2025
…#150999)

This patch adds 2 new attributes to `DemangledNameInfo`: `TemplateRange`
and `NameQualifiersRange`. It also introduces the
`function.name-qualifiers` entity formatter which allows tracking
qualifiers between the name of a function and its arguments/template.

This will be used downstream in Swift but may have applications in C++:
swiftlang#11068.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Aug 5, 2025
…ledNameInfo (#150999)

This patch adds 2 new attributes to `DemangledNameInfo`: `TemplateRange`
and `NameQualifiersRange`. It also introduces the
`function.name-qualifiers` entity formatter which allows tracking
qualifiers between the name of a function and its arguments/template.

This will be used downstream in Swift but may have applications in C++:
swiftlang/llvm-project#11068.
charles-zablit added a commit to charles-zablit/llvm-project that referenced this pull request Aug 5, 2025
…llvm#150999)

This patch adds 2 new attributes to `DemangledNameInfo`: `TemplateRange`
and `NameQualifiersRange`. It also introduces the
`function.name-qualifiers` entity formatter which allows tracking
qualifiers between the name of a function and its arguments/template.

This will be used downstream in Swift but may have applications in C++:
swiftlang#11068.
@charles-zablit charles-zablit force-pushed the charles-zablit/lldb/fix-cropped-swift-closures-in-backtraces branch 2 times, most recently from 97d1880 to fc8389e Compare August 8, 2025 14:42
krishna2803 pushed a commit to krishna2803/llvm-project that referenced this pull request Aug 12, 2025
…llvm#150999)

This patch adds 2 new attributes to `DemangledNameInfo`: `TemplateRange`
and `NameQualifiersRange`. It also introduces the
`function.name-qualifiers` entity formatter which allows tracking
qualifiers between the name of a function and its arguments/template.

This will be used downstream in Swift but may have applications in C++:
swiftlang#11068.
augusto2112 pushed a commit to augusto2112/llvm-project that referenced this pull request Aug 15, 2025
…llvm#150999)

This patch adds 2 new attributes to `DemangledNameInfo`: `TemplateRange`
and `NameQualifiersRange`. It also introduces the
`function.name-qualifiers` entity formatter which allows tracking
qualifiers between the name of a function and its arguments/template.

This will be used downstream in Swift but may have applications in C++:
swiftlang#11068.
@adrian-prantl
Copy link

Can you rebase this on swift/release/6.2.1?

size_t generic_end = generic_start + 1;

while (generic_end < demangled_name.size() && generic_depth > 0) {
if (demangled_name[generic_end] == '<') {

Choose a reason for hiding this comment

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

LLVM coding style prefers no {} in single-statements:
if (demangled_name[generic_end] == '<')
generic_depth++;
else if ...

Copy link
Author

Choose a reason for hiding this comment

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

Fixed, thanks!

@charles-zablit charles-zablit force-pushed the charles-zablit/lldb/fix-cropped-swift-closures-in-backtraces branch from fc8389e to d61aa2f Compare August 20, 2025 16:54
@charles-zablit charles-zablit changed the base branch from swift/release/6.2 to swift/release/6.2.1 August 20, 2025 16:54

if (!info.hasPrefix())
return llvm::createStringError(
"DemangledInfo for '%s does not have a name qualifiers range.",

Choose a reason for hiding this comment

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

        "DemangledInfo for '%s' does not have a name qualifiers range.",

also, is there a way to phrase this without referencing DemangledInfo (in case users see this?)

Copy link
Author

@charles-zablit charles-zablit Aug 21, 2025

Choose a reason for hiding this comment

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

Replaced it with: "The demangled name for '%s does not have a name qualifiers range.", and fixed the 3 other occurrences as well.

@charles-zablit charles-zablit force-pushed the charles-zablit/lldb/fix-cropped-swift-closures-in-backtraces branch from d61aa2f to f654f43 Compare August 21, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants