40#include "llvm/Support/Error.h"
41#include "llvm/Support/FormatAdapters.h"
60 return abi_sp->CallFrameAddressIsValid(cfa);
61 return cfa != 0 && cfa != 1;
73 if (name.starts_with(
"OUTLINED_FUNCTION_"))
78#define UNWIND_LOG_IMPL(LOG_FN, log, ...) \
79 LOG_FN(log, "{0}th{1}/fr{2} {3}", \
80 llvm::indent(std::min(m_frame_number, 100U)), m_thread.GetIndexID(), \
81 m_frame_number, llvm::formatv(__VA_ARGS__))
83#define UNWIND_LOG(log, ...) UNWIND_LOG_IMPL(LLDB_LOG, log, __VA_ARGS__)
85#define UNWIND_LOG_VERBOSE(log, ...) \
86 UNWIND_LOG_IMPL(LLDB_LOG_VERBOSE, log, __VA_ARGS__)
91 uint32_t frame_number,
115 m_all_registers_available = true;
120 std::shared_ptr<const UnwindPlan> unwind_plan_sp) {
137 pc_minus_one.
Slide(-1);
138 if (unwind_plan_sp->PlanValidAtAddress(pc_minus_one)) {
153 if (reg_ctx_sp.get() ==
nullptr) {
155 UNWIND_LOG(log,
"frame does not have a register context");
159 addr_t current_pc = reg_ctx_sp->GetPC();
175 current_pc = abi_sp->FixCodeAddress(current_pc);
177 std::shared_ptr<const UnwindPlan> lang_runtime_plan_sp =
180 if (lang_runtime_plan_sp.get()) {
193 UNWIND_LOG(log,
"using architectural default unwind method");
199 UNWIND_LOG(log,
"with pc value of {0:x}, symbol name is '{1}'", current_pc,
202 UNWIND_LOG(log,
"with pc value of {0:x}, function name is '{1}'",
205 UNWIND_LOG(log,
"with pc value of {0:x}, no symbol/function name is known.",
245 if (lang_runtime_plan_sp.get()) {
248 row_register_kind = lang_runtime_plan_sp->GetRegisterKind();
256 active_row->
Dump(active_row_strm, lang_runtime_plan_sp.get(), &
m_thread,
262 "initialized async frame current pc is {0:x} cfa is {1:x} afa "
277 if (active_row && log) {
286 UNWIND_LOG(log,
"could not find an unwindplan row for this frame's pc");
295 std::shared_ptr<const UnwindPlan> call_site_unwind_plan;
296 bool cfa_status =
false;
300 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
304 if (func_unwinders_sp.get() !=
nullptr)
305 call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(
308 if (call_site_unwind_plan !=
nullptr) {
314 UNWIND_LOG(log,
"could not read CFA value for first frame.");
323 "could not read CFA or AFA values for first frame, not valid.");
332 "initialized frame current pc is {0:x} cfa is {1:x} afa is {2:x} "
333 "using {3} UnwindPlan",
345 UNWIND_LOG(log,
"non-zeroth frame tests positive for IsFrameZero -- that "
346 "shouldn't happen.");
352 UNWIND_LOG(log,
"Could not get next frame, marking this frame as invalid.");
355 if (!
m_thread.GetRegisterContext()) {
357 UNWIND_LOG(log,
"Could not get register context for this thread, marking "
358 "this frame as invalid.");
372 std::shared_ptr<const UnwindPlan> lang_runtime_plan_sp =
375 if (lang_runtime_plan_sp.get()) {
390 pc = abi_sp->FixCodeAddress(
pc);
403 bool above_trap_handler =
false;
406 above_trap_handler =
true;
408 if (
pc == 0 ||
pc == 0x1) {
409 if (!above_trap_handler) {
411 UNWIND_LOG(log,
"this frame has a pc of 0x0");
416 const bool allow_section_end =
true;
427 above_trap_handler ==
false) {
428 UNWIND_LOG(log,
"using architectural default unwind method");
432 uint32_t permissions;
434 (permissions & ePermissionsExecutable) == 0) {
443 "had a pc of {0:x} which is not in executable memory but on "
444 "frame 1 -- allowing it once.",
451 UNWIND_LOG(log,
"pc is in a non-executable section of memory and this "
452 "isn't the 2nd frame in the stack walk.");
463 ->GetUnspecifiedRegistersAreUndefined())) &&
464 "Default UnwindPlan must set "
465 "UnspecifiedRegistersAreUndefined to true");
489 UNWIND_LOG(log,
"could not find a valid cfa address");
497 (permissions & ePermissionsReadable) == 0) {
500 log,
"the CFA points to a region of memory that is not readable");
504 UNWIND_LOG(log,
"could not find a row for function offset zero");
512 UNWIND_LOG(log,
"same CFA address as next frame, assuming the unwind "
513 "is looping - stopping");
527 UNWIND_LOG(log,
"could not find any symbol for this pc, or a default "
528 "unwind plan, to continue unwind.");
535 UNWIND_LOG(log,
"with pc value of {0:x}, symbol name is '{1}'",
pc,
538 UNWIND_LOG(log,
"with pc value of {0:x}, function name is '{1}'",
pc,
541 UNWIND_LOG(log,
"with pc value of {0:x}, no symbol/function name is known.",
545 bool decr_pc_and_recompute_addr_range;
549 decr_pc_and_recompute_addr_range =
true;
554 decr_pc_and_recompute_addr_range =
false;
560 decr_pc_and_recompute_addr_range =
false;
562 decr_pc_and_recompute_addr_range =
true;
568 decr_pc_and_recompute_addr_range =
false;
570 decr_pc_and_recompute_addr_range =
false;
573 decr_pc_and_recompute_addr_range =
true;
582 if (decr_pc_and_recompute_addr_range) {
584 "Backing up the pc value of {0:x} by 1 and re-doing symbol "
585 "lookup; old symbol was {1}",
602 if (decr_pc_and_recompute_addr_range &&
633 if (lang_runtime_plan_sp.get()) {
636 row_register_kind = lang_runtime_plan_sp->GetRegisterKind();
644 active_row->
Dump(active_row_strm, lang_runtime_plan_sp.get(), &
m_thread,
650 "initialized async frame current pc is {0:x} cfa is {1:x} afa "
672 if (active_row && log) {
676 UNWIND_LOG(log,
"Using fast unwind plan '{0}'",
687 if (active_row && log) {
692 UNWIND_LOG(log,
"Using full unwind plan '{0}'",
701 UNWIND_LOG(log,
"could not find unwind row for this pc");
718 UNWIND_LOG(log,
"same CFA address as next frame, assuming the unwind is "
719 "looping - stopping");
729 "initialized frame current pc is {0:x} cfa is {1:x} afa is {2:x}",
750 next_frame->GetNextFrame();
752 if (next_next_frame && next_next_frame->GetCFA(next_next_frame_cfa)) {
753 if (next_next_frame_cfa ==
m_cfa) {
783std::shared_ptr<const UnwindPlan>
788 pc_module_sp->GetObjectFile() ==
nullptr)
795 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
797 if (!func_unwinders_sp)
805 if (std::shared_ptr<const UnwindPlan> unwind_plan_sp =
806 func_unwinders_sp->GetUnwindPlanFastUnwind(
810 return unwind_plan_sp;
825std::shared_ptr<const UnwindPlan>
828 std::shared_ptr<const UnwindPlan> arch_default_unwind_plan_sp;
831 ABI *abi = process ? process->
GetABI().get() :
nullptr;
834 assert(((!arch_default_unwind_plan_sp ||
835 arch_default_unwind_plan_sp->GetRowCount() == 0 ||
836 arch_default_unwind_plan_sp->GetRowAtIndex(0)
837 ->GetUnspecifiedRegistersAreUndefined())) &&
838 "Default UnwindPlan must set "
839 "UnspecifiedRegistersAreUndefined to true");
842 log,
"unable to get architectural default UnwindPlan from ABI plugin");
864 uint32_t permissions;
867 if (current_pc_addr == 0 ||
870 (permissions & ePermissionsExecutable) == 0)) {
881 pc_module_sp->GetObjectFile() ==
nullptr) {
883 return arch_default_unwind_plan_sp;
901 "Overriding full unwind plan, using architectural default for "
904 return arch_default_unwind_plan_sp;
911 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
920 if (!func_unwinders_sp) {
923 if (!pc_module_sp || !pc_module_sp->GetObjectFile() ||
925 return arch_default_unwind_plan_sp;
930 pc_module_sp->GetUnwindTable().GetEHFrameInfo()) {
931 if (std::unique_ptr<UnwindPlan> plan_up =
937 pc_module_sp->GetUnwindTable().GetArmUnwindInfo();
939 auto unwind_plan_sp =
943 return unwind_plan_sp;
947 pc_module_sp->GetUnwindTable().GetObjectFileUnwindInfo();
948 if (object_file_unwind) {
949 if (std::unique_ptr<UnwindPlan> plan_up =
954 return arch_default_unwind_plan_sp;
966 if (
auto unwind_plan_sp = platform->GetTrapHandlerUnwindPlan(
968 return unwind_plan_sp;
971 auto unwind_plan_sp =
972 func_unwinders_sp->GetEHFrameUnwindPlan(process->
GetTarget());
975 func_unwinders_sp->GetObjectFileUnwindPlan(process->
GetTarget());
976 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc) &&
977 unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolYes) {
978 return unwind_plan_sp;
996 auto unwind_plan_sp =
997 func_unwinders_sp->GetEHFrameUnwindPlan(process->
GetTarget());
1000 func_unwinders_sp->GetObjectFileUnwindPlan(process->
GetTarget());
1001 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc)) {
1003 "frame uses {0} for full UnwindPlan because the "
1004 "DynamicLoader suggested we prefer it",
1005 unwind_plan_sp->GetSourceName());
1006 return unwind_plan_sp;
1013 auto unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
1015 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc)) {
1016 if (unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolNo) {
1028 std::shared_ptr<const UnwindPlan> call_site_unwind_plan =
1029 func_unwinders_sp->GetUnwindPlanAtCallSite(process->
GetTarget(),
1031 if (call_site_unwind_plan &&
1032 call_site_unwind_plan.get() != unwind_plan_sp.get() &&
1033 call_site_unwind_plan->GetSourceName() !=
1034 unwind_plan_sp->GetSourceName()) {
1042 "frame uses {0} for full UnwindPlan because this is the non-call "
1043 "site unwind plan and this is a zeroth frame",
1044 unwind_plan_sp->GetSourceName());
1045 return unwind_plan_sp;
1053 func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry(
1055 if (unwind_plan_sp) {
1057 "frame uses {0} for full UnwindPlan because we are "
1058 "at the first instruction of a function",
1059 unwind_plan_sp->GetSourceName());
1060 return unwind_plan_sp;
1065 std::shared_ptr<const UnwindPlan> unwind_plan_sp;
1069 unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite(
1074 "frame uses {0} for full UnwindPlan because this is the "
1075 "call-site unwind plan",
1076 unwind_plan_sp->GetSourceName());
1077 return unwind_plan_sp;
1084 unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
1087 if (unwind_plan_sp &&
1088 unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolNo) {
1099 std::shared_ptr<const UnwindPlan> call_site_unwind_plan =
1100 func_unwinders_sp->GetUnwindPlanAtCallSite(process->
GetTarget(),
1102 if (call_site_unwind_plan &&
1103 call_site_unwind_plan.get() != unwind_plan_sp.get() &&
1104 call_site_unwind_plan->GetSourceName() !=
1105 unwind_plan_sp->GetSourceName()) {
1114 "frame uses {0} for full UnwindPlan because we failed "
1115 "to find a call-site unwind plan that would work",
1116 unwind_plan_sp->GetSourceName());
1117 return unwind_plan_sp;
1122 if (arch_default_unwind_plan_sp)
1124 "frame uses {0} for full UnwindPlan because we are "
1125 "falling back to the arch default plan",
1126 arch_default_unwind_plan_sp->GetSourceName());
1129 "Unable to find any UnwindPlan for full unwind of this frame.");
1131 return arch_default_unwind_plan_sp;
1139 return m_thread.GetRegisterContext()->GetRegisterCount();
1143 return m_thread.GetRegisterContext()->GetRegisterInfoAtIndex(reg);
1147 return m_thread.GetRegisterContext()->GetRegisterSetCount();
1151 return m_thread.GetRegisterContext()->GetRegisterSet(reg_set);
1156 return m_thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber(
1165 bool success =
false;
1167 switch (regloc.
type) {
1172 if (!other_reg_info)
1176 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1182 if (!other_reg_info)
1187 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1189 success =
GetNextFrame()->ReadRegister(other_reg_info, value);
1197 if (!other_reg_info)
1202 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1204 success =
GetNextFrame()->ReadRegister(other_reg_info, value);
1208 UNWIND_LOG(log,
"read ({0})'s location", regnum);
1211 UNWIND_LOG(log,
"success {0}", success ?
"yes" :
"no");
1222 llvm_unreachable(
"FIXME debugger inferior function call unwind");
1227 success =
error.Success();
1230 llvm_unreachable(
"Unknown ConcreteRegisterLocation type.");
1241 bool success =
false;
1243 switch (regloc.
type) {
1248 m_thread.GetRegisterContext()->WriteRegister(other_reg_info, value);
1255 m_thread.GetRegisterContext()->WriteRegister(other_reg_info, value);
1257 success =
GetNextFrame()->WriteRegister(other_reg_info, value);
1265 llvm_unreachable(
"FIXME debugger inferior function call unwind");
1270 success =
error.Success();
1273 llvm_unreachable(
"Unknown ConcreteRegisterLocation type.");
1309 const std::vector<ConstString> trap_handler_names(
1310 platform_sp->GetTrapHandlerSymbolNames());
1318 const std::vector<ConstString> user_specified_trap_handler_names(
1320 for (
ConstString name : user_specified_trap_handler_names) {
1362std::optional<UnwindPlan::Row::AbstractRegisterLocation>
1377 "could not convert lldb regnum {0} ({1}) into {2} "
1378 "RegisterKind reg numbering scheme",
1392 unwindplan_regloc) &&
1396 "supplying caller's saved {0} ({1})'s location using FastUnwindPlan",
1398 return unwindplan_regloc;
1403 bool got_new_full_unwindplan =
false;
1406 got_new_full_unwindplan =
true;
1417 if (got_new_full_unwindplan && active_row && log) {
1422 UNWIND_LOG(log,
"Using full unwind plan '{0}'",
1430 "could not convert lldb regnum {0} ({1}) into "
1431 "eRegisterKindGeneric reg numbering scheme",
1435 "could not convert lldb regnum {0} ({1}) into {2} "
1436 "RegisterKind reg numbering scheme",
1441 "marking register {0} ({1}) as Undefined (volatile) in this "
1442 "stack frame because this row is UnspecifiedRegistersAreUndefined.",
1445 return unwindplan_regloc;
1450 if (regnum.
IsValid() && active_row &&
1452 unwindplan_regloc)) {
1455 "supplying caller's saved {0} ({1})'s location using {2} UnwindPlan",
1458 return unwindplan_regloc;
1487 if (pc_regnum.
IsValid() && pc_regnum == regnum) {
1494 return_address_regnum =
1499 return_address_regnum = arch_default_ra_regnum.
GetAsKind(kind);
1507 return_address_regnum);
1509 "requested caller's saved PC but this UnwindPlan uses a RA "
1510 "reg; getting {0} ({1}) instead",
1517 unwindplan_regloc)) {
1519 "supplying caller's saved {0} ({1})'s location using {2} "
1527 if (unwindplan_regloc.
IsSame())
1529 return unwindplan_regloc;
1537 return unwindplan_regloc;
1545 "marking register {0} ({1}) as Undefined (volatile) in this "
1546 "stack frame because this row is UnspecifiedRegistersAreUndefined.",
1549 return unwindplan_regloc;
1563 ABI *abi = process ? process->
GetABI().get() :
nullptr;
1572 "supplying caller's saved {0} ({1})'s location using ABI default",
1577 return unwindplan_regloc;
1584 std::string unwindplan_name;
1586 unwindplan_name +=
"via '";
1588 unwindplan_name +=
"'";
1594 return unwindplan_regloc;
1602 uint32_t lldb_regnum,
1611 regloc = iterator->second;
1612 UNWIND_LOG(log,
"supplying caller's saved {0} ({1})'s location, cached",
1619 std::optional<UnwindPlan::Row::AbstractRegisterLocation> abs_regloc =
1625 if (abs_regloc->IsUndefined()) {
1627 log,
"did not supply reg location for {0} ({1}) because it is volatile",
1635 if (abs_regloc->IsUnspecified()) {
1640 "save location for {0} ({1}) is unspecified, continue searching",
1645 if (abs_regloc->IsSame()) {
1652 "supplying caller's register {0} ({1}) from the live "
1653 "RegisterContext at frame 0",
1666 "register {0} ({1}) is marked as 'IsSame' - it is a pc or "
1667 "return address reg on a frame which does not have all "
1668 "registers available -- treat as if we have no information",
1677 "supplying caller's register {0} ({1}) value is unmodified in "
1683 if (abs_regloc->IsCFAPlusOffset()) {
1684 int offset = abs_regloc->GetOffset();
1689 "supplying caller's register {0} ({1}), value is CFA plus "
1690 "offset {2} [value is {3:x}]",
1696 if (abs_regloc->IsAtCFAPlusOffset()) {
1697 int offset = abs_regloc->GetOffset();
1703 "supplying caller's register {0} ({1}) from the stack, saved at "
1704 "CFA plus offset {2} [saved at {3:x}]",
1710 if (abs_regloc->IsAFAPlusOffset()) {
1714 int offset = abs_regloc->GetOffset();
1719 "supplying caller's register {0} ({1}), value is AFA plus "
1720 "offset {2} [value is {3:x}]",
1726 if (abs_regloc->IsAtAFAPlusOffset()) {
1730 int offset = abs_regloc->GetOffset();
1736 "supplying caller's register {0} ({1}) from the stack, saved at "
1737 "AFA plus offset {2} [saved at {3:x}]",
1743 if (abs_regloc->IsInOtherRegister()) {
1745 abs_regloc->GetRegisterNumber());
1748 "could not supply caller's {0} ({1}) location - was saved in "
1749 "another reg but couldn't convert that regnum",
1758 "supplying caller's register {0} ({1}), saved in register {2} ({3})",
1764 if (abs_regloc->IsDWARFExpression() || abs_regloc->IsAtDWARFExpression()) {
1765 DataExtractor dwarfdata(abs_regloc->GetDWARFExpressionBytes(),
1766 abs_regloc->GetDWARFExpressionLength(),
1774 llvm::Expected<Value> result =
1775 dwarfexpr.
Evaluate(&exe_ctx,
this, 0, &cfa_val,
nullptr);
1778 "DWARF expression failed to evaluate: {0}");
1781 val = result->GetScalar().ULongLong();
1782 if (abs_regloc->IsDWARFExpression()) {
1788 "supplying caller's register {0} ({1}) via DWARF expression "
1789 "(IsDWARFExpression)",
1793 regloc.
type = UnwindLLDB::ConcreteRegisterLocation::
1794 eRegisterSavedAtMemoryLocation;
1798 "supplying caller's register {0} ({1}) via DWARF expression "
1799 "(IsAtDWARFExpression)",
1805 "tried to use IsDWARFExpression or IsAtDWARFExpression for {0} "
1811 if (abs_regloc->IsConstant()) {
1815 UNWIND_LOG(log,
"supplying caller's register {0} ({1}) via constant value",
1820 UNWIND_LOG(log,
"no save location for {0} ({1}) in this stack frame",
1837 if (
Architecture *arch = process_sp->GetTarget().GetArchitecturePlugin())
1838 arch_override_plan_sp =
1841 if (arch_override_plan_sp) {
1847 log,
"Replacing Full Unwindplan with Architecture UnwindPlan, '{0}'",
1855 m_start_pc.GetLoadAddress(&process_sp->GetTarget()));
1919 if (
ABISP abi_sp = process_sp->GetABI())
1920 old_caller_pc_value = abi_sp->FixCodeAddress(old_caller_pc_value);
1939 std::shared_ptr<const UnwindPlan> original_full_unwind_plan_sp =
1958 ABISP abi_sp = process_sp ? process_sp->GetABI() :
nullptr;
1962 UNWIND_LOG(log,
"failed to get cfa with fallback unwindplan");
1983 new_caller_pc_value =
1984 process_sp->FixCodeAddress(new_caller_pc_value);
1990 UNWIND_LOG(log,
"failed to get a pc value for the caller frame with the "
1991 "fallback unwind plan");
1999 if (old_caller_pc_value == new_caller_pc_value &&
2002 UNWIND_LOG(log,
"fallback unwind plan got the same values for this frame "
2003 "CFA and caller frame pc, not using");
2010 "trying to unwind from this function with the UnwindPlan '{0}' "
2011 "because UnwindPlan '{1}' failed.",
2013 original_full_unwind_plan_sp->GetSourceName());
2045 ABISP abi_sp = process_sp ? process_sp->GetABI() :
nullptr;
2050 "failed to get cfa with fallback unwindplan");
2068 "switched unconditionally to the fallback unwindplan {0}",
2076 std::shared_ptr<const UnwindPlan> unwind_plan) {
2077 if (unwind_plan->GetUnwindPlanForSignalTrap() !=
eLazyBoolYes) {
2091 UNWIND_LOG(log,
"This frame is marked as a trap handler via its UnwindPlan");
2105 "Resetting current offset and re-doing symbol lookup; old "
2138 UNWIND_LOG(log,
"CFA value via dereferencing reg");
2141 addr_t reg_to_deref_contents;
2142 if (
ReadGPRValue(regnum_to_deref, reg_to_deref_contents)) {
2148 reg_info, reg_to_deref_contents, reg_info->
byte_size, reg_value);
2149 if (
error.Success()) {
2152 "CFA value via dereferencing reg {0} ({1}): reg has val "
2153 "{2:x}, CFA value is {3:x}",
2156 reg_to_deref_contents, address);
2161 "Tried to deref reg {0} ({1}) [{2:x}] but memory read failed.",
2164 reg_to_deref_contents);
2171 UNWIND_LOG(log,
"CFA value via register plus offset");
2178 "Got an invalid CFA register value - reg {0} ({1}), value {2:x}",
2183 address = cfa_reg_contents + fa.
GetOffset();
2186 "CFA is {0:x}: Register {1} ({2}) contents are {3:x}, offset is {4}",
2196 UNWIND_LOG(log,
"CFA value via DWARF expression");
2207 llvm::Expected<Value> result =
2208 dwarfexpr.
Evaluate(&exe_ctx,
this, 0,
nullptr,
nullptr);
2210 address = result->GetScalar().ULongLong();
2211 UNWIND_LOG(log,
"CFA value set by DWARF expression is {0:x}", address);
2215 "Failed to set CFA value via DWARF expression: {0}");
2219 UNWIND_LOG(log,
"CFA value via heuristic search");
2224 const unsigned max_iterations = 256;
2225 for (
unsigned i = 0; i < max_iterations; ++i) {
2228 llvm::Expected<lldb::addr_t> candidate =
2232 "Cannot read memory at {1:x}: {0}", candidate_addr);
2236 uint32_t permissions;
2238 permissions & lldb::ePermissionsExecutable) {
2239 address = candidate_addr;
2240 UNWIND_LOG(log,
"Heuristically found CFA: {0:x}", address);
2249 UNWIND_LOG(log,
"CFA value set by constant is {0:x}", address);
2265 hint = abi_sp->FixCodeAddress(hint);
2267 hint += plan_offset;
2270 if (!next->m_sym_ctx.module_sp || !next->m_sym_ctx.symbol)
2272 if (
auto expected_size =
2273 next->m_sym_ctx.module_sp->GetSymbolFile()->GetParameterStackSize(
2274 *next->m_sym_ctx.symbol))
2275 hint += *expected_size;
2278 "Could not retrieve parameter size: {0}");
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_ERRORV(log, error,...)
#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
llvm::Expected< lldb::addr_t > ReadPointerFromMemory(lldb::addr_t vm_addr)
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
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