14#include "llvm/ADT/STLExtras.h"
15#include "llvm/TargetParser/Triple.h"
1308 const llvm::Triple::ArchType arch_type = arch.
GetTriple().getArch();
1309 const llvm::Triple::VendorType vendor_type = arch.
GetTriple().getVendor();
1311 if (vendor_type == llvm::Triple::Apple) {
1312 if ((arch_type == llvm::Triple::arm) ||
1313 (arch_type == llvm::Triple::thumb)) {
1324 llvm::ArrayRef<addr_t> args)
const {
1338 const char *reg_names[] = {
"r0",
"r1",
"r2",
"r3"};
1340 llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end();
1342 for (
size_t i = 0; i < std::size(reg_names); ++i) {
1356 size_t num_stack_regs = ae - ai;
1358 sp -= (num_stack_regs * 4);
1360 sp &= ~(16ull - 1ull);
1368 for (; ai != ae; ++ai) {
1371 ->WriteRegisterValueToMemory(reg_info, arg_pos,
1401 uint32_t new_cpsr = curr_cpsr & ~MASK_CPSR_IT_MASK;
1403 if (function_addr & 1ull)
1406 new_cpsr &= ~MASK_CPSR_T;
1408 if (new_cpsr != curr_cpsr) {
1429 uint32_t num_values = values.
GetSize();
1444 for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) {
1453 if (compiler_type) {
1454 bool is_signed =
false;
1455 size_t bit_width = 0;
1456 std::optional<uint64_t> bit_size = compiler_type.
GetBitSize(&thread);
1460 bit_width = *bit_size;
1462 bit_width = *bit_size;
1468 if (value_idx < 4) {
1477 switch (value_idx) {
1514 const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
1520 sp += arg_byte_size;
1529 bool is_armv7k =
false;
1532 const ArchSpec &arch(process_sp->GetTarget().GetArchitecture());
1547 return return_valobj_sp;
1553 return return_valobj_sp;
1562 std::optional<uint64_t> bit_width = compiler_type.
GetBitSize(&thread);
1564 return return_valobj_sp;
1566 switch (*bit_width) {
1568 return return_valobj_sp;
1581 if (r1_reg_info && r2_reg_info && r3_reg_info) {
1582 std::optional<uint64_t> byte_size =
1585 return return_valobj_sp;
1587 if (*byte_size <= r0_reg_info->byte_size + r1_reg_info->
byte_size +
1591 std::unique_ptr<DataBufferHeap> heap_data_up(
1593 const ByteOrder byte_order = process_sp->GetByteOrder();
1598 if (reg_ctx->
ReadRegister(r0_reg_info, r0_reg_value) &&
1604 heap_data_up->GetBytes() + 0,
1605 4, byte_order,
error) &&
1607 heap_data_up->GetBytes() + 4,
1608 4, byte_order,
error) &&
1610 heap_data_up->GetBytes() + 8,
1611 4, byte_order,
error) &&
1613 heap_data_up->GetBytes() + 12,
1614 4, byte_order,
error)) {
1617 process_sp->GetAddressByteSize());
1621 return return_valobj_sp;
1628 return return_valobj_sp;
1641 value.
GetScalar() = (uint64_t)raw_value;
1675 return return_valobj_sp;
1682 return return_valobj_sp;
1688 if (!new_value_sp) {
1689 error.SetErrorString(
"Empty value object for return value.");
1693 CompilerType compiler_type = new_value_sp->GetCompilerType();
1694 if (!compiler_type) {
1695 error.SetErrorString(
"Null clang type for return value.");
1699 Thread *thread = frame_sp->GetThread().get();
1707 bool set_it_simple =
false;
1712 size_t num_bytes = new_value_sp->GetData(data, data_error);
1713 if (data_error.
Fail()) {
1714 error.SetErrorStringWithFormat(
1715 "Couldn't convert return value to raw data: %s",
1720 if (num_bytes <= 8) {
1722 if (num_bytes <= 4) {
1723 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes);
1726 set_it_simple =
true;
1728 uint32_t raw_value = data.
GetMaxU32(&offset, 4);
1732 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes - offset);
1735 set_it_simple =
true;
1748 uint32_t bytes_written = 4;
1749 uint32_t raw_value = data.
GetMaxU64(&offset, 4);
1751 bytes_written <= num_bytes) {
1754 if (bytes_written <= num_bytes &&
1758 if (bytes_written <= num_bytes &&
1762 if (bytes_written <= num_bytes &&
1764 set_it_simple =
true;
1770 error.SetErrorString(
"We don't support returning longer than 64 bit "
1771 "integer values at present.");
1775 error.SetErrorString(
1776 "We don't support returning complex values at present");
1778 error.SetErrorString(
1779 "We don't support returning float values at present");
1783 error.SetErrorString(
1784 "We only support setting simple integer return types at present.");
1790 unwind_plan.
Clear();
1800 row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0);
1803 row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num,
true);
1815 unwind_plan.
Clear();
1818 uint32_t fp_reg_num =
1823 const int32_t ptr_size = 4;
1825 row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
1827 row->SetUnspecifiedRegistersAreUndefined(
true);
1829 row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2,
true);
1830 row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1,
true);
1833 unwind_plan.
SetSourceName(
"arm-apple-ios default unwind plan");
1868 const char *name = reg_info->
name;
1869 if (name[0] ==
'r') {
1872 return name[2] ==
'\0';
1879 return name[3] ==
'\0';
1886 return name[2] ==
'\0';
1888 return name[2] ==
'\0';
1890 return name[2] ==
'\0';
1894 }
else if (name[0] ==
'd') {
1897 return name[2] ==
'\0';
1907 return name[3] ==
'\0';
1927 return name[3] ==
'\0';
1939 return name[3] ==
'\0';
1948 return name[2] ==
'\0';
1953 }
else if (name[0] ==
's') {
1956 return name[2] ==
'\0';
1968 return name[3] ==
'\0';
1982 return name[2] ==
'\0';
1987 }
else if (name[0] ==
'q') {
2007 return name[2] ==
'\0';
2010 return name[2] ==
'\0';
2014 }
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)
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.