Skip to content

Commit c3429d5

Browse files
Merge pull request #10378 from felipepiovezan/felipe/call_fix_code_address
[lldb][swift] Call FixCodeAddress on code addresses read from memory
2 parents 23f6dc9 + 0fc719c commit c3429d5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,10 +2807,12 @@ std::optional<lldb::addr_t> SwiftLanguageRuntime::TrySkipVirtualParentProlog(
28072807
// Get the PC of the parent frame, i.e. the continuation pointer, which is
28082808
// the second field of the CFA.
28092809
addr_t pc_location = cfa + ptr_size;
2810-
addr_t pc_value = LLDB_INVALID_ADDRESS;
2811-
process.ReadMemory(pc_location, &pc_value, ptr_size, error);
2810+
addr_t pc_value = process.ReadPointerFromMemory(pc_location, error);
28122811
if (error.Fail())
28132812
return {};
2813+
// Clear any high order bits of this code address so that SetLoadAddress works
2814+
// properly.
2815+
pc_value = process.FixCodeAddress(pc_value);
28142816

28152817
Address pc;
28162818
Target &target = process.GetTarget();
@@ -2819,11 +2821,16 @@ std::optional<lldb::addr_t> SwiftLanguageRuntime::TrySkipVirtualParentProlog(
28192821
return {};
28202822

28212823
SymbolContext sc;
2822-
if (!pc.CalculateSymbolContext(&sc,
2823-
eSymbolContextFunction | eSymbolContextSymbol))
2824-
return {};
2825-
if (!sc.symbol && !sc.function)
2824+
bool sc_ok = pc.CalculateSymbolContext(&sc, eSymbolContextFunction |
2825+
eSymbolContextSymbol);
2826+
if (!sc_ok || (!sc.symbol && !sc.function)) {
2827+
Log *log = GetLog(LLDBLog::Unwind);
2828+
LLDB_LOGF(log,
2829+
"SwiftLanguageRuntime::%s Failed to find a symbol context for "
2830+
"address 0x%" PRIx64,
2831+
__FUNCTION__, pc_value);
28262832
return {};
2833+
}
28272834

28282835
auto prologue_size = sc.symbol ? sc.symbol->GetPrologueByteSize()
28292836
: sc.function->GetPrologueByteSize();

0 commit comments

Comments
 (0)