40#include "llvm/Support/FormatAdapters.h"
59 return abi_sp->CallFrameAddressIsValid(cfa);
60 return cfa != 0 && cfa != 1;
72 if (name.starts_with(
"OUTLINED_FUNCTION_"))
77#define UNWIND_LOG_IMPL(LOG_FN, log, ...) \
78 LOG_FN(log, "{0}th{1}/fr{2} {3}", \
79 llvm::indent(std::min(m_frame_number, 100U)), m_thread.GetIndexID(), \
80 m_frame_number, llvm::formatv(__VA_ARGS__))
82#define UNWIND_LOG(log, ...) UNWIND_LOG_IMPL(LLDB_LOG, log, __VA_ARGS__)
84#define UNWIND_LOG_VERBOSE(log, ...) \
85 UNWIND_LOG_IMPL(LLDB_LOG_VERBOSE, log, __VA_ARGS__)
90 uint32_t frame_number,
114 m_all_registers_available = true;
119 std::shared_ptr<const UnwindPlan> unwind_plan_sp) {
136 pc_minus_one.
Slide(-1);
137 if (unwind_plan_sp->PlanValidAtAddress(pc_minus_one)) {
152 if (reg_ctx_sp.get() ==
nullptr) {
154 UNWIND_LOG(log,
"frame does not have a register context");
158 addr_t current_pc = reg_ctx_sp->GetPC();
174 current_pc = abi_sp->FixCodeAddress(current_pc);
176 std::shared_ptr<const UnwindPlan> lang_runtime_plan_sp =
179 if (lang_runtime_plan_sp.get()) {
192 UNWIND_LOG(log,
"using architectural default unwind method");
198 UNWIND_LOG(log,
"with pc value of {0:x}, symbol name is '{1}'", current_pc,
201 UNWIND_LOG(log,
"with pc value of {0:x}, function name is '{1}'",
204 UNWIND_LOG(log,
"with pc value of {0:x}, no symbol/function name is known.",
244 if (lang_runtime_plan_sp.get()) {
247 row_register_kind = lang_runtime_plan_sp->GetRegisterKind();
255 active_row->
Dump(active_row_strm, lang_runtime_plan_sp.get(), &
m_thread,
261 "initialized async frame current pc is {0:x} cfa is {1:x} afa "
276 if (active_row && log) {
285 UNWIND_LOG(log,
"could not find an unwindplan row for this frame's pc");
294 std::shared_ptr<const UnwindPlan> call_site_unwind_plan;
295 bool cfa_status =
false;
299 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
303 if (func_unwinders_sp.get() !=
nullptr)
304 call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(
307 if (call_site_unwind_plan !=
nullptr) {
313 UNWIND_LOG(log,
"could not read CFA value for first frame.");
322 "could not read CFA or AFA values for first frame, not valid.");
331 "initialized frame current pc is {0:x} cfa is {1:x} afa is {2:x} "
332 "using {3} UnwindPlan",
344 UNWIND_LOG(log,
"non-zeroth frame tests positive for IsFrameZero -- that "
345 "shouldn't happen.");
351 UNWIND_LOG(log,
"Could not get next frame, marking this frame as invalid.");
354 if (!
m_thread.GetRegisterContext()) {
356 UNWIND_LOG(log,
"Could not get register context for this thread, marking "
357 "this frame as invalid.");
371 std::shared_ptr<const UnwindPlan> lang_runtime_plan_sp =
374 if (lang_runtime_plan_sp.get()) {
389 pc = abi_sp->FixCodeAddress(
pc);
402 bool above_trap_handler =
false;
405 above_trap_handler =
true;
407 if (
pc == 0 ||
pc == 0x1) {
408 if (!above_trap_handler) {
410 UNWIND_LOG(log,
"this frame has a pc of 0x0");
415 const bool allow_section_end =
true;
426 above_trap_handler ==
false) {
427 UNWIND_LOG(log,
"using architectural default unwind method");
431 uint32_t permissions;
433 (permissions & ePermissionsExecutable) == 0) {
442 "had a pc of {0:x} which is not in executable memory but on "
443 "frame 1 -- allowing it once.",
450 UNWIND_LOG(log,
"pc is in a non-executable section of memory and this "
451 "isn't the 2nd frame in the stack walk.");
462 ->GetUnspecifiedRegistersAreUndefined())) &&
463 "Default UnwindPlan must set "
464 "UnspecifiedRegistersAreUndefined to true");
488 UNWIND_LOG(log,
"could not find a valid cfa address");
496 (permissions & ePermissionsReadable) == 0) {
499 log,
"the CFA points to a region of memory that is not readable");
503 UNWIND_LOG(log,
"could not find a row for function offset zero");
511 UNWIND_LOG(log,
"same CFA address as next frame, assuming the unwind "
512 "is looping - stopping");
526 UNWIND_LOG(log,
"could not find any symbol for this pc, or a default "
527 "unwind plan, to continue unwind.");
534 UNWIND_LOG(log,
"with pc value of {0:x}, symbol name is '{1}'",
pc,
537 UNWIND_LOG(log,
"with pc value of {0:x}, function name is '{1}'",
pc,
540 UNWIND_LOG(log,
"with pc value of {0:x}, no symbol/function name is known.",
544 bool decr_pc_and_recompute_addr_range;
548 decr_pc_and_recompute_addr_range =
true;
553 decr_pc_and_recompute_addr_range =
false;
559 decr_pc_and_recompute_addr_range =
false;
561 decr_pc_and_recompute_addr_range =
true;
567 decr_pc_and_recompute_addr_range =
false;
569 decr_pc_and_recompute_addr_range =
false;
572 decr_pc_and_recompute_addr_range =
true;
581 if (decr_pc_and_recompute_addr_range) {
583 "Backing up the pc value of {0:x} by 1 and re-doing symbol "
584 "lookup; old symbol was {1}",
601 if (decr_pc_and_recompute_addr_range &&
632 if (lang_runtime_plan_sp.get()) {
635 row_register_kind = lang_runtime_plan_sp->GetRegisterKind();
643 active_row->
Dump(active_row_strm, lang_runtime_plan_sp.get(), &
m_thread,
649 "initialized async frame current pc is {0:x} cfa is {1:x} afa "
671 if (active_row && log) {
675 UNWIND_LOG(log,
"Using fast unwind plan '{0}'",
686 if (active_row && log) {
691 UNWIND_LOG(log,
"Using full unwind plan '{0}'",
700 UNWIND_LOG(log,
"could not find unwind row for this pc");
717 UNWIND_LOG(log,
"same CFA address as next frame, assuming the unwind is "
718 "looping - stopping");
728 "initialized frame current pc is {0:x} cfa is {1:x} afa is {2:x}",
749 next_frame->GetNextFrame();
751 if (next_next_frame && next_next_frame->GetCFA(next_next_frame_cfa)) {
752 if (next_next_frame_cfa ==
m_cfa) {
782std::shared_ptr<const UnwindPlan>
787 pc_module_sp->GetObjectFile() ==
nullptr)
794 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
796 if (!func_unwinders_sp)
804 if (std::shared_ptr<const UnwindPlan> unwind_plan_sp =
805 func_unwinders_sp->GetUnwindPlanFastUnwind(
809 return unwind_plan_sp;
824std::shared_ptr<const UnwindPlan>
827 std::shared_ptr<const UnwindPlan> arch_default_unwind_plan_sp;
830 ABI *abi = process ? process->
GetABI().get() :
nullptr;
833 assert(((!arch_default_unwind_plan_sp ||
834 arch_default_unwind_plan_sp->GetRowCount() == 0 ||
835 arch_default_unwind_plan_sp->GetRowAtIndex(0)
836 ->GetUnspecifiedRegistersAreUndefined())) &&
837 "Default UnwindPlan must set "
838 "UnspecifiedRegistersAreUndefined to true");
841 log,
"unable to get architectural default UnwindPlan from ABI plugin");
863 uint32_t permissions;
866 if (current_pc_addr == 0 ||
869 (permissions & ePermissionsExecutable) == 0)) {
880 pc_module_sp->GetObjectFile() ==
nullptr) {
882 return arch_default_unwind_plan_sp;
900 "Overriding full unwind plan, using architectural default for "
903 return arch_default_unwind_plan_sp;
910 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
919 if (!func_unwinders_sp) {
922 if (!pc_module_sp || !pc_module_sp->GetObjectFile() ||
924 return arch_default_unwind_plan_sp;
929 pc_module_sp->GetUnwindTable().GetEHFrameInfo()) {
930 if (std::unique_ptr<UnwindPlan> plan_up =
936 pc_module_sp->GetUnwindTable().GetArmUnwindInfo();
938 auto unwind_plan_sp =
942 return unwind_plan_sp;
946 pc_module_sp->GetUnwindTable().GetObjectFileUnwindInfo();
947 if (object_file_unwind) {
948 if (std::unique_ptr<UnwindPlan> plan_up =
953 return arch_default_unwind_plan_sp;
965 if (
auto unwind_plan_sp = platform->GetTrapHandlerUnwindPlan(
967 return unwind_plan_sp;
970 auto unwind_plan_sp =
971 func_unwinders_sp->GetEHFrameUnwindPlan(process->
GetTarget());
974 func_unwinders_sp->GetObjectFileUnwindPlan(process->
GetTarget());
975 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc) &&
976 unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolYes) {
977 return unwind_plan_sp;
995 auto unwind_plan_sp =
996 func_unwinders_sp->GetEHFrameUnwindPlan(process->
GetTarget());
999 func_unwinders_sp->GetObjectFileUnwindPlan(process->
GetTarget());
1000 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc)) {
1002 "frame uses {0} for full UnwindPlan because the "
1003 "DynamicLoader suggested we prefer it",
1004 unwind_plan_sp->GetSourceName());
1005 return unwind_plan_sp;
1012 auto unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
1014 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc)) {
1015 if (unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolNo) {
1027 std::shared_ptr<const UnwindPlan> call_site_unwind_plan =
1028 func_unwinders_sp->GetUnwindPlanAtCallSite(process->
GetTarget(),
1030 if (call_site_unwind_plan &&
1031 call_site_unwind_plan.get() != unwind_plan_sp.get() &&
1032 call_site_unwind_plan->GetSourceName() !=
1033 unwind_plan_sp->GetSourceName()) {
1041 "frame uses {0} for full UnwindPlan because this is the non-call "
1042 "site unwind plan and this is a zeroth frame",
1043 unwind_plan_sp->GetSourceName());
1044 return unwind_plan_sp;
1052 func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry(
1054 if (unwind_plan_sp) {
1056 "frame uses {0} for full UnwindPlan because we are "
1057 "at the first instruction of a function",
1058 unwind_plan_sp->GetSourceName());
1059 return unwind_plan_sp;
1064 std::shared_ptr<const UnwindPlan> unwind_plan_sp;
1068 unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite(
1073 "frame uses {0} for full UnwindPlan because this is the "
1074 "call-site unwind plan",
1075 unwind_plan_sp->GetSourceName());
1076 return unwind_plan_sp;
1083 unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
1086 if (unwind_plan_sp &&
1087 unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolNo) {
1098 std::shared_ptr<const UnwindPlan> call_site_unwind_plan =
1099 func_unwinders_sp->GetUnwindPlanAtCallSite(process->
GetTarget(),
1101 if (call_site_unwind_plan &&
1102 call_site_unwind_plan.get() != unwind_plan_sp.get() &&
1103 call_site_unwind_plan->GetSourceName() !=
1104 unwind_plan_sp->GetSourceName()) {
1113 "frame uses {0} for full UnwindPlan because we failed "
1114 "to find a call-site unwind plan that would work",
1115 unwind_plan_sp->GetSourceName());
1116 return unwind_plan_sp;
1121 if (arch_default_unwind_plan_sp)
1123 "frame uses {0} for full UnwindPlan because we are "
1124 "falling back to the arch default plan",
1125 arch_default_unwind_plan_sp->GetSourceName());
1128 "Unable to find any UnwindPlan for full unwind of this frame.");
1130 return arch_default_unwind_plan_sp;
1138 return m_thread.GetRegisterContext()->GetRegisterCount();
1142 return m_thread.GetRegisterContext()->GetRegisterInfoAtIndex(reg);
1146 return m_thread.GetRegisterContext()->GetRegisterSetCount();
1150 return m_thread.GetRegisterContext()->GetRegisterSet(reg_set);
1155 return m_thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber(
1164 bool success =
false;
1166 switch (regloc.
type) {
1171 if (!other_reg_info)
1175 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1181 if (!other_reg_info)
1186 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1188 success =
GetNextFrame()->ReadRegister(other_reg_info, value);
1196 if (!other_reg_info)
1201 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1203 success =
GetNextFrame()->ReadRegister(other_reg_info, value);
1207 UNWIND_LOG(log,
"read ({0})'s location", regnum);
1210 UNWIND_LOG(log,
"success {0}", success ?
"yes" :
"no");
1221 llvm_unreachable(
"FIXME debugger inferior function call unwind");
1226 success =
error.Success();
1229 llvm_unreachable(
"Unknown ConcreteRegisterLocation type.");
1240 bool success =
false;
1242 switch (regloc.
type) {
1247 m_thread.GetRegisterContext()->WriteRegister(other_reg_info, value);
1254 m_thread.GetRegisterContext()->WriteRegister(other_reg_info, value);
1256 success =
GetNextFrame()->WriteRegister(other_reg_info, value);
1264 llvm_unreachable(
"FIXME debugger inferior function call unwind");
1269 success =
error.Success();
1272 llvm_unreachable(
"Unknown ConcreteRegisterLocation type.");
1308 const std::vector<ConstString> trap_handler_names(
1309 platform_sp->GetTrapHandlerSymbolNames());
1317 const std::vector<ConstString> user_specified_trap_handler_names(
1319 for (
ConstString name : user_specified_trap_handler_names) {
1361std::optional<UnwindPlan::Row::AbstractRegisterLocation>
1376 "could not convert lldb regnum {0} ({1}) into {2} "
1377 "RegisterKind reg numbering scheme",
1391 unwindplan_regloc) &&
1395 "supplying caller's saved {0} ({1})'s location using FastUnwindPlan",
1397 return unwindplan_regloc;
1402 bool got_new_full_unwindplan =
false;
1405 got_new_full_unwindplan =
true;
1416 if (got_new_full_unwindplan && active_row && log) {
1421 UNWIND_LOG(log,
"Using full unwind plan '{0}'",
1429 "could not convert lldb regnum {0} ({1}) into "
1430 "eRegisterKindGeneric reg numbering scheme",
1434 "could not convert lldb regnum {0} ({1}) into {2} "
1435 "RegisterKind reg numbering scheme",
1440 "marking register {0} ({1}) as Undefined (volatile) in this "
1441 "stack frame because this row is UnspecifiedRegistersAreUndefined.",
1444 return unwindplan_regloc;
1449 if (regnum.
IsValid() && active_row &&
1451 unwindplan_regloc)) {
1454 "supplying caller's saved {0} ({1})'s location using {2} UnwindPlan",
1457 return unwindplan_regloc;
1486 if (pc_regnum.
IsValid() && pc_regnum == regnum) {
1493 return_address_regnum =
1498 return_address_regnum = arch_default_ra_regnum.
GetAsKind(kind);
1506 return_address_regnum);
1508 "requested caller's saved PC but this UnwindPlan uses a RA "
1509 "reg; getting {0} ({1}) instead",
1516 unwindplan_regloc)) {
1518 "supplying caller's saved {0} ({1})'s location using {2} "
1526 if (unwindplan_regloc.
IsSame())
1528 return unwindplan_regloc;
1536 return unwindplan_regloc;
1544 "marking register {0} ({1}) as Undefined (volatile) in this "
1545 "stack frame because this row is UnspecifiedRegistersAreUndefined.",
1548 return unwindplan_regloc;
1562 ABI *abi = process ? process->
GetABI().get() :
nullptr;
1571 "supplying caller's saved {0} ({1})'s location using ABI default",
1576 return unwindplan_regloc;
1583 std::string unwindplan_name;
1585 unwindplan_name +=
"via '";
1587 unwindplan_name +=
"'";
1593 return unwindplan_regloc;
1601 uint32_t lldb_regnum,
1610 regloc = iterator->second;
1611 UNWIND_LOG(log,
"supplying caller's saved {0} ({1})'s location, cached",
1618 std::optional<UnwindPlan::Row::AbstractRegisterLocation> abs_regloc =
1624 if (abs_regloc->IsUndefined()) {
1626 log,
"did not supply reg location for {0} ({1}) because it is volatile",
1634 if (abs_regloc->IsUnspecified()) {
1639 "save location for {0} ({1}) is unspecified, continue searching",
1644 if (abs_regloc->IsSame()) {
1651 "supplying caller's register {0} ({1}) from the live "
1652 "RegisterContext at frame 0",
1665 "register {0} ({1}) is marked as 'IsSame' - it is a pc or "
1666 "return address reg on a frame which does not have all "
1667 "registers available -- treat as if we have no information",
1676 "supplying caller's register {0} ({1}) value is unmodified in "
1682 if (abs_regloc->IsCFAPlusOffset()) {
1683 int offset = abs_regloc->GetOffset();
1688 "supplying caller's register {0} ({1}), value is CFA plus "
1689 "offset {2} [value is {3:x}]",
1695 if (abs_regloc->IsAtCFAPlusOffset()) {
1696 int offset = abs_regloc->GetOffset();
1702 "supplying caller's register {0} ({1}) from the stack, saved at "
1703 "CFA plus offset {2} [saved at {3:x}]",
1709 if (abs_regloc->IsAFAPlusOffset()) {
1713 int offset = abs_regloc->GetOffset();
1718 "supplying caller's register {0} ({1}), value is AFA plus "
1719 "offset {2} [value is {3:x}]",
1725 if (abs_regloc->IsAtAFAPlusOffset()) {
1729 int offset = abs_regloc->GetOffset();
1735 "supplying caller's register {0} ({1}) from the stack, saved at "
1736 "AFA plus offset {2} [saved at {3:x}]",
1742 if (abs_regloc->IsInOtherRegister()) {
1744 abs_regloc->GetRegisterNumber());
1747 "could not supply caller's {0} ({1}) location - was saved in "
1748 "another reg but couldn't convert that regnum",
1757 "supplying caller's register {0} ({1}), saved in register {2} ({3})",
1763 if (abs_regloc->IsDWARFExpression() || abs_regloc->IsAtDWARFExpression()) {
1764 DataExtractor dwarfdata(abs_regloc->GetDWARFExpressionBytes(),
1765 abs_regloc->GetDWARFExpressionLength(),
1773 llvm::Expected<Value> result =
1774 dwarfexpr.
Evaluate(&exe_ctx,
this, 0, &cfa_val,
nullptr);
1777 "DWARF expression failed to evaluate: {0}");
1780 val = result->GetScalar().ULongLong();
1781 if (abs_regloc->IsDWARFExpression()) {
1787 "supplying caller's register {0} ({1}) via DWARF expression "
1788 "(IsDWARFExpression)",
1792 regloc.
type = UnwindLLDB::ConcreteRegisterLocation::
1793 eRegisterSavedAtMemoryLocation;
1797 "supplying caller's register {0} ({1}) via DWARF expression "
1798 "(IsAtDWARFExpression)",
1804 "tried to use IsDWARFExpression or IsAtDWARFExpression for {0} "
1810 if (abs_regloc->IsConstant()) {
1814 UNWIND_LOG(log,
"supplying caller's register {0} ({1}) via constant value",
1819 UNWIND_LOG(log,
"no save location for {0} ({1}) in this stack frame",
1836 if (
Architecture *arch = process_sp->GetTarget().GetArchitecturePlugin())
1837 arch_override_plan_sp =
1840 if (arch_override_plan_sp) {
1846 log,
"Replacing Full Unwindplan with Architecture UnwindPlan, '{0}'",
1854 m_start_pc.GetLoadAddress(&process_sp->GetTarget()));
1918 if (
ABISP abi_sp = process_sp->GetABI())
1919 old_caller_pc_value = abi_sp->FixCodeAddress(old_caller_pc_value);
1938 std::shared_ptr<const UnwindPlan> original_full_unwind_plan_sp =
1957 ABISP abi_sp = process_sp ? process_sp->GetABI() :
nullptr;
1961 UNWIND_LOG(log,
"failed to get cfa with fallback unwindplan");
1982 new_caller_pc_value =
1983 process_sp->FixCodeAddress(new_caller_pc_value);
1989 UNWIND_LOG(log,
"failed to get a pc value for the caller frame with the "
1990 "fallback unwind plan");
1998 if (old_caller_pc_value == new_caller_pc_value &&
2001 UNWIND_LOG(log,
"fallback unwind plan got the same values for this frame "
2002 "CFA and caller frame pc, not using");
2009 "trying to unwind from this function with the UnwindPlan '{0}' "
2010 "because UnwindPlan '{1}' failed.",
2012 original_full_unwind_plan_sp->GetSourceName());
2044 ABISP abi_sp = process_sp ? process_sp->GetABI() :
nullptr;
2049 "failed to get cfa with fallback unwindplan");
2067 "switched unconditionally to the fallback unwindplan {0}",
2075 std::shared_ptr<const UnwindPlan> unwind_plan) {
2076 if (unwind_plan->GetUnwindPlanForSignalTrap() !=
eLazyBoolYes) {
2090 UNWIND_LOG(log,
"This frame is marked as a trap handler via its UnwindPlan");
2104 "Resetting current offset and re-doing symbol lookup; old "
2137 UNWIND_LOG(log,
"CFA value via dereferencing reg");
2140 addr_t reg_to_deref_contents;
2141 if (
ReadGPRValue(regnum_to_deref, reg_to_deref_contents)) {
2147 reg_info, reg_to_deref_contents, reg_info->
byte_size, reg_value);
2148 if (
error.Success()) {
2151 "CFA value via dereferencing reg {0} ({1}): reg has val "
2152 "{2:x}, CFA value is {3:x}",
2155 reg_to_deref_contents, address);
2160 "Tried to deref reg {0} ({1}) [{2:x}] but memory read failed.",
2163 reg_to_deref_contents);
2170 UNWIND_LOG(log,
"CFA value via register plus offset");
2177 "Got an invalid CFA register value - reg {0} ({1}), value {2:x}",
2182 address = cfa_reg_contents + fa.
GetOffset();
2185 "CFA is {0:x}: Register {1} ({2}) contents are {3:x}, offset is {4}",
2195 UNWIND_LOG(log,
"CFA value via DWARF expression");
2206 llvm::Expected<Value> result =
2207 dwarfexpr.
Evaluate(&exe_ctx,
this, 0,
nullptr,
nullptr);
2209 address = result->GetScalar().ULongLong();
2210 UNWIND_LOG(log,
"CFA value set by DWARF expression is {0:x}", address);
2213 UNWIND_LOG(log,
"Failed to set CFA value via DWARF expression: {0}",
2214 fmt_consume(result.takeError()));
2218 UNWIND_LOG(log,
"CFA value via heuristic search");
2223 const unsigned max_iterations = 256;
2224 for (
unsigned i = 0; i < max_iterations; ++i) {
2231 UNWIND_LOG(log,
"Cannot read memory at {0:x}: {1}", candidate_addr, st);
2235 uint32_t permissions;
2237 permissions & lldb::ePermissionsExecutable) {
2238 address = candidate_addr;
2239 UNWIND_LOG(log,
"Heuristically found CFA: {0:x}", address);
2248 UNWIND_LOG(log,
"CFA value set by constant is {0:x}", address);
2264 hint = abi_sp->FixCodeAddress(hint);
2266 hint += plan_offset;
2269 if (!next->m_sym_ctx.module_sp || !next->m_sym_ctx.symbol)
2271 if (
auto expected_size =
2272 next->m_sym_ctx.module_sp->GetSymbolFile()->GetParameterStackSize(
2273 *next->m_sym_ctx.symbol))
2274 hint += *expected_size;
2277 "Could not retrieve parameter size: {0}",
2278 fmt_consume(expected_size.takeError()));
2302 uint32_t regnum,
addr_t &value) {
2306 uint32_t lldb_regnum;
2308 lldb_regnum = regnum;
2309 }
else if (!
m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds(
2319 "Could not find RegisterInfo definition for lldb register number {0}",
2326 generic_regnum = regnum;
2328 m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds(
2336 if (
m_thread.GetRegisterContext()->ReadRegister(reg_info, reg_value)) {
2341 value = abi_sp->FixCodeAddress(value);
2348 bool pc_register =
false;
2363 value = abi_sp->FixCodeAddress(value);
2392 "passing along to the live register context for reg {0}",
2394 return m_thread.GetRegisterContext()->ReadRegister(reg_info, value);
2397 bool is_pc_regnum =
false;
2400 is_pc_regnum =
true;
2415 value = abi_sp->FixCodeAddress(reg_value);
2435 "passing along to the live register context for reg {0}",
2437 return m_thread.GetRegisterContext()->WriteRegister(reg_info, value);
2493 bool read_successfully =
ReadPC (start_pc);
2494 if (read_successfully)
2499 if (
ABISP abi_sp = process_sp->GetABI())
2500 start_pc = abi_sp->FixCodeAddress(start_pc);
2503 return read_successfully;
2515 bool above_trap_handler =
false;
2518 above_trap_handler =
true;
2529 pc = abi_sp->FixCodeAddress(
pc);
2532 above_trap_handler ==
false && (
pc == 0 ||
pc == 1));
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG_ERROR(log, error,...)
static ConstString GetSymbolOrFunctionName(const SymbolContext &sym_ctx)
#define UNWIND_LOG_VERBOSE(log,...)
static bool IsClangOutlinedFunction(const SymbolContext &sym_ctx)
Identify a clang outlined function by symbol name.
static bool CallFrameAddressIsValid(ABISP abi_sp, lldb::addr_t cfa)
#define UNWIND_LOG(log,...)
A class to represent register numbers, and able to convert between different register numbering schem...
uint32_t GetAsKind(lldb::RegisterKind kind)
lldb::RegisterKind GetRegisterKind() const
uint32_t GetRegisterNumber() const
void init(lldb_private::Thread &thread, lldb::RegisterKind kind, uint32_t num)
virtual lldb::UnwindPlanSP CreateDefaultUnwindPlan()=0
virtual bool GetFallbackRegisterLocation(const RegisterInfo *reg_info, UnwindPlan::Row::AbstractRegisterLocation &unwind_regloc)
virtual lldb::UnwindPlanSP CreateFunctionEntryUnwindPlan()=0
A section + offset based address class.
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
bool Slide(int64_t offset)
bool ResolveFunctionScope(lldb_private::SymbolContext &sym_ctx)
Resolve this address to its containing function.
An architecture specification class.
bool GetUnwindPlan(Target &target, const Address &addr, UnwindPlan &unwind_plan)
virtual std::unique_ptr< UnwindPlan > GetUnwindPlan(llvm::ArrayRef< AddressRange > ranges, const Address &addr)=0
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
llvm::Expected< Value > Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::addr_t func_load_addr, const Value *initial_value_ptr, const Value *object_address_ptr) const
DWARFExpression * GetMutableExpressionAtAddress(lldb::addr_t func_load_addr=LLDB_INVALID_ADDRESS, lldb::addr_t load_addr=0)
void SetRegisterKind(lldb::RegisterKind reg_kind)
Set the call-frame-info style register kind.
virtual bool AlwaysRelyOnEHUnwindInfo(SymbolContext &sym_ctx)
Ask if the eh_frame information for the given SymbolContext should be relied on even when it's the fi...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Target * GetTargetPtr() const
Returns a pointer to the target object.
Target & GetTargetRef() const
Returns a reference to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
ConstString GetName() const
static lldb::UnwindPlanSP GetRuntimeUnwindPlan(lldb_private::Thread &thread, lldb_private::RegisterContext *regctx, bool &behaves_like_zeroth_frame)
A language runtime may be able to provide a special UnwindPlan for the frame represented by the regis...
A plug-in interface definition class for debugging a process.
virtual bool GetLoadAddressPermissions(lldb::addr_t load_addr, uint32_t &permissions)
Attempt to get the attributes for a region of memory in the process.
lldb::ByteOrder GetByteOrder() const
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
uint32_t GetAddressByteSize() const
virtual DynamicLoader * GetDynamicLoader()
Get the dynamic loader plug-in for this process.
const lldb::ABISP & GetABI()
Target & GetTarget()
Get the target object pointer for this module.
std::optional< UnwindPlan::Row::AbstractRegisterLocation > GetAbstractRegisterLocation(uint32_t lldb_regnum, lldb::RegisterKind &kind)
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
bool CheckIfLoopingStack()
bool GetCFA(lldb::addr_t &cfa)
void InitializeZerothFrame()
lldb_private::Thread & m_thread
void PropagateTrapHandlerFlagFromUnwindPlan(std::shared_ptr< const UnwindPlan > unwind_plan)
Check if the given unwind plan indicates a signal trap handler, and update frame type and symbol cont...
lldb_private::Address m_start_pc
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
void InitializeNonZerothFrame()
bool ReadRegisterValueFromRegisterLocation(lldb_private::UnwindLLDB::ConcreteRegisterLocation regloc, const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value)
const lldb_private::RegisterSet * GetRegisterSet(size_t reg_set) override
bool m_behaves_like_zeroth_frame
std::shared_ptr< RegisterContextUnwind > SharedPtr
bool ReadFrameAddress(lldb::RegisterKind register_kind, const UnwindPlan::Row::FAValue &fa, lldb::addr_t &address)
bool ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
void InvalidateAllRegisters() override
lldb::UnwindPlanSP TryAdoptArchitectureUnwindPlan()
RegisterContextUnwind(lldb_private::Thread &thread, const SharedPtr &next_frame, lldb_private::SymbolContext &sym_ctx, uint32_t frame_number, lldb_private::UnwindLLDB &unwind_lldb)
std::shared_ptr< const UnwindPlan > GetFastUnwindPlanForFrame()
std::shared_ptr< const UnwindPlan > m_fast_unwind_plan_sp
std::map< uint32_t, lldb_private::UnwindLLDB::ConcreteRegisterLocation > m_registers
std::shared_ptr< const UnwindPlan > GetFullUnwindPlanForFrame()
bool ReadPC(lldb::addr_t &start_pc)
bool ForceSwitchToFallbackUnwindPlan()
Switch to the fallback unwind plan unconditionally without any safety checks that it is providing bet...
size_t GetRegisterSetCount() override
lldb_private::UnwindLLDB::RegisterSearchResult SavedLocationForRegister(uint32_t lldb_regnum, lldb_private::UnwindLLDB::ConcreteRegisterLocation ®loc)
bool IsTrapHandlerFrame() const
bool ReadGPRValue(lldb::RegisterKind register_kind, uint32_t regnum, lldb::addr_t &value)
lldb_private::UnwindLLDB & m_parent_unwind
bool WriteRegisterValueToRegisterLocation(lldb_private::UnwindLLDB::ConcreteRegisterLocation regloc, const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value)
bool m_all_registers_available
bool TryFallbackUnwindPlan()
If the unwind has to the caller frame has failed, try something else.
std::optional< int > m_current_offset
How far into the function we've executed.
lldb_private::Address m_current_pc
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
lldb::addr_t GetReturnAddressHint(int32_t plan_offset)
std::optional< int > m_current_offset_backed_up_one
bool IsTrapHandlerSymbol(lldb_private::Process *process, const lldb_private::SymbolContext &m_sym_ctx) const
Determines if a SymbolContext is a trap handler or not.
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override
Convert from a given register numbering scheme to the lldb register numbering scheme.
bool IsUnwindPlanValidForCurrentPC(std::shared_ptr< const UnwindPlan > unwind_plan_sp)
std::shared_ptr< const UnwindPlan > m_fallback_unwind_plan_sp
lldb_private::SymbolContext & m_sym_ctx
bool BehavesLikeZerothFrame() const override
Indicates that this frame is currently executing code, that the PC value is not a return-pc but an ac...
SharedPtr GetPrevFrame() const
std::shared_ptr< const UnwindPlan > m_full_unwind_plan_sp
SharedPtr GetNextFrame() const
size_t GetRegisterCount() override
bool GetStartPC(lldb::addr_t &start_pc)
virtual Status ReadRegisterValueFromMemory(const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, uint32_t src_len, RegisterValue ®_value)
RegisterContext(Thread &thread, uint32_t concrete_frame_idx)
lldb::TargetSP CalculateTarget() override
virtual Status WriteRegisterValueToMemory(const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue ®_value)
bool SetUInt(uint64_t uint, uint32_t byte_size)
uint64_t GetAsUInt64(uint64_t fail_value=UINT64_MAX, bool *success_ptr=nullptr) const
RegisterValue::Type GetType() const
bool Fail() const
Test for error condition.
llvm::StringRef GetString() const
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
Symbol * symbol
The Symbol for a given query.
ConstString GetName() const
lldb::PlatformSP GetPlatform()
const ArchSpec & GetArchitecture() const
void SetInRegister(uint32_t reg_num)
int GetDWARFExpressionLength() const
const uint8_t * GetDWARFExpressionBytes() const
int32_t GetOffset() const
ValueType GetValueType() const
uint64_t GetConstant() const
uint32_t GetRegisterNumber() const
const FAValue & GetAFAValue() const
const FAValue & GetCFAValue() const
bool GetRegisterInfo(uint32_t reg_num, AbstractRegisterLocation ®ister_location) const
void Dump(Stream &s, const UnwindPlan *unwind_plan, Thread *thread, lldb::addr_t base_addr) const
bool GetUnspecifiedRegistersAreUndefined() const
@ LoadAddress
A load address value.
void SetValueType(ValueType value_type)
#define LLDB_REGNUM_GENERIC_RA
#define LLDB_REGNUM_GENERIC_SP
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_REGNUM
#define LLDB_REGNUM_GENERIC_PC
#define LLDB_REGNUM_GENERIC_FP
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::Platform > PlatformSP
std::shared_ptr< lldb_private::FuncUnwinders > FuncUnwindersSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::UnwindPlan > UnwindPlanSP
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
std::shared_ptr< lldb_private::Module > ModuleSP
RegisterKind
Register numbering types.
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
@ eRegisterKindLLDB
lldb's internal register numbers
Every register is described in detail including its name, alternate name (optional),...
uint32_t byte_size
Size in bytes of the register.
uint32_t kinds[lldb::kNumRegisterKinds]
Holds all of the various register numbers for all register kinds.
Registers are grouped into register sets.
An UnwindPlan::Row::AbstractRegisterLocation, combined with the register context and memory for a spe...
union lldb_private::UnwindLLDB::ConcreteRegisterLocation::@112231307016025255352221255122100277032134020214 location
@ eRegisterSavedAtHostMemoryLocation
@ eRegisterIsRegisterPlusOffset
@ eRegisterSavedAtMemoryLocation
@ eRegisterInLiveRegisterContext
lldb::addr_t target_memory_location
struct lldb_private::UnwindLLDB::ConcreteRegisterLocation::@112231307016025255352221255122100277032134020214::@342316333304072166237122265045271116073153235374 reg_plus_offset