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.");
468 UNWIND_LOG(log,
"could not find a valid cfa address");
476 (permissions & ePermissionsReadable) == 0) {
479 log,
"the CFA points to a region of memory that is not readable");
483 UNWIND_LOG(log,
"could not find a row for function offset zero");
491 UNWIND_LOG(log,
"same CFA address as next frame, assuming the unwind "
492 "is looping - stopping");
506 UNWIND_LOG(log,
"could not find any symbol for this pc, or a default "
507 "unwind plan, to continue unwind.");
514 UNWIND_LOG(log,
"with pc value of {0:x}, symbol name is '{1}'",
pc,
517 UNWIND_LOG(log,
"with pc value of {0:x}, function name is '{1}'",
pc,
520 UNWIND_LOG(log,
"with pc value of {0:x}, no symbol/function name is known.",
524 bool decr_pc_and_recompute_addr_range;
528 decr_pc_and_recompute_addr_range =
true;
533 decr_pc_and_recompute_addr_range =
false;
539 decr_pc_and_recompute_addr_range =
false;
541 decr_pc_and_recompute_addr_range =
true;
547 decr_pc_and_recompute_addr_range =
false;
549 decr_pc_and_recompute_addr_range =
false;
552 decr_pc_and_recompute_addr_range =
true;
561 if (decr_pc_and_recompute_addr_range) {
563 "Backing up the pc value of {0:x} by 1 and re-doing symbol "
564 "lookup; old symbol was {1}",
581 if (decr_pc_and_recompute_addr_range &&
612 if (lang_runtime_plan_sp.get()) {
615 row_register_kind = lang_runtime_plan_sp->GetRegisterKind();
623 active_row->
Dump(active_row_strm, lang_runtime_plan_sp.get(), &
m_thread,
629 "initialized async frame current pc is {0:x} cfa is {1:x} afa "
651 if (active_row && log) {
655 UNWIND_LOG(log,
"Using fast unwind plan '{0}'",
666 if (active_row && log) {
671 UNWIND_LOG(log,
"Using full unwind plan '{0}'",
680 UNWIND_LOG(log,
"could not find unwind row for this pc");
697 UNWIND_LOG(log,
"same CFA address as next frame, assuming the unwind is "
698 "looping - stopping");
708 "initialized frame current pc is {0:x} cfa is {1:x} afa is {2:x}",
729 next_frame->GetNextFrame();
731 if (next_next_frame && next_next_frame->GetCFA(next_next_frame_cfa)) {
732 if (next_next_frame_cfa ==
m_cfa) {
762std::shared_ptr<const UnwindPlan>
767 pc_module_sp->GetObjectFile() ==
nullptr)
774 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
776 if (!func_unwinders_sp)
784 if (std::shared_ptr<const UnwindPlan> unwind_plan_sp =
785 func_unwinders_sp->GetUnwindPlanFastUnwind(
789 return unwind_plan_sp;
804std::shared_ptr<const UnwindPlan>
807 std::shared_ptr<const UnwindPlan> arch_default_unwind_plan_sp;
810 ABI *abi = process ? process->
GetABI().get() :
nullptr;
815 log,
"unable to get architectural default UnwindPlan from ABI plugin");
837 uint32_t permissions;
840 if (current_pc_addr == 0 ||
843 (permissions & ePermissionsExecutable) == 0)) {
854 pc_module_sp->GetObjectFile() ==
nullptr) {
856 return arch_default_unwind_plan_sp;
862 pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
871 if (!func_unwinders_sp) {
874 if (!pc_module_sp || !pc_module_sp->GetObjectFile() ||
876 return arch_default_unwind_plan_sp;
881 pc_module_sp->GetUnwindTable().GetEHFrameInfo()) {
882 if (std::unique_ptr<UnwindPlan> plan_up =
888 pc_module_sp->GetUnwindTable().GetArmUnwindInfo();
890 auto unwind_plan_sp =
894 return unwind_plan_sp;
898 pc_module_sp->GetUnwindTable().GetObjectFileUnwindInfo();
899 if (object_file_unwind) {
900 if (std::unique_ptr<UnwindPlan> plan_up =
905 return arch_default_unwind_plan_sp;
917 if (
auto unwind_plan_sp = platform->GetTrapHandlerUnwindPlan(
919 return unwind_plan_sp;
922 auto unwind_plan_sp =
923 func_unwinders_sp->GetEHFrameUnwindPlan(process->
GetTarget());
926 func_unwinders_sp->GetObjectFileUnwindPlan(process->
GetTarget());
927 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc) &&
928 unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolYes) {
929 return unwind_plan_sp;
947 auto unwind_plan_sp =
948 func_unwinders_sp->GetEHFrameUnwindPlan(process->
GetTarget());
951 func_unwinders_sp->GetObjectFileUnwindPlan(process->
GetTarget());
952 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc)) {
954 "frame uses {0} for full UnwindPlan because the "
955 "DynamicLoader suggested we prefer it",
956 unwind_plan_sp->GetSourceName());
957 return unwind_plan_sp;
964 auto unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
966 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(
m_current_pc)) {
967 if (unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolNo) {
979 std::shared_ptr<const UnwindPlan> call_site_unwind_plan =
980 func_unwinders_sp->GetUnwindPlanAtCallSite(process->
GetTarget(),
982 if (call_site_unwind_plan &&
983 call_site_unwind_plan.get() != unwind_plan_sp.get() &&
984 call_site_unwind_plan->GetSourceName() !=
985 unwind_plan_sp->GetSourceName()) {
993 "frame uses {0} for full UnwindPlan because this is the non-call "
994 "site unwind plan and this is a zeroth frame",
995 unwind_plan_sp->GetSourceName());
996 return unwind_plan_sp;
1004 func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry(
1006 if (unwind_plan_sp) {
1008 "frame uses {0} for full UnwindPlan because we are "
1009 "at the first instruction of a function",
1010 unwind_plan_sp->GetSourceName());
1011 return unwind_plan_sp;
1016 std::shared_ptr<const UnwindPlan> unwind_plan_sp;
1020 unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite(
1025 "frame uses {0} for full UnwindPlan because this is the "
1026 "call-site unwind plan",
1027 unwind_plan_sp->GetSourceName());
1028 return unwind_plan_sp;
1035 unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
1038 if (unwind_plan_sp &&
1039 unwind_plan_sp->GetSourcedFromCompiler() ==
eLazyBoolNo) {
1050 std::shared_ptr<const UnwindPlan> call_site_unwind_plan =
1051 func_unwinders_sp->GetUnwindPlanAtCallSite(process->
GetTarget(),
1053 if (call_site_unwind_plan &&
1054 call_site_unwind_plan.get() != unwind_plan_sp.get() &&
1055 call_site_unwind_plan->GetSourceName() !=
1056 unwind_plan_sp->GetSourceName()) {
1065 "frame uses {0} for full UnwindPlan because we failed "
1066 "to find a call-site unwind plan that would work",
1067 unwind_plan_sp->GetSourceName());
1068 return unwind_plan_sp;
1073 if (arch_default_unwind_plan_sp)
1075 "frame uses {0} for full UnwindPlan because we are "
1076 "falling back to the arch default plan",
1077 arch_default_unwind_plan_sp->GetSourceName());
1080 "Unable to find any UnwindPlan for full unwind of this frame.");
1082 return arch_default_unwind_plan_sp;
1090 return m_thread.GetRegisterContext()->GetRegisterCount();
1094 return m_thread.GetRegisterContext()->GetRegisterInfoAtIndex(reg);
1098 return m_thread.GetRegisterContext()->GetRegisterSetCount();
1102 return m_thread.GetRegisterContext()->GetRegisterSet(reg_set);
1107 return m_thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber(
1116 bool success =
false;
1118 switch (regloc.
type) {
1123 if (!other_reg_info)
1127 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1133 if (!other_reg_info)
1138 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1140 success =
GetNextFrame()->ReadRegister(other_reg_info, value);
1148 if (!other_reg_info)
1153 m_thread.GetRegisterContext()->ReadRegister(other_reg_info, value);
1155 success =
GetNextFrame()->ReadRegister(other_reg_info, value);
1159 UNWIND_LOG(log,
"read ({0})'s location", regnum);
1162 UNWIND_LOG(log,
"success {0}", success ?
"yes" :
"no");
1173 llvm_unreachable(
"FIXME debugger inferior function call unwind");
1178 success =
error.Success();
1181 llvm_unreachable(
"Unknown ConcreteRegisterLocation type.");
1192 bool success =
false;
1194 switch (regloc.
type) {
1199 m_thread.GetRegisterContext()->WriteRegister(other_reg_info, value);
1206 m_thread.GetRegisterContext()->WriteRegister(other_reg_info, value);
1208 success =
GetNextFrame()->WriteRegister(other_reg_info, value);
1216 llvm_unreachable(
"FIXME debugger inferior function call unwind");
1221 success =
error.Success();
1224 llvm_unreachable(
"Unknown ConcreteRegisterLocation type.");
1260 const std::vector<ConstString> trap_handler_names(
1261 platform_sp->GetTrapHandlerSymbolNames());
1269 const std::vector<ConstString> user_specified_trap_handler_names(
1271 for (
ConstString name : user_specified_trap_handler_names) {
1313std::optional<UnwindPlan::Row::AbstractRegisterLocation>
1328 "could not convert lldb regnum {0} ({1}) into {2} "
1329 "RegisterKind reg numbering scheme",
1343 unwindplan_regloc) &&
1347 "supplying caller's saved {0} ({1})'s location using FastUnwindPlan",
1349 return unwindplan_regloc;
1354 bool got_new_full_unwindplan =
false;
1357 got_new_full_unwindplan =
true;
1368 if (got_new_full_unwindplan && active_row && log) {
1373 UNWIND_LOG(log,
"Using full unwind plan '{0}'",
1381 "could not convert lldb regnum {0} ({1}) into "
1382 "eRegisterKindGeneric reg numbering scheme",
1386 "could not convert lldb regnum {0} ({1}) into {2} "
1387 "RegisterKind reg numbering scheme",
1392 if (regnum.
IsValid() && active_row &&
1394 unwindplan_regloc)) {
1397 "supplying caller's saved {0} ({1})'s location using {2} UnwindPlan",
1400 return unwindplan_regloc;
1429 if (pc_regnum.
IsValid() && pc_regnum == regnum) {
1436 return_address_regnum =
1441 return_address_regnum = arch_default_ra_regnum.
GetAsKind(kind);
1449 return_address_regnum);
1451 "requested caller's saved PC but this UnwindPlan uses a RA "
1452 "reg; getting {0} ({1}) instead",
1459 unwindplan_regloc)) {
1461 "supplying caller's saved {0} ({1})'s location using {2} "
1469 if (unwindplan_regloc.
IsSame())
1471 return unwindplan_regloc;
1479 return unwindplan_regloc;
1496 ABI *abi = process ? process->
GetABI().get() :
nullptr;
1505 "supplying caller's saved {0} ({1})'s location using ABI default",
1510 return unwindplan_regloc;
1517 std::string unwindplan_name;
1519 unwindplan_name +=
"via '";
1521 unwindplan_name +=
"'";
1527 return unwindplan_regloc;
1535 uint32_t lldb_regnum,
1544 regloc = iterator->second;
1545 UNWIND_LOG(log,
"supplying caller's saved {0} ({1})'s location, cached",
1552 std::optional<UnwindPlan::Row::AbstractRegisterLocation> abs_regloc =
1558 if (abs_regloc->IsUndefined()) {
1560 log,
"did not supply reg location for {0} ({1}) because it is volatile",
1568 if (abs_regloc->IsUnspecified()) {
1573 "save location for {0} ({1}) is unspecified, continue searching",
1578 if (abs_regloc->IsSame()) {
1585 "supplying caller's register {0} ({1}) from the live "
1586 "RegisterContext at frame 0",
1599 "register {0} ({1}) is marked as 'IsSame' - it is a pc or "
1600 "return address reg on a frame which does not have all "
1601 "registers available -- treat as if we have no information",
1610 "supplying caller's register {0} ({1}) value is unmodified in "
1616 if (abs_regloc->IsCFAPlusOffset()) {
1617 int offset = abs_regloc->GetOffset();
1622 "supplying caller's register {0} ({1}), value is CFA plus "
1623 "offset {2} [value is {3:x}]",
1629 if (abs_regloc->IsAtCFAPlusOffset()) {
1630 int offset = abs_regloc->GetOffset();
1636 "supplying caller's register {0} ({1}) from the stack, saved at "
1637 "CFA plus offset {2} [saved at {3:x}]",
1643 if (abs_regloc->IsAFAPlusOffset()) {
1647 int offset = abs_regloc->GetOffset();
1652 "supplying caller's register {0} ({1}), value is AFA plus "
1653 "offset {2} [value is {3:x}]",
1659 if (abs_regloc->IsAtAFAPlusOffset()) {
1663 int offset = abs_regloc->GetOffset();
1669 "supplying caller's register {0} ({1}) from the stack, saved at "
1670 "AFA plus offset {2} [saved at {3:x}]",
1676 if (abs_regloc->IsInOtherRegister()) {
1678 abs_regloc->GetRegisterNumber());
1681 "could not supply caller's {0} ({1}) location - was saved in "
1682 "another reg but couldn't convert that regnum",
1691 "supplying caller's register {0} ({1}), saved in register {2} ({3})",
1697 if (abs_regloc->IsDWARFExpression() || abs_regloc->IsAtDWARFExpression()) {
1698 DataExtractor dwarfdata(abs_regloc->GetDWARFExpressionBytes(),
1699 abs_regloc->GetDWARFExpressionLength(),
1707 llvm::Expected<Value> result =
1708 dwarfexpr.
Evaluate(&exe_ctx,
this, 0, &cfa_val,
nullptr);
1711 "DWARF expression failed to evaluate: {0}");
1714 val = result->GetScalar().ULongLong();
1715 if (abs_regloc->IsDWARFExpression()) {
1721 "supplying caller's register {0} ({1}) via DWARF expression "
1722 "(IsDWARFExpression)",
1726 regloc.
type = UnwindLLDB::ConcreteRegisterLocation::
1727 eRegisterSavedAtMemoryLocation;
1731 "supplying caller's register {0} ({1}) via DWARF expression "
1732 "(IsAtDWARFExpression)",
1738 "tried to use IsDWARFExpression or IsAtDWARFExpression for {0} "
1744 if (abs_regloc->IsConstant()) {
1748 UNWIND_LOG(log,
"supplying caller's register {0} ({1}) via constant value",
1753 UNWIND_LOG(log,
"no save location for {0} ({1}) in this stack frame",
1770 if (
Architecture *arch = process_sp->GetTarget().GetArchitecturePlugin())
1771 arch_override_plan_sp =
1774 if (arch_override_plan_sp) {
1780 log,
"Replacing Full Unwindplan with Architecture UnwindPlan, '{0}'",
1788 m_start_pc.GetLoadAddress(&process_sp->GetTarget()));
1852 if (
ABISP abi_sp = process_sp->GetABI())
1853 old_caller_pc_value = abi_sp->FixCodeAddress(old_caller_pc_value);
1872 std::shared_ptr<const UnwindPlan> original_full_unwind_plan_sp =
1891 ABISP abi_sp = process_sp ? process_sp->GetABI() :
nullptr;
1895 UNWIND_LOG(log,
"failed to get cfa with fallback unwindplan");
1916 new_caller_pc_value =
1917 process_sp->FixCodeAddress(new_caller_pc_value);
1923 UNWIND_LOG(log,
"failed to get a pc value for the caller frame with the "
1924 "fallback unwind plan");
1932 if (old_caller_pc_value == new_caller_pc_value &&
1935 UNWIND_LOG(log,
"fallback unwind plan got the same values for this frame "
1936 "CFA and caller frame pc, not using");
1943 "trying to unwind from this function with the UnwindPlan '{0}' "
1944 "because UnwindPlan '{1}' failed.",
1946 original_full_unwind_plan_sp->GetSourceName());
1978 ABISP abi_sp = process_sp ? process_sp->GetABI() :
nullptr;
1983 "failed to get cfa with fallback unwindplan");
2001 "switched unconditionally to the fallback unwindplan {0}",
2009 std::shared_ptr<const UnwindPlan> unwind_plan) {
2010 if (unwind_plan->GetUnwindPlanForSignalTrap() !=
eLazyBoolYes) {
2024 UNWIND_LOG(log,
"This frame is marked as a trap handler via its UnwindPlan");
2038 "Resetting current offset and re-doing symbol lookup; old "
2071 UNWIND_LOG(log,
"CFA value via dereferencing reg");
2074 addr_t reg_to_deref_contents;
2075 if (
ReadGPRValue(regnum_to_deref, reg_to_deref_contents)) {
2081 reg_info, reg_to_deref_contents, reg_info->
byte_size, reg_value);
2082 if (
error.Success()) {
2085 "CFA value via dereferencing reg {0} ({1}): reg has val "
2086 "{2:x}, CFA value is {3:x}",
2089 reg_to_deref_contents, address);
2094 "Tried to deref reg {0} ({1}) [{2:x}] but memory read failed.",
2097 reg_to_deref_contents);
2104 UNWIND_LOG(log,
"CFA value via register plus offset");
2111 "Got an invalid CFA register value - reg {0} ({1}), value {2:x}",
2116 address = cfa_reg_contents + fa.
GetOffset();
2119 "CFA is {0:x}: Register {1} ({2}) contents are {3:x}, offset is {4}",
2129 UNWIND_LOG(log,
"CFA value via DWARF expression");
2140 llvm::Expected<Value> result =
2141 dwarfexpr.
Evaluate(&exe_ctx,
this, 0,
nullptr,
nullptr);
2143 address = result->GetScalar().ULongLong();
2144 UNWIND_LOG(log,
"CFA value set by DWARF expression is {0:x}", address);
2147 UNWIND_LOG(log,
"Failed to set CFA value via DWARF expression: {0}",
2148 fmt_consume(result.takeError()));
2152 UNWIND_LOG(log,
"CFA value via heuristic search");
2157 const unsigned max_iterations = 256;
2158 for (
unsigned i = 0; i < max_iterations; ++i) {
2165 UNWIND_LOG(log,
"Cannot read memory at {0:x}: {1}", candidate_addr, st);
2169 uint32_t permissions;
2171 permissions & lldb::ePermissionsExecutable) {
2172 address = candidate_addr;
2173 UNWIND_LOG(log,
"Heuristically found CFA: {0:x}", address);
2182 UNWIND_LOG(log,
"CFA value set by constant is {0:x}", address);
2198 hint = abi_sp->FixCodeAddress(hint);
2200 hint += plan_offset;
2203 if (!next->m_sym_ctx.module_sp || !next->m_sym_ctx.symbol)
2205 if (
auto expected_size =
2206 next->m_sym_ctx.module_sp->GetSymbolFile()->GetParameterStackSize(
2207 *next->m_sym_ctx.symbol))
2208 hint += *expected_size;
2211 "Could not retrieve parameter size: {0}",
2212 fmt_consume(expected_size.takeError()));
2236 uint32_t regnum,
addr_t &value) {
2240 uint32_t lldb_regnum;
2242 lldb_regnum = regnum;
2243 }
else if (!
m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds(
2253 "Could not find RegisterInfo definition for lldb register number {0}",
2260 generic_regnum = regnum;
2262 m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds(
2270 if (
m_thread.GetRegisterContext()->ReadRegister(reg_info, reg_value)) {
2275 value = abi_sp->FixCodeAddress(value);
2282 bool pc_register =
false;
2297 value = abi_sp->FixCodeAddress(value);
2326 "passing along to the live register context for reg {0}",
2328 return m_thread.GetRegisterContext()->ReadRegister(reg_info, value);
2331 bool is_pc_regnum =
false;
2334 is_pc_regnum =
true;
2349 value = abi_sp->FixCodeAddress(reg_value);
2369 "passing along to the live register context for reg {0}",
2371 return m_thread.GetRegisterContext()->WriteRegister(reg_info, value);
2427 bool read_successfully =
ReadPC (start_pc);
2428 if (read_successfully)
2433 if (
ABISP abi_sp = process_sp->GetABI())
2434 start_pc = abi_sp->FixCodeAddress(start_pc);
2437 return read_successfully;
2449 bool above_trap_handler =
false;
2452 above_trap_handler =
true;
2463 pc = abi_sp->FixCodeAddress(
pc);
2466 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
@ 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