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,
1373 TargetSP target_sp(thread.CalculateTarget());
1397 if (function_addr & 1ull)
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 =
1451 llvm::expectedToOptional(compiler_type.
GetBitSize(&thread));
1455 bit_width = *bit_size;
1457 bit_width = *bit_size;
1463 if (value_idx < 4) {
1472 switch (value_idx) {
1509 const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
1515 sp += arg_byte_size;
1524 bool is_armv7k =
false;
1527 const ArchSpec &arch(process_sp->GetTarget().GetArchitecture());
1542 return return_valobj_sp;
1548 return return_valobj_sp;
1557 std::optional<uint64_t> bit_width =
1558 llvm::expectedToOptional(compiler_type.
GetBitSize(&thread));
1560 return return_valobj_sp;
1562 switch (*bit_width) {
1564 return return_valobj_sp;
1577 if (r1_reg_info && r2_reg_info && r3_reg_info) {
1578 std::optional<uint64_t> byte_size =
1579 llvm::expectedToOptional(compiler_type.
GetByteSize(&thread));
1581 return return_valobj_sp;
1582 ProcessSP process_sp(thread.GetProcess());
1583 if (*byte_size <= r0_reg_info->byte_size + r1_reg_info->
byte_size +
1587 std::unique_ptr<DataBufferHeap> heap_data_up(
1589 const ByteOrder byte_order = process_sp->GetByteOrder();
1594 if (reg_ctx->
ReadRegister(r0_reg_info, r0_reg_value) &&
1600 heap_data_up->GetBytes() + 0,
1601 4, byte_order,
error) &&
1603 heap_data_up->GetBytes() + 4,
1604 4, byte_order,
error) &&
1606 heap_data_up->GetBytes() + 8,
1607 4, byte_order,
error) &&
1609 heap_data_up->GetBytes() + 12,
1610 4, byte_order,
error)) {
1613 process_sp->GetAddressByteSize());
1617 return return_valobj_sp;
1624 return return_valobj_sp;
1637 value.
GetScalar() = (uint64_t)raw_value;
1666 thread.GetRegisterContext()->ReadRegisterAsUnsigned(r0_reg_info, 0) &
1671 return return_valobj_sp;
1677 thread.GetStackFrameAtIndex(0).get(), value,
ConstString(
""));
1678 return return_valobj_sp;
1684 if (!new_value_sp) {
1689 CompilerType compiler_type = new_value_sp->GetCompilerType();
1690 if (!compiler_type) {
1695 Thread *thread = frame_sp->GetThread().get();
1703 bool set_it_simple =
false;
1708 size_t num_bytes = new_value_sp->GetData(data, data_error);
1709 if (data_error.
Fail()) {
1711 "Couldn't convert return value to raw data: %s",
1716 if (num_bytes <= 8) {
1718 if (num_bytes <= 4) {
1719 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes);
1722 set_it_simple =
true;
1724 uint32_t raw_value = data.
GetMaxU32(&offset, 4);
1728 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes - offset);
1731 set_it_simple =
true;
1744 uint32_t bytes_written = 4;
1745 uint32_t raw_value = data.
GetMaxU64(&offset, 4);
1747 bytes_written <= num_bytes) {
1750 if (bytes_written <= num_bytes &&
1754 if (bytes_written <= num_bytes &&
1758 if (bytes_written <= num_bytes &&
1760 set_it_simple =
true;
1767 "We don't support returning longer than 64 bit "
1768 "integer values at present.");
1773 "We don't support returning complex values at present");
1776 "We don't support returning float values at present");
1781 "We only support setting simple integer return types at present.");
1800 plan_sp->AppendRow(std::move(row));
1801 plan_sp->SetSourceName(
"arm at-func-entry default");
1807 uint32_t fp_reg_num =
1812 const int32_t ptr_size = 4;
1821 plan_sp->AppendRow(std::move(row));
1822 plan_sp->SetSourceName(
"arm-apple-ios default unwind plan");
1824 plan_sp->SetUnwindPlanValidAtAllInstructions(
eLazyBoolNo);
1856 const char *name = reg_info->
name;
1857 if (name[0] ==
'r') {
1860 return name[2] ==
'\0';
1867 return name[3] ==
'\0';
1874 return name[2] ==
'\0';
1876 return name[2] ==
'\0';
1878 return name[2] ==
'\0';
1882 }
else if (name[0] ==
'd') {
1885 return name[2] ==
'\0';
1895 return name[3] ==
'\0';
1915 return name[3] ==
'\0';
1927 return name[3] ==
'\0';
1936 return name[2] ==
'\0';
1941 }
else if (name[0] ==
's') {
1944 return name[2] ==
'\0';
1956 return name[3] ==
'\0';
1970 return name[2] ==
'\0';
1975 }
else if (name[0] ==
'q') {
1995 return name[2] ==
'\0';
1998 return name[2] ==
'\0';
2002 }
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[]
#define MASK_CPSR_IT_MASK
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
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
lldb::UnwindPlanSP CreateDefaultUnwindPlan() override
static llvm::StringRef GetPluginNameStatic()
lldb::UnwindPlanSP CreateFunctionEntryUnwindPlan() override
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.
llvm::Expected< 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
llvm::Expected< 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.
void SetIsRegisterPlusOffset(uint32_t reg_num, int32_t offset)
bool SetRegisterLocationToAtCFAPlusOffset(uint32_t reg_num, int32_t offset, bool can_replace)
const FAValue & GetCFAValue() const
bool SetRegisterLocationToRegister(uint32_t reg_num, uint32_t other_reg_num, bool can_replace)
void SetUnspecifiedRegistersAreUndefined(bool unspec_is_undef)
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
See comment on m_scalar to understand what GetScalar returns.
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::UnwindPlan > UnwindPlanSP
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.