Skip to content

[lldb][swift] Add function to extract funclet numbers #10247

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

Merged

Conversation

felipepiovezan
Copy link

Async functions are broken into many pieces, and each piece is identified by an integer number in the mangling scheme. This establishes an ordering between funclets which we can exploit, in a subsequent commit, to filter out multiple breakpoints locations attributed to the same line.

An exception: entry funclets don't have such a number. This commit assigns 0 to them, to better reflect the intent of ordering funclets.

@felipepiovezan felipepiovezan requested a review from a team as a code owner March 13, 2025 14:42
Copy link

@kastiglione kastiglione left a comment

Choose a reason for hiding this comment

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

Looks good. I have a few comments.

Comment on lines 149 to 150
if (node_id)
return node_id->getIndex();

Choose a reason for hiding this comment

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

since I've seen all sorts of invariants break with demangled node trees, this should probably include a check to node_id->hasIndex().

using namespace swift::Demangle;
Context ctx;
NodePointer node = SwiftLanguageRuntime::DemangleSymbolAsNode(name, ctx);
return GetFuncletNumber(node);

Choose a reason for hiding this comment

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

Should there be a log (perhaps verbose only) to capture symbols that fail to get a funclet number?

Suggested change
return GetFuncletNumber(node);
auto number = GetFuncletNumber(node);
if (node && !number)
LLDB_LOG(..., "could not get funclet number for mangled name {0}", name);
return number;

Copy link
Author

Choose a reason for hiding this comment

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

The challenge with this is that the StringRef overload of this function is only used for testing.

The real users of this function will use the NodePointer overload (which is called by the StringRef overload), as they use the NodePointer for other purposes. As such, we wouldn't be logging on the most important path (there is no way to grab the name from the NodePointer).

With that in mind, I'll make sure to add logging on the next PR, the one that uses these functions to filter breakpoints.

Comment on lines 162 to 163
if (!IsSwiftMangledName(name))
return {};

Choose a reason for hiding this comment

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

I think this is redundant.

Async functions are broken into many pieces, and each piece is
identified by an integer number in the mangling scheme. This establishes
an ordering between funclets which we can exploit, in a subsequent
commit, to filter out multiple breakpoints locations attributed to the
same line.

An exception: entry funclets don't have such a number. This commit
assigns 0 to them, to better reflect the intent of ordering funclets.
@felipepiovezan felipepiovezan force-pushed the felipe/funclet_number branch from 298995a to 9cb2811 Compare March 13, 2025 19:40
@felipepiovezan
Copy link
Author

@swift-ci test

@felipepiovezan felipepiovezan merged commit 162ee50 into swiftlang:stable/20240723 Mar 14, 2025
3 checks passed
@felipepiovezan felipepiovezan deleted the felipe/funclet_number branch March 14, 2025 09:37
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