Skip to content

[lldb] Extract logic out of GetFunctionDisplayName into a helper function #10766

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

Conversation

charles-zablit
Copy link

This patch splits the logic inside SwiftLanguage::GetFunctionDisplayName into reusable helper functions.

  • SwiftLanguage::GetFunctionName returns the name of the function as a string.
  • SwiftLanguage::GetFunctionDisplayArgs returns the generics and arguments of the function as a string.

This will be needed for #10710

@charles-zablit charles-zablit requested a review from a team as a code owner May 30, 2025 11:13
@charles-zablit
Copy link
Author

I'm not sure about the changes to the Language::FunctionNameRepresentation::eNameWithNoArgs case. It seems like it should just print the name of the function without its parameters given the name of the enum entry. The patch respects that and will only print the name of the function.

However, this is not what's happening prior to the patch, as the parameters are printed as well.

This does not seem to break any tests in check-lldb but it's probably not tested at all.


s << display_name;
if (inline_info) {
s.PutCString(" [inlined] ");

Choose a reason for hiding this comment

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

In llvm#135343 I added a SymbolContext::GetPossiblyInlinedFunctionName. We decided the [inlined] format was a bit too noisy.

Could we clean up the Swift plugin to use that functionality?

if (open_paren && generic && generic < open_paren)
return std::string(cstr, generic);
if (open_paren)
return std::string(cstr, open_paren);

Choose a reason for hiding this comment

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

Hmmm why is this new logic needed?

Choose a reason for hiding this comment

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

We didn't previously do this in the NoArgs case right?

Copy link
Author

Choose a reason for hiding this comment

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

I am a bit confused by the original implementation of the NoArgs case: if the frame is foo(a: 1) I would expect the NoArgscase to returnfooand nothing else. But in the original implementation, it returnsfoo(a: Int)`.

This additional logic is due to me splitting the the logic into 2 helper functions. Say we have foo<T>(a: T). GetFunctionName will return foo and GetFunctionDisplayArgs will return <Int>(a=1).

Hence: no, we didn't previously do this in the NoArgs case, but I think this was a mistake. Since there are no tests for the way backtraces are printed in the Swift plugin, I have no idea how much of a breaking change this is.

Choose a reason for hiding this comment

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

Oh I see. In that case, if eNoArgs was always broken, lets just remove that case entirely? That'll mean less code to change in the other PR (and we won't be breaking any users)

@Michael137
Copy link

@swift-ci test

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