Skip to content

Commit 063abb3

Browse files
[lldb] Implement SwiftLanguage::AreEqualForFrameComparison
This checks whether the two provided symbol contexts refer to funclets of the same async function. In particular, this fixes an issue in the ThreadPlanStepOverRange algorithm for async functions. When the plan stops, it compares the current symbol context to the symbol context of where it started. An initial comparison is done through StackIDs. If that comparison says the two are equal, the plan then attempts to confirm the two SymbolContexts are the same by checking whether the underlying functions are the same. Because different funclets correspond to different low level functions, this comparison was failing.
1 parent 1aec81a commit 063abb3

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,23 @@ bool SwiftLanguage::IgnoreForLineBreakpoints(const SymbolContext &sc) const {
18341834
name);
18351835
}
18361836

1837+
std::optional<bool>
1838+
SwiftLanguage::AreEqualForFrameComparison(const SymbolContext &sc1,
1839+
const SymbolContext &sc2) const {
1840+
auto result = SwiftLanguageRuntime::AreFuncletsOfSameAsyncFunction(
1841+
sc1.GetFunctionName(Mangled::ePreferMangled),
1842+
sc2.GetFunctionName(Mangled::ePreferMangled));
1843+
switch (result) {
1844+
case SwiftLanguageRuntime::FuncletComparisonResult::NotBothFunclets:
1845+
return {};
1846+
case SwiftLanguageRuntime::FuncletComparisonResult::SameAsyncFunction:
1847+
return true;
1848+
case SwiftLanguageRuntime::FuncletComparisonResult::DifferentAsyncFunctions:
1849+
return false;
1850+
}
1851+
llvm_unreachable("unhandled enumeration in AreEquivalentFunctions");
1852+
}
1853+
18371854
//------------------------------------------------------------------
18381855
// Static Functions
18391856
//------------------------------------------------------------------

lldb/source/Plugins/Language/Swift/SwiftLanguage.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ class SwiftLanguage : public Language {
7575
ConstString
7676
GetDemangledFunctionNameWithoutArguments(Mangled mangled) const override;
7777

78+
/// Returns whether two SymbolContexts correspond to funclets of the same
79+
/// async function.
80+
/// If either SymbolContext is not a funclet, nullopt is returned.
81+
std::optional<bool>
82+
AreEqualForFrameComparison(const SymbolContext &sc1,
83+
const SymbolContext &sc2) const override;
7884
//------------------------------------------------------------------
7985
// Static Functions
8086
//------------------------------------------------------------------

0 commit comments

Comments
 (0)