Skip to content

Demangling: Add option for printing simplified async resume functions #36978

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

Conversation

kastiglione
Copy link
Contributor

@kastiglione kastiglione commented Apr 20, 2021

Add a new option to DemangleOptions for the purpose of printing async resume partials by the name of their top-level function.

This will initially be used lldb when generating backtraces. This will allow the backtrace to show frames in the backtrace using the function names found in the source code.

For demonstration, instead of a backtrace like this:

asyncHelper() at main.swift:2
(1) await resume partial function for static Main.main() at main.swift:13

with this change the backtrace will be:

asyncHelper() at main.swift:2
static Main.main() at main.swift:13

@kastiglione
Copy link
Contributor Author

Terminology question: what words are we using for the "relationship" between a function and its generated coroutines? I used "top-level" in the PR description, but is there a word that should be used instead?

@kastiglione
Copy link
Contributor Author

kastiglione commented Apr 20, 2021

There doesn't seem to be a lot of testing options for this. Is it fine or does anyone have recommendations?

@kastiglione
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@aschwaighofer aschwaighofer left a comment

Choose a reason for hiding this comment

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

LGTM

@adrian-prantl
Copy link
Contributor

There doesn't seem to be a lot of testing options for this. Is it fine or does anyone have recommendations?

You could expose it via a command line option in swift-demangle and add it to test/Demangle/demangle-special-options.test

@kastiglione
Copy link
Contributor Author

@adrian-prantl The command doesn't have many options to begin with, so I wasn't sure if it was appropriate to add an option just to test. Maybe a hidden option.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 0768697

@kastiglione
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0768697

@kastiglione
Copy link
Contributor Author

@swift-ci test Linux Platform

@adrian-prantl
Copy link
Contributor

swift-demangle is a utility to manually do all sorts of demangling, so it seems to be appropriate to expose these options

@kastiglione
Copy link
Contributor Author

I'll add a hidden flag and add FileCheck tests in a follow up. I'd prefer to merge this to allow swiftlang/llvm-project#2868 to be merged.

@kastiglione kastiglione merged commit a4e71aa into main Apr 21, 2021
@kastiglione kastiglione deleted the Demangling-Add-option-for-printing-simplified-async-resume-functions branch April 21, 2021 19:11
kastiglione added a commit that referenced this pull request Mar 22, 2022
Change `SimplifiedUIDemangleOptions` to remove "partial function" prefixes when demangling async coroutine symbols.

This removes the prefixes "await resume partial function" and "suspend resume partial function" from demangled names, in doing so hides the effect of async/coroutine function splitting from stack traces and other symbolication. This output will produce the source level function name.

For example, a symbol that previously would have demangled to:

```
(1) await resume partial function for static Main.main()
```

will, with this change, demangle to:

```
static Main.main()
```

See #36978 where `ShowAsyncResumePartial` was introduced for lldb.

rdar://90455541
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.

4 participants