14#include "llvm/ADT/STLExtras.h"
15#include "llvm/TargetParser/Triple.h"
1305 const llvm::Triple::ArchType arch_type = arch.
GetTriple().getArch();
1306 const llvm::Triple::VendorType vendor_type = arch.
GetTriple().getVendor();
1308 if (vendor_type != llvm::Triple::Apple) {
1309 if ((arch_type == llvm::Triple::arm) ||
1310 (arch_type == llvm::Triple::thumb)) {
1321 llvm::ArrayRef<addr_t> args)
const {
1335 const uint8_t reg_names[] = {
1339 llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end();
1341 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 &= ~(8ull - 1ull);
1368 for (; ai != ae; ++ai) {
1371 ->WriteRegisterValueToMemory(reg_info, arg_pos,
1406 uint32_t new_cpsr = curr_cpsr & ~MASK_CPSR_IT_MASK;
1408 if (function_addr & 1ull)
1411 new_cpsr &= ~MASK_CPSR_T;
1413 if (new_cpsr != curr_cpsr) {
1426 uint32_t num_values = values.
GetSize();
1441 for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) {
1450 if (compiler_type) {
1451 bool is_signed =
false;
1452 size_t bit_width = 0;
1455 if (std::optional<uint64_t> size = compiler_type.
GetBitSize(&thread))
1463 if (value_idx < 4) {
1489 const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
1495 sp += arg_byte_size;
1505 size_t byte_size,
Value &value) {
1526 const ArchSpec &arch(process_sp->GetTarget().GetArchitecture());
1540 return return_valobj_sp;
1548 return return_valobj_sp;
1552 uint32_t float_count;
1553 bool is_vfp_candidate =
false;
1554 uint8_t vfp_count = 0;
1555 uint8_t vfp_byte_size = 0;
1562 std::optional<uint64_t> bit_width = compiler_type.
GetBitSize(&thread);
1563 std::optional<uint64_t> byte_size = compiler_type.
GetByteSize(&thread);
1564 if (!bit_width || !byte_size)
1565 return return_valobj_sp;
1568 switch (*bit_width) {
1570 return return_valobj_sp;
1582 value.
GetScalar() = (uint64_t)raw_value;
1615 if (
IsArmHardFloat(thread) && (*byte_size == 8 || *byte_size == 16)) {
1616 is_vfp_candidate =
true;
1618 vfp_count = (*byte_size == 8 ? 1 : 2);
1619 }
else if (*byte_size <= 16) {
1621 uint32_t *buffer_ptr = (uint32_t *)buffer.
GetBytes();
1623 for (uint32_t i = 0; 4 * i < *byte_size; ++i) {
1632 return return_valobj_sp;
1635 if (float_count == 1 && !is_complex) {
1636 switch (*bit_width) {
1638 return return_valobj_sp;
1640 static_assert(
sizeof(double) ==
sizeof(uint64_t));
1658 value.
GetScalar() = *
reinterpret_cast<double *
>(&raw_value);
1664 static_assert(
sizeof(float) ==
sizeof(uint32_t));
1676 value.
GetScalar() = *
reinterpret_cast<float *
>(&raw_value);
1681 }
else if (is_complex && float_count == 2) {
1683 is_vfp_candidate =
true;
1684 vfp_byte_size = *byte_size / 2;
1688 return return_valobj_sp;
1691 return return_valobj_sp;
1695 const uint32_t homogeneous_count =
1698 if (homogeneous_count > 0 && homogeneous_count <= 4) {
1699 std::optional<uint64_t> base_byte_size = base_type.
GetByteSize(&thread);
1701 if (base_byte_size &&
1702 (*base_byte_size == 8 || *base_byte_size == 16)) {
1703 is_vfp_candidate =
true;
1705 vfp_count = (*base_byte_size == 8 ? homogeneous_count
1706 : homogeneous_count * 2);
1709 if (float_count == 1 && !is_complex) {
1710 is_vfp_candidate =
true;
1712 vfp_byte_size = *base_byte_size;
1713 vfp_count = homogeneous_count;
1716 }
else if (homogeneous_count == 0) {
1717 const uint32_t num_children = compiler_type.
GetNumFields();
1719 if (num_children > 0 && num_children <= 2) {
1721 for (index = 0; index < num_children; index++) {
1727 std::optional<uint64_t> base_byte_size =
1729 if (float_count == 2 && is_complex) {
1730 if (index != 0 && base_byte_size &&
1731 vfp_byte_size != *base_byte_size)
1733 else if (base_byte_size)
1734 vfp_byte_size = *base_byte_size;
1741 if (index == num_children) {
1742 is_vfp_candidate =
true;
1743 vfp_byte_size = (vfp_byte_size >> 1);
1744 vfp_count = (num_children << 1);
1750 if (*byte_size <= 4) {
1752 uint32_t raw_value =
1754 value.
SetBytes(&raw_value, *byte_size);
1755 }
else if (!is_vfp_candidate) {
1757 return return_valobj_sp;
1761 return return_valobj_sp;
1764 if (is_vfp_candidate) {
1766 ByteOrder byte_order = process_sp->GetByteOrder();
1769 uint32_t data_offset = 0;
1771 for (uint32_t reg_index = 0; reg_index < vfp_count; reg_index++) {
1772 uint32_t regnum = 0;
1774 if (vfp_byte_size == 4)
1776 else if (vfp_byte_size == 8)
1783 if (reg_info ==
nullptr)
1791 if ((data_offset + vfp_byte_size) <= data_sp->GetByteSize()) {
1794 *reg_info, data_sp->GetBytes() + data_offset, vfp_byte_size,
1796 if (bytes_copied != vfp_byte_size)
1799 data_offset += bytes_copied;
1803 if (data_offset == *byte_size) {
1812 return return_valobj_sp;
1820 return return_valobj_sp;
1826 if (!new_value_sp) {
1831 CompilerType compiler_type = new_value_sp->GetCompilerType();
1832 if (!compiler_type) {
1837 Thread *thread = frame_sp->GetThread().get();
1845 bool set_it_simple =
false;
1850 size_t num_bytes = new_value_sp->GetData(data, data_error);
1851 if (data_error.
Fail()) {
1853 "Couldn't convert return value to raw data: %s",
1858 if (num_bytes <= 8) {
1861 if (num_bytes <= 4) {
1862 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes);
1865 set_it_simple =
true;
1867 uint32_t raw_value = data.
GetMaxU32(&offset, 4);
1872 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes - offset);
1875 set_it_simple =
true;
1880 "We don't support returning longer than 64 bit "
1881 "integer values at present.");
1886 "We don't support returning complex values at present");
1889 "We don't support returning float values at present");
1894 "We only support setting simple integer return types at present.");
1900 unwind_plan.
Clear();
1910 row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0);
1913 row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num,
true);
1925 unwind_plan.
Clear();
1933 const int32_t ptr_size = 4;
1935 row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
1937 row->SetUnspecifiedRegistersAreUndefined(
true);
1939 row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2,
true);
1940 row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1,
true);
1970 const char *name = reg_info->
name;
1971 if (name[0] ==
'r') {
1974 return name[2] ==
'\0';
1980 return name[3] ==
'\0';
1987 return name[2] ==
'\0';
1989 return name[2] ==
'\0';
1993 }
else if (name[0] ==
'd') {
1996 return name[2] ==
'\0';
2006 return name[3] ==
'\0';
2026 return name[3] ==
'\0';
2038 return name[3] ==
'\0';
2047 return name[2] ==
'\0';
2052 }
else if (name[0] ==
's') {
2055 return name[2] ==
'\0';
2067 return name[3] ==
'\0';
2081 return name[2] ==
'\0';
2086 }
else if (name[0] ==
'q') {
2107 return name[2] ==
'\0';
2110 return name[2] ==
'\0';
2114 }
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 const uint32_t k_num_register_infos
static bool GetReturnValuePassedInMemory(Thread &thread, RegisterContext *reg_ctx, size_t byte_size, Value &value)
static const RegisterInfo g_register_infos[]
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_PLUGIN_DEFINE(PluginName)
bool GetArgumentValues(lldb_private::Thread &thread, lldb_private::ValueList &values) const override
bool CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
bool IsArmHardFloat(lldb_private::Thread &thread) const
lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const override
bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch)
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
lldb_private::Status SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override
static llvm::StringRef GetPluginNameStatic()
bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
const lldb_private::RegisterInfo * GetRegisterInfoArray(uint32_t &count) override
size_t GetRedZoneSize() const override
static std::unique_ptr< llvm::MCRegisterInfo > MakeMCRegisterInfo(const ArchSpec &arch)
Utility function to construct a MCRegisterInfo using the ArchSpec triple.
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.
uint32_t GetFlags() const
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.
uint32_t IsHomogeneousAggregate(CompilerType *base_type_ptr) const
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
bool IsFloatingPointType(uint32_t &count, bool &is_complex) const
uint32_t GetNumFields() const
bool IsIntegerOrEnumerationType(bool &is_signed) const
bool IsAggregateType() const
std::optional< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
bool IsVectorType(CompilerType *element_type=nullptr, uint64_t *size=nullptr) const
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::offset_t GetByteSize() const override
Get the number of bytes in the data buffer.
"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)
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)
double GetAsDouble(double fail_value=0.0, bool *success_ptr=nullptr) const
uint32_t GetAsMemoryData(const RegisterInfo ®_info, void *dst, uint32_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
float GetAsFloat(float fail_value=0.0f, bool *success_ptr=nullptr) 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()
void SetBytes(const void *bytes, int len)
uint8_t * GetBytes()
Get a pointer to the data.
#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::WritableDataBuffer > WritableDataBufferSP
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.