32 "Arm-specific algorithms",
80 const uint32_t cpsr = reg_ctx_sp->GetFlags(0);
85 const uint32_t J =
Bit32(cpsr, 24);
86 const uint32_t T =
Bit32(cpsr, 5);
87 const uint32_t ISETSTATE = J << 1 | T;
100 const addr_t pc = reg_ctx_sp->GetPC();
104 const uint64_t opcode = thread.GetProcess()->ReadUnsignedIntegerFromMemory(
pc, 4,
UINT64_MAX,
error);
107 const uint32_t condition =
Bits32((uint32_t)opcode, 31, 28);
117 }
else if (ISETSTATE == 1) {
119 const uint32_t ITSTATE =
Bits32(cpsr, 15, 10) << 2 |
Bits32(cpsr, 26, 25);
121 const uint32_t condition =
Bits32(ITSTATE, 7, 4);
134 bool is_alternate_isa =
false;
136 switch (addr_class) {
141 is_alternate_isa =
true;
146 if ((code_addr & 2u) || is_alternate_isa)
147 return code_addr | 1u;
153 switch (addr_class) {
159 return opcode_addr & ~(1ull);
179 std::shared_ptr<const UnwindPlan> current_unwindplan) {
181 ProcessSP process_sp = thread.GetProcess();
185 const ArchSpec arch = process_sp->GetTarget().GetArchitecture();
199 bool got_concrete_location =
false;
202 got_concrete_location =
true;
209 got_concrete_location =
true;
212 if (!got_concrete_location)
243 const uint32_t exception_return = -1U & ~0b11111U;
245 const uint32_t gprs_only = 0b10000;
247 const uint32_t lowbits = 0b01;
249 if ((callers_return_address & exception_return) != exception_return)
251 if ((callers_return_address & lowbits) != lowbits)
254 const bool fp_regs_saved = !(callers_return_address & gprs_only);
256 const RegisterKind plan_regkind = current_unwindplan->GetRegisterKind();
257 UnwindPlanSP new_plan = std::make_shared<UnwindPlan>(plan_regkind);
258 new_plan->SetSourceName(
"Arm Cortex-M exception return UnwindPlan");
260 new_plan->SetUnwindPlanValidAtAllInstructions(
eLazyBoolYes);
263 int stored_regs_size = fp_regs_saved ? 0x68 : 0x20;
267 const int gpr_reg_count = std::size(gpr_regs);
272 const int fpr_reg_count = std::size(fpr_regs);
275 std::vector<uint32_t> saved_regs;
276 for (
int i = 0; i < gpr_reg_count; i++) {
277 uint32_t regno = gpr_regs[i];
279 plan_regkind, regno);
280 saved_regs.push_back(regno);
283 for (
int i = 0; i < fpr_reg_count; i++) {
284 uint32_t regno = fpr_regs[i];
286 plan_regkind, regno);
287 saved_regs.push_back(regno);
301 uint32_t callers_xPSR =
302 process_sp->ReadUnsignedIntegerFromMemory(cfa + 0x1c, 4, 0,
error);
303 const bool align_stack = callers_xPSR & (1U << 9);
304 uint32_t callers_sp = cfa + stored_regs_size;
310 "ArchitectureArm::GetArchitectureUnwindPlan found caller return "
311 "addr of 0x%" PRIx64
", for frame with CFA 0x%" PRIx64
312 ", fp_regs_saved %d, stored_regs_size 0x%x, align stack %d",
313 callers_return_address, cfa, fp_regs_saved, stored_regs_size,
318 plan_regkind, sp_regnum);
320 const int row_count = current_unwindplan->GetRowCount();
321 for (
int i = 0; i < row_count; i++) {
324 const size_t saved_reg_count = saved_regs.size();
325 for (
size_t j = 0; j < saved_reg_count; j++) {
335 new_plan->AppendRow(row);
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
A class to represent register numbers, and able to convert between different register numbering schem...
uint32_t GetAsKind(lldb::RegisterKind kind)
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
llvm::Triple & GetTriple()
Architecture triple accessor.
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
static std::unique_ptr< Architecture > Create(const ArchSpec &arch)
lldb::addr_t GetCallableLoadAddress(lldb::addr_t load_addr, AddressClass addr_class) const override
Get load_addr as a callable code load address for this target.
ArchitectureArm()=default
static llvm::StringRef GetPluginNameStatic()
void OverrideStopInfo(Thread &thread) const override
This is currently intended to handle cases where a program stops at an instruction that won't get exe...
lldb::addr_t GetOpcodeLoadAddress(lldb::addr_t load_addr, AddressClass addr_class) const override
Get load_addr as an opcode for this target.
lldb::UnwindPlanSP GetArchitectureUnwindPlan(lldb_private::Thread &thread, lldb_private::RegisterContextUnwind *regctx, std::shared_ptr< const UnwindPlan > current_unwindplan) override
Return an UnwindPlan that allows architecture-defined rules for finding saved registers,...
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
bool GetCFA(lldb::addr_t &cfa)
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
bool ReadRegisterValueFromRegisterLocation(lldb_private::UnwindLLDB::ConcreteRegisterLocation regloc, const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value)
lldb_private::UnwindLLDB::RegisterSearchResult SavedLocationForRegister(uint32_t lldb_regnum, lldb_private::UnwindLLDB::ConcreteRegisterLocation ®loc)
uint32_t GetAsUInt32(uint32_t fail_value=UINT32_MAX, bool *success_ptr=nullptr) const
bool SetRegisterLocationToIsCFAPlusOffset(uint32_t reg_num, int32_t offset, bool can_replace)
bool SetRegisterLocationToAtCFAPlusOffset(uint32_t reg_num, int32_t offset, bool can_replace)
#define LLDB_REGNUM_GENERIC_RA
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_REGNUM
#define LLDB_REGNUM_GENERIC_PC
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.
static bool ARMConditionPassed(const uint32_t condition, const uint32_t cpsr)
static uint32_t Bits32(const uint32_t bits, const uint32_t msbit, const uint32_t lsbit)
static uint32_t Bit32(const uint32_t bits, const uint32_t bit)
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::UnwindPlan > UnwindPlanSP
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
RegisterKind
Register numbering types.
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
@ eRegisterKindLLDB
lldb's internal register numbers
@ eRegisterKindDWARF
the register numbers seen DWARF
Every register is described in detail including its name, alternate name (optional),...
An UnwindPlan::Row::AbstractRegisterLocation, combined with the register context and memory for a spe...