Skip to content

Commit 1e8d7e9

Browse files
committed
[lldb] When matching entry values for async swift function, fallback to the current function from parent function when evaluating subexpressions.
This occurs when the parent function does not have debug info (*). In swift async functions this is ok since we only need to be able to restore the ABI defined context register for the async context (r14)... so it is not necessary to match with a callsite parameter. (*) E.x.: On Linux async funclets called from a libswift_Concurrency.so that had its debug info stripped.
1 parent 8274de2 commit 1e8d7e9

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lldb/source/Expression/DWARFExpression.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,6 @@ static bool Evaluate_DW_OP_entry_value(std::vector<Value> &stack,
731731
return false;
732732
}
733733

734-
Function *parent_func =
735-
parent_frame->GetSymbolContext(eSymbolContextFunction).function;
736-
if (!parent_func) {
737-
LLDB_LOG(log, "Evaluate_DW_OP_entry_value: no parent function");
738-
return false;
739-
}
740-
741734
// 2. Find the call edge in the parent function responsible for creating the
742735
// current activation.
743736
Function *current_func =
@@ -751,6 +744,7 @@ static bool Evaluate_DW_OP_entry_value(std::vector<Value> &stack,
751744
ModuleList &modlist = target.GetImages();
752745
ExecutionContext parent_exe_ctx = *exe_ctx;
753746
parent_exe_ctx.SetFrameSP(parent_frame);
747+
Function *parent_func = nullptr;
754748
#ifdef LLDB_ENABLE_SWIFT
755749
// Swift async function arguments are represented relative to a
756750
// DW_OP_entry_value that fetches the async context register. This
@@ -760,6 +754,14 @@ static bool Evaluate_DW_OP_entry_value(std::vector<Value> &stack,
760754
auto fn_name = current_func->GetMangled().GetMangledName().GetStringRef();
761755
if (!SwiftLanguageRuntime::IsAnySwiftAsyncFunctionSymbol(fn_name)) {
762756
#endif
757+
758+
parent_func =
759+
parent_frame->GetSymbolContext(eSymbolContextFunction).function;
760+
if (!parent_func) {
761+
LLDB_LOG(log, "Evaluate_DW_OP_entry_value: no parent function");
762+
return false;
763+
}
764+
763765
if (!parent_frame->IsArtificial()) {
764766
// If the parent frame is not artificial, the current activation may be
765767
// produced by an ambiguous tail call. In this case, refuse to proceed.
@@ -845,7 +847,8 @@ static bool Evaluate_DW_OP_entry_value(std::vector<Value> &stack,
845847
}
846848
llvm::Optional<DWARFExpression> subexpr;
847849
if (!matched_param) {
848-
subexpr.emplace(parent_func->CalculateSymbolContextModule(),
850+
auto *ctx_func = parent_func ? parent_func : current_func;
851+
subexpr.emplace(ctx_func->CalculateSymbolContextModule(),
849852
DataExtractor(opcodes, subexpr_offset, subexpr_len),
850853
dwarf_cu);
851854
}

0 commit comments

Comments
 (0)