40#include "llvm/Support/FormatAdapters.h"
59 return abi_sp->CallFrameAddressIsValid(cfa);
60 return cfa != 0 && cfa != 1;
63#define UNWIND_LOG_IMPL(LOG_FN, log, ...) \
64 LOG_FN(log, "{0}th{1}/fr{2} {3}", \
65 llvm::indent(std::min(m_frame_number, 100U)), m_thread.GetIndexID(), \
66 m_frame_number, llvm::formatv(__VA_ARGS__))
68#define UNWIND_LOG(log, ...) UNWIND_LOG_IMPL(LLDB_LOG, log, __VA_ARGS__)
70#define UNWIND_LOG_VERBOSE(log, ...) \
71 UNWIND_LOG_IMPL(LLDB_LOG_VERBOSE, log, __VA_ARGS__)
76 uint32_t frame_number,
100 m_all_registers_available = true;
105 std::shared_ptr<const UnwindPlan> unwind_plan_sp) {
122 pc_minus_one.
Slide(-1);
123 if (unwind_plan_sp->PlanValidAtAddress(pc_minus_one)) {
138 if (reg_ctx_sp.get() ==
nullptr) {
140 UNWIND_LOG(log,
"frame does not have a register context");
144 addr_t current_pc = reg_ctx_sp->GetPC();
160 current_pc = abi_sp->FixCodeAddress(current_pc);
162 std::shared_ptr<const UnwindPlan> lang_runtime_plan_sp =
165 if (lang_runtime_plan_sp.get()) {
178 UNWIND_LOG(log,
"using architectural default unwind method");
184 UNWIND_LOG(log,
"with pc value of {0:x}, symbol name is '{1}'", current_pc,
187 UNWIND_LOG(log,
"with pc value of {0:x}, function name is '{1}'",
190 UNWIND_LOG(log,
"with pc value of {0:x}, no symbol/function name is known.",
230 if (lang_runtime_plan_sp.get()) {
233 row_register_kind = lang_runtime_plan_sp->GetRegisterKind();
241 active_row->
Dump(active_row_strm, lang_runtime_plan_sp.get(), &
m_thread,
247 "initialized async frame current pc is {0:x} cfa is {1:x} afa "
262 if (active_row && log) {
271 UNWIND_LOG(log,
"could not find an unwindplan row for this frame's pc");
280 std::shared_ptr<const UnwindPlan> call_site_unwind_plan;
281 bool cfa_status =
false;
285 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
289 if (func_unwinders_sp.get() !=
nullptr)
290 call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(
293 if (call_site_unwind_plan !=
nullptr) {
299 UNWIND_LOG(log,
"could not read CFA value for first frame.");
308 "could not read CFA or AFA values for first frame, not valid.");
317 "initialized frame current pc is {0:x} cfa is {1:x} afa is {2:x} "
318 "using {3} UnwindPlan",
330 UNWIND_LOG(log,
"non-zeroth frame tests positive for IsFrameZero -- that "
331 "shouldn't happen.");
337 UNWIND_LOG(log,
"Could not get next frame, marking this frame as invalid.");
340 if (!
m_thread.GetRegisterContext()) {
342 UNWIND_LOG(log,
"Could not get register context for this thread, marking "
343 "this frame as invalid.");
357 std::shared_ptr<const UnwindPlan> lang_runtime_plan_sp =
360 if (lang_runtime_plan_sp.get()) {
375 pc = abi_sp->FixCodeAddress(
pc);
388 bool above_trap_handler =
false;
391 above_trap_handler =
true;
393 if (
pc == 0 ||
pc == 0x1) {
394 if (!above_trap_handler) {
396 UNWIND_LOG(log,
"this frame has a pc of 0x0");
401 const bool allow_section_end =
true;
412 above_trap_handler ==
false) {
413 UNWIND_LOG(log,
"using architectural default unwind method");
417 uint32_t permissions;
419 (permissions & ePermissionsExecutable) == 0) {
428 "had a pc of {0:x} which is not in executable memory but on "
429 "frame 1 -- allowing it once.",
436 UNWIND_LOG(log,
"pc is in a non-executable section of memory and this "
437 "isn't the 2nd frame in the stack walk.");
448 ->GetUnspecifiedRegistersAreUndefined())) &&
449 "Default UnwindPlan must set "
450 "UnspecifiedRegistersAreUndefined to true");
474 UNWIND_LOG(log,
"could not find a valid cfa address");
482 (permissions & ePermissionsReadable) == 0) {
485 log,
"the CFA points to a region of memory that is not readable");
489 UNWIND_LOG(log,
"could not find a row for function offset zero");
497 UNWIND_LOG(log,
"same CFA address as next frame, assuming the unwind "
498 "is looping - stopping");
512 UNWIND_LOG(log,
"could not find any symbol for this pc, or a default "
513 "unwind plan, to continue unwind.");
520 UNWIND_LOG(log,
"with pc value of {0:x}, symbol name is '{1}'",
pc,
523 UNWIND_LOG(log,
"with pc value of {0:x}, function name is '{1}'",
pc,
526 UNWIND_LOG(log,
"with pc value of {0:x}, no symbol/function name is known.",
530 bool decr_pc_and_recompute_addr_range;
534 decr_pc_and_recompute_addr_range =
true;
539 decr_pc_and_recompute_addr_range =
false;
545 decr_pc_and_recompute_addr_range =
false;
547 decr_pc_and_recompute_addr_range =
true;
553 decr_pc_and_recompute_addr_range =
false;
555 decr_pc_and_recompute_addr_range =
false;
558 decr_pc_and_recompute_addr_range =
true;
567 if (decr_pc_and_recompute_addr_range) {
569 "Backing up the pc value of {0:x} by 1 and re-doing symbol "
570 "lookup; old symbol was {1}",
587 if (decr_pc_and_recompute_addr_range &&
618 if (lang_runtime_plan_sp.get()) {
621 row_register_kind = lang_runtime_plan_sp->GetRegisterKind();
629 active_row->
Dump(active_row_strm, lang_runtime_plan_sp.get(), &
m_thread,
635 "initialized async frame current pc is {0:x} cfa is {1:x} afa "
657 if (active_row && log) {
661 UNWIND_LOG(log,
"Using fast unwind plan '{0}'",
672 if (active_row && log) {
677 UNWIND_LOG(log,
"Using full unwind plan '{0}'",
686 UNWIND_LOG(log,
"could not find unwind row for this pc");
703 UNWIND_LOG(log,
"same CFA address as next frame, assuming the unwind is "
704 "looping - stopping");
714 "initialized frame current pc is {0:x} cfa is {1:x} afa is {2:x}",
735 next_frame->GetNextFrame();
737 if (next_next_frame && next_next_frame->GetCFA(next_next_frame_cfa)) {
738 if (next_next_frame_cfa ==
m_cfa) {
768std::shared_ptr<const UnwindPlan>
773 pc_module_sp->GetObjectFile() ==
nullptr)
780 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
782 if (!func_unwinders_sp)
790 if (std::shared_ptr<const UnwindPlan> unwind_plan_sp =
791 func_unwinders_sp->GetUnwindPlanFastUnwind(
795 return unwind_plan_sp;
810std::shared_ptr<const UnwindPlan>
813 std::shared_ptr<const UnwindPlan> arch_default_unwind_plan_sp;
816 ABI *abi = process ? process->
GetABI().get() :
nullptr;
819 assert(((!arch_default_unwind_plan_sp ||
820 arch_default_unwind_plan_sp->GetRowCount() == 0 ||
821 arch_default_unwind_plan_sp->GetRowAtIndex(0)
822 ->GetUnspecifiedRegistersAreUndefined())) &&
823 "Default UnwindPlan must set "
824 "UnspecifiedRegistersAreUndefined to true");
827 log,
"unable to get architectural default UnwindPlan from ABI plugin");
849 uint32_t permissions;
852 if (current_pc_addr == 0 ||
855 (permissions & ePermissionsExecutable) == 0)) {
866 pc_module_sp->GetObjectFile() ==
nullptr) {
868 return arch_default_unwind_plan_sp;
874 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
883 if (!func_unwinders_sp) {
886 if (!pc_module_sp || !pc_module_sp->GetObjectFile() ||
888 return arch_default_unwind_plan_sp;
893 pc_module_sp->GetUnwindTable().GetEHFrameInfo()) {
894 if (std::unique_ptr<UnwindPlan> plan_up =
900 pc_module_sp->GetUnwindTable().GetArmUnwindInfo();
902 auto unwind_plan_sp =
906 return unwind_plan_sp;
910 pc_module_sp->GetUnwindTable().GetObjectFileUnwindInfo();
911 if (object_file_unwind) {
912 if (std::unique_ptr<UnwindPlan> plan_up =
917 return arch_default_unwind_plan_sp;
929 if (
auto unwind_plan_sp = platform->GetTrapHandlerUnwindPlan(
931 return unwind_plan_sp;
934 auto unwind_plan_sp =
935 func_unwinders_sp->GetEHFrameUnwindPlan(process->
GetTarget());
938 func_unwinders_sp->GetObjectFileUnwindPlan(process->
GetTarget());
939 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc) &&
940 unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolYes) {
941 return unwind_plan_sp;
959 auto unwind_plan_sp =
960 func_unwinders_sp->GetEHFrameUnwindPlan(process->
GetTarget());
963 func_unwinders_sp->GetObjectFileUnwindPlan(process->
GetTarget());
964 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc)) {
966 "frame uses {0} for full UnwindPlan because the "
967 "DynamicLoader suggested we prefer it",
968 unwind_plan_sp->GetSourceName());
969 return unwind_plan_sp;
976 auto unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
978 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc)) {
979 if (unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolNo) {
991 std::shared_ptr<const UnwindPlan> call_site_unwind_plan =
992 func_unwinders_sp->GetUnwindPlanAtCallSite(process->
GetTarget(),
994 if (call_site_unwind_plan &&
995 call_site_unwind_plan.get() != unwind_plan_sp.get() &&
996 call_site_unwind_plan->GetSourceName() !=
997 unwind_plan_sp->GetSourceName()) {
1005 "frame uses {0} for full UnwindPlan because this is the non-call "
1006 "site unwind plan and this is a zeroth frame",
1007 unwind_plan_sp->GetSourceName());
1008 return unwind_plan_sp;
1016 func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry(
1018 if (unwind_plan_sp) {
1020 "frame uses {0} for full UnwindPlan because we are "
1021 "at the first instruction of a function",
1022 unwind_plan_sp->GetSourceName());
1023 return unwind_plan_sp;
1028 std::shared_ptr<const UnwindPlan> unwind_plan_sp;
1032 unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite(
1037 "frame uses {0} for full UnwindPlan because this is the "
1038 "call-site unwind plan",
1039 unwind_plan_sp->GetSourceName());
1040 return unwind_plan_sp;
1047 unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
1050 if (unwind_plan_sp &&
1051 unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolNo) {
1062 std::shared_ptr<const UnwindPlan> call_site_unwind_plan =
1063 func_unwinders_sp->GetUnwindPlanAtCallSite(process->
GetTarget(),
1065 if (call_site_unwind_plan &&
1066 call_site_unwind_plan.get() != unwind_plan_sp.get() &&
1067 call_site_unwind_plan->GetSourceName() !=
1068 unwind_plan_sp->GetSourceName()) {
1077 "frame uses {0} for full UnwindPlan because we failed "
1078 "to find a call-site unwind plan that would work",
1079 unwind_plan_sp->GetSourceName());
1080 return unwind_plan_sp;
1085 if (arch_default_unwind_plan_sp)
1087 "frame uses {0} for full UnwindPlan because we are "
1088 "falling back to the arch default plan",
1089 arch_default_unwind_plan_sp->GetSourceName());
1092 "Unable to find any UnwindPlan for full unwind of this frame.");
1094 return arch_default_unwind_plan_sp;
1102 return m_thread.GetRegisterContext()->GetRegisterCount();
1106 return m_thread.GetRegisterContext()->GetRegisterInfoAtIndex(reg);
1110 return m_thread.GetRegisterContext()->GetRegisterSetCount();
1114 return m_thread.GetRegisterContext()->GetRegisterSet(reg_set);
1119 return m_thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber(
1128 bool success =
false;
1130 switch (regloc.
type) {
1135 if (!other_reg_info)
1139 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1145 if (!other_reg_info)
1150 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1152 success =
GetNextFrame()->ReadRegister(other_reg_info, value);
1160 if (!other_reg_info)
1165 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1167 success =
GetNextFrame()->ReadRegister(other_reg_info, value);
1171 UNWIND_LOG(log,
"read ({0})'s location", regnum);
1174 UNWIND_LOG(log,
"success {0}", success ?
"yes" :
"no");
1185 llvm_unreachable(
"FIXME debugger inferior function call unwind");
1190 success =
error.Success();
1193 llvm_unreachable(
"Unknown ConcreteRegisterLocation type.");
1204 bool success =
false;
1206 switch (regloc.
type) {
1211 m_thread.GetRegisterContext()->WriteRegister(other_reg_info, value);
1218 m_thread.GetRegisterContext()->WriteRegister(other_reg_info, value);
1220 success =
GetNextFrame()->WriteRegister(other_reg_info, value);
1228 llvm_unreachable(
"FIXME debugger inferior function call unwind");
1233 success =
error.Success();
1236 llvm_unreachable(
"Unknown ConcreteRegisterLocation type.");
1272 const std::vector<ConstString> trap_handler_names(
1273 platform_sp->GetTrapHandlerSymbolNames());
1281 const std::vector<ConstString> user_specified_trap_handler_names(
1283 for (
ConstString name : user_specified_trap_handler_names) {
1325std::optional<UnwindPlan::Row::AbstractRegisterLocation>
1340 "could not convert lldb regnum {0} ({1}) into {2} "
1341 "RegisterKind reg numbering scheme",
1355 unwindplan_regloc) &&
1359 "supplying caller's saved {0} ({1})'s location using FastUnwindPlan",
1361 return unwindplan_regloc;
1366 bool got_new_full_unwindplan =
false;
1369 got_new_full_unwindplan =
true;
1380 if (got_new_full_unwindplan && active_row && log) {
1385 UNWIND_LOG(log,
"Using full unwind plan '{0}'",
1393 "could not convert lldb regnum {0} ({1}) into "
1394 "eRegisterKindGeneric reg numbering scheme",
1398 "could not convert lldb regnum {0} ({1}) into {2} "
1399 "RegisterKind reg numbering scheme",
1404 "marking register {0} ({1}) as Undefined (volatile) in this "
1405 "stack frame because this row is UnspecifiedRegistersAreUndefined.",
1408 return unwindplan_regloc;
1413 if (regnum.
IsValid() && active_row &&
1415 unwindplan_regloc)) {
1418 "supplying caller's saved {0} ({1})'s location using {2} UnwindPlan",
1421 return unwindplan_regloc;
1450 if (pc_regnum.
IsValid() && pc_regnum == regnum) {
1457 return_address_regnum =
1462 return_address_regnum = arch_default_ra_regnum.
GetAsKind(kind);
1470 return_address_regnum);
1472 "requested caller's saved PC but this UnwindPlan uses a RA "
1473 "reg; getting {0} ({1}) instead",
1480 unwindplan_regloc)) {
1482 "supplying caller's saved {0} ({1})'s location using {2} "
1490 if (unwindplan_regloc.
IsSame())
1492 return unwindplan_regloc;
1500 return unwindplan_regloc;
1508 "marking register {0} ({1}) as Undefined (volatile) in this "
1509 "stack frame because this row is UnspecifiedRegistersAreUndefined.",
1512 return unwindplan_regloc;
1526 ABI *abi = process ? process->
GetABI().get() :
nullptr;
1535 "supplying caller's saved {0} ({1})'s location using ABI default",
1540 return unwindplan_regloc;
1547 std::string unwindplan_name;
1549 unwindplan_name +=
"via '";
1551 unwindplan_name +=
"'";
1557 return unwindplan_regloc;
1565 uint32_t lldb_regnum,
1574 regloc = iterator->second;
1575 UNWIND_LOG(log,
"supplying caller's saved {0} ({1})'s location, cached",
1582 std::optional<UnwindPlan::Row::AbstractRegisterLocation> abs_regloc =
1588 if (abs_regloc->IsUndefined()) {
1590 log,
"did not supply reg location for {0} ({1}) because it is volatile",
1598 if (abs_regloc->IsUnspecified()) {
1603 "save location for {0} ({1}) is unspecified, continue searching",
1608 if (abs_regloc->IsSame()) {
1615 "supplying caller's register {0} ({1}) from the live "
1616 "RegisterContext at frame 0",
1629 "register {0} ({1}) is marked as 'IsSame' - it is a pc or "
1630 "return address reg on a frame which does not have all "
1631 "registers available -- treat as if we have no information",
1640 "supplying caller's register {0} ({1}) value is unmodified in "
1646 if (abs_regloc->IsCFAPlusOffset()) {
1647 int offset = abs_regloc->GetOffset();
1652 "supplying caller's register {0} ({1}), value is CFA plus "
1653 "offset {2} [value is {3:x}]",
1659 if (abs_regloc->IsAtCFAPlusOffset()) {
1660 int offset = abs_regloc->GetOffset();
1666 "supplying caller's register {0} ({1}) from the stack, saved at "
1667 "CFA plus offset {2} [saved at {3:x}]",
1673 if (abs_regloc->IsAFAPlusOffset()) {
1677 int offset = abs_regloc->GetOffset();
1682 "supplying caller's register {0} ({1}), value is AFA plus "
1683 "offset {2} [value is {3:x}]",
1689 if (abs_regloc->IsAtAFAPlusOffset()) {
1693 int offset = abs_regloc->GetOffset();
1699 "supplying caller's register {0} ({1}) from the stack, saved at "
1700 "AFA plus offset {2} [saved at {3:x}]",
1706 if (abs_regloc->IsInOtherRegister()) {
1708 abs_regloc->GetRegisterNumber());
1711 "could not supply caller's {0} ({1}) location - was saved in "
1712 "another reg but couldn't convert that regnum",
1721 "supplying caller's register {0} ({1}), saved in register {2} ({3})",
1727 if (abs_regloc->IsDWARFExpression() || abs_regloc->IsAtDWARFExpression()) {
1728 DataExtractor dwarfdata(abs_regloc->GetDWARFExpressionBytes(),
1729 abs_regloc->GetDWARFExpressionLength(),
1737 llvm::Expected<Value> result =
1738 dwarfexpr.
Evaluate(&exe_ctx,
this, 0, &cfa_val,
nullptr);
1741 "DWARF expression failed to evaluate: {0}");
1744 val = result->GetScalar().ULongLong();
1745 if (abs_regloc->IsDWARFExpression()) {
1751 "supplying caller's register {0} ({1}) via DWARF expression "
1752 "(IsDWARFExpression)",
1756 regloc.
type = UnwindLLDB::ConcreteRegisterLocation::
1757 eRegisterSavedAtMemoryLocation;
1761 "supplying caller's register {0} ({1}) via DWARF expression "
1762 "(IsAtDWARFExpression)",
1768 "tried to use IsDWARFExpression or IsAtDWARFExpression for {0} "
1774 if (abs_regloc->IsConstant()) {
1778 UNWIND_LOG(log,
"supplying caller's register {0} ({1}) via constant value",
1783 UNWIND_LOG(log,
"no save location for {0} ({1}) in this stack frame",
1800 if (
Architecture *arch = process_sp->GetTarget().GetArchitecturePlugin())
1801 arch_override_plan_sp =
1804 if (arch_override_plan_sp) {
1810 log,
"Replacing Full Unwindplan with Architecture UnwindPlan, '{0}'",
1818 m_start_pc.GetLoadAddress(&process_sp->GetTarget()));
1882 if (
ABISP abi_sp = process_sp->GetABI())
1883 old_caller_pc_value = abi_sp->FixCodeAddress(old_caller_pc_value);
1902 std::shared_ptr<const UnwindPlan> original_full_unwind_plan_sp =
1921 ABISP abi_sp = process_sp ? process_sp->GetABI() :
nullptr;
1925 UNWIND_LOG(log,
"failed to get cfa with fallback unwindplan");
1946 new_caller_pc_value =
1947 process_sp->FixCodeAddress(new_caller_pc_value);
1953 UNWIND_LOG(log,
"failed to get a pc value for the caller frame with the "
1954 "fallback unwind plan");
1962 if (old_caller_pc_value == new_caller_pc_value &&
1965 UNWIND_LOG(log,
"fallback unwind plan got the same values for this frame "
1966 "CFA and caller frame pc, not using");
1973 "trying to unwind from this function with the UnwindPlan '{0}' "
1974 "because UnwindPlan '{1}' failed.",
1976 original_full_unwind_plan_sp->GetSourceName());
2008 ABISP abi_sp = process_sp ? process_sp->GetABI() :
nullptr;
2013 "failed to get cfa with fallback unwindplan");
2031 "switched unconditionally to the fallback unwindplan {0}",
2039 std::shared_ptr<const UnwindPlan> unwind_plan) {
2040 if (unwind_plan->GetUnwindPlanForSignalTrap() !=
eLazyBoolYes) {
2054 UNWIND_LOG(log,
"This frame is marked as a trap handler via its UnwindPlan");
2068 "Resetting current offset and re-doing symbol lookup; old "
2101 UNWIND_LOG(log,
"CFA value via dereferencing reg");
2104 addr_t reg_to_deref_contents;
2105 if (
ReadGPRValue(regnum_to_deref, reg_to_deref_contents)) {
2111 reg_info, reg_to_deref_contents, reg_info->
byte_size, reg_value);
2112 if (
error.Success()) {
2115 "CFA value via dereferencing reg {0} ({1}): reg has val "
2116 "{2:x}, CFA value is {3:x}",
2119 reg_to_deref_contents, address);
2124 "Tried to deref reg {0} ({1}) [{2:x}] but memory read failed.",
2127 reg_to_deref_contents);
2134 UNWIND_LOG(log,
"CFA value via register plus offset");
2141 "Got an invalid CFA register value - reg {0} ({1}), value {2:x}",
2146 address = cfa_reg_contents + fa.
GetOffset();
2149 "CFA is {0:x}: Register {1} ({2}) contents are {3:x}, offset is {4}",
2159 UNWIND_LOG(log,
"CFA value via DWARF expression");
2170 llvm::Expected<Value> result =
2171 dwarfexpr.
Evaluate(&exe_ctx,
this, 0,
nullptr,
nullptr);
2173 address = result->GetScalar().ULongLong();
2174 UNWIND_LOG(log,
"CFA value set by DWARF expression is {0:x}", address);
2177 UNWIND_LOG(log,
"Failed to set CFA value via DWARF expression: {0}",
2178 fmt_consume(result.takeError()));
2182 UNWIND_LOG(log,
"CFA value via heuristic search");
2187 const unsigned max_iterations = 256;
2188 for (
unsigned i = 0; i < max_iterations; ++i) {
2195 UNWIND_LOG(log,
"Cannot read memory at {0:x}: {1}", candidate_addr, st);
2199 uint32_t permissions;
2201 permissions & lldb::ePermissionsExecutable) {
2202 address = candidate_addr;
2203 UNWIND_LOG(log,
"Heuristically found CFA: {0:x}", address);
2212 UNWIND_LOG(log,
"CFA value set by constant is {0:x}", address);
2228 hint = abi_sp->FixCodeAddress(hint);
2230 hint += plan_offset;
2233 if (!next->m_sym_ctx.module_sp || !next->m_sym_ctx.symbol)
2235 if (
auto expected_size =
2236 next->m_sym_ctx.module_sp->GetSymbolFile()->GetParameterStackSize(
2237 *next->m_sym_ctx.symbol))
2238 hint += *expected_size;
2241 "Could not retrieve parameter size: {0}",
2242 fmt_consume(expected_size.takeError()));
2266 uint32_t regnum,
addr_t &value) {
2270 uint32_t lldb_regnum;
2272 lldb_regnum = regnum;
2273 }
else if (!
m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds(
2283 "Could not find RegisterInfo definition for lldb register number {0}",
2290 generic_regnum = regnum;
2292 m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds(
2300 if (
m_thread.GetRegisterContext()->ReadRegister(reg_info, reg_value)) {
2305 value = abi_sp->FixCodeAddress(value);
2312 bool pc_register =
false;
2327 value = abi_sp->FixCodeAddress(value);
2356 "passing along to the live register context for reg {0}",
2358 return m_thread.GetRegisterContext()->ReadRegister(reg_info, value);
2361 bool is_pc_regnum =
false;
2364 is_pc_regnum =
true;
2379 value = abi_sp->FixCodeAddress(reg_value);
2399 "passing along to the live register context for reg {0}",
2401 return m_thread.GetRegisterContext()->WriteRegister(reg_info, value);
2457 bool read_successfully =
ReadPC (start_pc);
2458 if (read_successfully)
2463 if (
ABISP abi_sp = process_sp->GetABI())
2464 start_pc = abi_sp->FixCodeAddress(start_pc);
2467 return read_successfully;
2479 bool above_trap_handler =
false;
2482 above_trap_handler =
true;
2493 pc = abi_sp->FixCodeAddress(
pc);
2496 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 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.
"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