14#include "llvm/ADT/STLExtras.h"
15#include "llvm/TargetParser/Triple.h"
1302 const llvm::Triple::ArchType arch_type = arch.
GetTriple().getArch();
1303 const llvm::Triple::VendorType vendor_type = arch.
GetTriple().getVendor();
1305 if (vendor_type == llvm::Triple::Apple) {
1306 if ((arch_type == llvm::Triple::arm) ||
1307 (arch_type == llvm::Triple::thumb)) {
1318 llvm::ArrayRef<addr_t> args)
const {
1332 const char *reg_names[] = {
"r0",
"r1",
"r2",
"r3"};
1334 llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end();
1336 for (
size_t i = 0; i < std::size(reg_names); ++i) {
1350 size_t num_stack_regs = ae - ai;
1352 sp -= (num_stack_regs * 4);
1354 sp &= ~(16ull - 1ull);
1362 for (; ai != ae; ++ai) {
1365 ->WriteRegisterValueToMemory(reg_info, arg_pos,
1395 uint32_t new_cpsr = curr_cpsr & ~MASK_CPSR_IT_MASK;
1397 if (function_addr & 1ull)
1400 new_cpsr &= ~MASK_CPSR_T;
1402 if (new_cpsr != curr_cpsr) {
1423 uint32_t num_values = values.
GetSize();
1438 for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) {
1447 if (compiler_type) {
1448 bool is_signed =
false;
1449 size_t bit_width = 0;
1450 std::optional<uint64_t> bit_size = compiler_type.
GetBitSize(&thread);
1454 bit_width = *bit_size;
1456 bit_width = *bit_size;
1462 if (value_idx < 4) {
1471 switch (value_idx) {
1508 const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
1514 sp += arg_byte_size;
1523 bool is_armv7k =
false;
1526 const ArchSpec &arch(process_sp->GetTarget().GetArchitecture());
1541 return return_valobj_sp;
1547 return return_valobj_sp;
1556 std::optional<uint64_t> bit_width = compiler_type.
GetBitSize(&thread);
1558 return return_valobj_sp;
1560 switch (*bit_width) {
1562 return return_valobj_sp;
1575 if (r1_reg_info && r2_reg_info && r3_reg_info) {
1576 std::optional<uint64_t> byte_size =
1579 return return_valobj_sp;
1581 if (*byte_size <= r0_reg_info->byte_size + r1_reg_info->
byte_size +
1585 std::unique_ptr<DataBufferHeap> heap_data_up(
1587 const ByteOrder byte_order = process_sp->GetByteOrder();
1592 if (reg_ctx->
ReadRegister(r0_reg_info, r0_reg_value) &&
1598 heap_data_up->GetBytes() + 0,
1599 4, byte_order,
error) &&
1601 heap_data_up->GetBytes() + 4,
1602 4, byte_order,
error) &&
1604 heap_data_up->GetBytes() + 8,
1605 4, byte_order,
error) &&
1607 heap_data_up->GetBytes() + 12,
1608 4, byte_order,
error)) {
1611 process_sp->GetAddressByteSize());
1615 return return_valobj_sp;
1622 return return_valobj_sp;
1635 value.
GetScalar() = (uint64_t)raw_value;
1669 return return_valobj_sp;
1676 return return_valobj_sp;
1682 if (!new_value_sp) {
1687 CompilerType compiler_type = new_value_sp->GetCompilerType();
1688 if (!compiler_type) {
1693 Thread *thread = frame_sp->GetThread().get();
1701 bool set_it_simple =
false;
1706 size_t num_bytes = new_value_sp->GetData(data, data_error);
1707 if (data_error.
Fail()) {
1709 "Couldn't convert return value to raw data: %s",
1714 if (num_bytes <= 8) {
1716 if (num_bytes <= 4) {
1717 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes);
1720 set_it_simple =
true;
1722 uint32_t raw_value = data.
GetMaxU32(&offset, 4);
1726 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes - offset);
1729 set_it_simple =
true;
1742 uint32_t bytes_written = 4;
1743 uint32_t raw_value = data.
GetMaxU64(&offset, 4);
1745 bytes_written <= num_bytes) {
1748 if (bytes_written <= num_bytes &&
1752 if (bytes_written <= num_bytes &&
1756 if (bytes_written <= num_bytes &&
1758 set_it_simple =
true;
1765 "We don't support returning longer than 64 bit "
1766 "integer values at present.");
1771 "We don't support returning complex values at present");
1774 "We don't support returning float values at present");
1779 "We only support setting simple integer return types at present.");
1785 unwind_plan.
Clear();
1795 row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0);
1798 row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num,
true);
1810 unwind_plan.
Clear();
1813 uint32_t fp_reg_num =
1818 const int32_t ptr_size = 4;
1820 row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
1822 row->SetUnspecifiedRegistersAreUndefined(
true);
1824 row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2,
true);
1825 row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1,
true);
1828 unwind_plan.
SetSourceName(
"arm-apple-ios default unwind plan");
1863 const char *name = reg_info->
name;
1864 if (name[0] ==
'r') {
1867 return name[2] ==
'\0';
1874 return name[3] ==
'\0';
1881 return name[2] ==
'\0';
1883 return name[2] ==
'\0';
1885 return name[2] ==
'\0';
1889 }
else if (name[0] ==
'd') {
1892 return name[2] ==
'\0';
1902 return name[3] ==
'\0';
1922 return name[3] ==
'\0';
1934 return name[3] ==
'\0';
1943 return name[2] ==
'\0';
1948 }
else if (name[0] ==
's') {
1951 return name[2] ==
'\0';
1963 return name[3] ==
'\0';
1977 return name[2] ==
'\0';
1982 }
else if (name[0] ==
'q') {
2002 return name[2] ==
'\0';
2005 return name[2] ==
'\0';
2009 }
else if (name[0] ==
's' && name[1] ==
'p' && name[2] ==
'\0')
static const uint32_t k_num_register_infos
static const RegisterInfo g_register_infos[]
static llvm::raw_ostream & error(Stream &strm)
lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const override
lldb_private::Status SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override
bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
bool CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
size_t GetRedZoneSize() const override
bool IsArmv7kProcess() const
const lldb_private::RegisterInfo * GetRegisterInfoArray(uint32_t &count) override
bool GetArgumentValues(lldb_private::Thread &thread, lldb_private::ValueList &values) const override
bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, lldb::addr_t func_addr, lldb::addr_t returnAddress, llvm::ArrayRef< lldb::addr_t > args) const override
bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override
static llvm::StringRef GetPluginNameStatic()
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch)
static std::unique_ptr< llvm::MCRegisterInfo > MakeMCRegisterInfo(const ArchSpec &arch)
Utility function to construct a MCRegisterInfo using the ArchSpec triple.
lldb::ProcessSP GetProcessSP() const
Request to get a Process shared pointer.
A section + offset based address class.
lldb::addr_t GetCallableLoadAddress(Target *target, bool is_indirect=false) const
Get the load address as a callable code load address.
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
Generic representation of a type in a programming language.
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
bool IsFloatingPointType(uint32_t &count, bool &is_complex) const
bool IsIntegerOrEnumerationType(bool &is_signed) const
std::optional< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
bool IsPointerOrReferenceType(CompilerType *pointee_type=nullptr) const
bool IsPointerType(CompilerType *pointee_type=nullptr) const
A uniqued constant string class.
A subclass of DataBuffer that stores a data buffer on the heap.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Process & GetProcessRef() const
Returns a reference to the process object.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
size_t ReadScalarIntegerFromMemory(lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Status &error)
uint32_t GetAddressByteSize() const
virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num)
Convert from a given register numbering scheme to the lldb register numbering scheme.
uint64_t ReadRegisterAsUnsigned(uint32_t reg, uint64_t fail_value)
virtual const RegisterInfo * GetRegisterInfoAtIndex(size_t reg)=0
uint64_t GetSP(uint64_t fail_value=LLDB_INVALID_ADDRESS)
virtual bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value)=0
const RegisterInfo * GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num)
bool WriteRegisterFromUnsigned(uint32_t reg, uint64_t uval)
const RegisterInfo * GetRegisterInfoByName(llvm::StringRef reg_name, uint32_t start_idx=0)
virtual bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value)=0
bool SignExtend(uint32_t sign_bitpos)
uint32_t GetAsMemoryData(const RegisterInfo ®_info, void *dst, uint32_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
bool GetScalarValue(Scalar &scalar) const
void SetUInt32(uint32_t uint, Type t=eTypeUInt32)
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
bool Fail() const
Test for error condition.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
virtual lldb::RegisterContextSP GetRegisterContext()=0
lldb::TargetSP CalculateTarget() override
lldb::ProcessSP GetProcess() const
void SetUnwindPlanForSignalTrap(lldb_private::LazyBool is_for_signal_trap)
void SetRegisterKind(lldb::RegisterKind kind)
void AppendRow(const RowSP &row_sp)
std::shared_ptr< Row > RowSP
void SetSourcedFromCompiler(lldb_private::LazyBool from_compiler)
void SetSourceName(const char *)
void SetUnwindPlanValidAtAllInstructions(lldb_private::LazyBool valid_at_all_insn)
Value * GetValueAtIndex(size_t idx)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
const Scalar & GetScalar() const
void SetCompilerType(const CompilerType &compiler_type)
const CompilerType & GetCompilerType()
#define LLDB_REGNUM_GENERIC_RA
#define LLDB_REGNUM_GENERIC_SP
#define LLDB_REGNUM_GENERIC_ARG4
#define LLDB_REGNUM_GENERIC_ARG3
#define LLDB_REGNUM_GENERIC_ARG1
#define LLDB_REGNUM_GENERIC_FLAGS
#define LLDB_INVALID_REGNUM
#define LLDB_REGNUM_GENERIC_ARG2
#define LLDB_REGNUM_GENERIC_PC
#define LLDB_REGNUM_GENERIC_FP
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Process > ProcessSP
@ eEncodingUint
unsigned integer
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::Target > TargetSP
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
@ eRegisterKindDWARF
the register numbers seen DWARF
Every register is described in detail including its name, alternate name (optional),...
uint32_t byte_size
Size in bytes of the register.
const char * name
Name of this register, can't be NULL.