@@ -2924,31 +2924,15 @@ std::optional<lldb::addr_t> SwiftLanguageRuntime::TrySkipVirtualParentProlog(
29242924 addr_t pc_value = process.ReadPointerFromMemory (pc_location, error);
29252925 if (error.Fail ())
29262926 return {};
2927- // Clear any high order bits of this code address so that SetLoadAddress works
2928- // properly.
2929- pc_value = process.FixCodeAddress (pc_value);
29302927
2931- Address pc;
2932- Target &target = process.GetTarget ();
2933- pc.SetLoadAddress (pc_value, &target);
2934- if (!pc.IsValid ())
2935- return {};
2936-
2937- SymbolContext sc;
2938- bool sc_ok = pc.CalculateSymbolContext (&sc, eSymbolContextFunction |
2939- eSymbolContextSymbol);
2940- if (!sc_ok || (!sc.symbol && !sc.function )) {
2941- Log *log = GetLog (LLDBLog::Unwind);
2942- LLDB_LOGF (log,
2943- " SwiftLanguageRuntime::%s Failed to find a symbol context for "
2944- " address 0x%" PRIx64,
2945- __FUNCTION__, pc_value);
2946- return {};
2947- }
2928+ llvm::Expected<uint64_t > maybe_prologue_size =
2929+ FindPrologueSize (process, pc_value);
2930+ if (maybe_prologue_size)
2931+ return pc_value + *maybe_prologue_size;
29482932
2949- auto prologue_size = sc. symbol ? sc. symbol -> GetPrologueByteSize ()
2950- : sc. function -> GetPrologueByteSize ( );
2951- return pc_value + prologue_size ;
2933+ LLDB_LOG_ERROR ( GetLog (LLDBLog::Unwind), maybe_prologue_size. takeError (),
2934+ " {1}::{0} " , __FUNCTION__ );
2935+ return pc_value;
29522936}
29532937
29542938// / Attempts to read the memory location at `task_addr_location`, producing
@@ -3139,4 +3123,30 @@ llvm::Expected<std::optional<std::string>> GetTaskName(lldb::addr_t task_addr,
31393123 return status.takeError ();
31403124}
31413125
3126+ llvm::Expected<uint64_t > FindPrologueSize (Process &process,
3127+ uint64_t load_address) {
3128+ Address addr;
3129+ Target &target = process.GetTarget ();
3130+ addr.SetLoadAddress (process.FixCodeAddress (load_address), &target);
3131+ if (!addr.IsValid ())
3132+ return llvm::createStringError (
3133+ llvm::formatv (" Invalid load address for {0:x}" , load_address));
3134+
3135+ SymbolContext sc;
3136+ bool sc_ok = addr.CalculateSymbolContext (&sc, eSymbolContextFunction |
3137+ eSymbolContextSymbol);
3138+ if (!sc_ok || (!sc.symbol && !sc.function ))
3139+ return llvm::createStringError (llvm::formatv (
3140+ " Failed to find a symbol context for address {1:x}" , load_address));
3141+
3142+ uint64_t prologue_size = sc.symbol ? sc.symbol ->GetPrologueByteSize ()
3143+ : sc.function ->GetPrologueByteSize ();
3144+
3145+ if (prologue_size == 0 )
3146+ return llvm::createStringError (llvm::formatv (
3147+ " Prologue size is 0 for function {0}" ,
3148+ sc.GetFunctionName (Mangled::NamePreference::ePreferMangled)));
3149+
3150+ return prologue_size;
3151+ }
31423152} // namespace lldb_private
0 commit comments