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,
 
 1379  TargetSP target_sp(thread.CalculateTarget());
 
 1408  if (function_addr & 1ull)
 
 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 =
 
 1456                llvm::expectedToOptional(compiler_type.
GetBitSize(&thread)))
 
 1464        if (value_idx < 4) {
 
 1490          const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
 
 1496          sp += arg_byte_size;
 
 
 1506                                         size_t byte_size, 
Value &value) {
 
 1514  thread.GetProcess()->ReadMemory(address, buffer.
GetBytes(),
 
 
 1525  ProcessSP process_sp(thread.GetProcess());
 
 1527    const ArchSpec &arch(process_sp->GetTarget().GetArchitecture());
 
 
 1541    return return_valobj_sp;
 
 1549    return return_valobj_sp;
 
 1553  uint32_t float_count;
 
 1554  bool is_vfp_candidate = 
false;
 
 1555  uint8_t vfp_count = 0;
 
 1556  uint8_t vfp_byte_size = 0;
 
 1563  std::optional<uint64_t> bit_width =
 
 1564      llvm::expectedToOptional(compiler_type.
GetBitSize(&thread));
 
 1565  std::optional<uint64_t> byte_size =
 
 1566      llvm::expectedToOptional(compiler_type.
GetByteSize(&thread));
 
 1567  if (!bit_width || !byte_size)
 
 1568    return return_valobj_sp;
 
 1571    switch (*bit_width) {
 
 1573      return return_valobj_sp;
 
 1585        value.
GetScalar() = (uint64_t)raw_value;
 
 1614        thread.GetRegisterContext()->ReadRegisterAsUnsigned(r0_reg_info, 0) &
 
 1618    if (
IsArmHardFloat(thread) && (*byte_size == 8 || *byte_size == 16)) {
 
 1619      is_vfp_candidate = 
true;
 
 1621      vfp_count = (*byte_size == 8 ? 1 : 2);
 
 1622    } 
else if (*byte_size <= 16) {
 
 1624      uint32_t *buffer_ptr = (uint32_t *)buffer.
GetBytes();
 
 1626      for (uint32_t i = 0; 4 * i < *byte_size; ++i) {
 
 1635        return return_valobj_sp;
 
 1638    if (float_count == 1 && !is_complex) {
 
 1639      switch (*bit_width) {
 
 1641        return return_valobj_sp;
 
 1643        static_assert(
sizeof(double) == 
sizeof(uint64_t));
 
 1661          value.
GetScalar() = *
reinterpret_cast<double *
>(&raw_value);
 
 1667        static_assert(
sizeof(float) == 
sizeof(uint32_t));
 
 1679          value.
GetScalar() = *
reinterpret_cast<float *
>(&raw_value);
 
 1684    } 
else if (is_complex && float_count == 2) {
 
 1686        is_vfp_candidate = 
true;
 
 1687        vfp_byte_size = *byte_size / 2;
 
 1691        return return_valobj_sp;
 
 1694      return return_valobj_sp;
 
 1698      const uint32_t homogeneous_count =
 
 1701      if (homogeneous_count > 0 && homogeneous_count <= 4) {
 
 1702        std::optional<uint64_t> base_byte_size =
 
 1703            llvm::expectedToOptional(base_type.
GetByteSize(&thread));
 
 1705          if (base_byte_size &&
 
 1706              (*base_byte_size == 8 || *base_byte_size == 16)) {
 
 1707            is_vfp_candidate = 
true;
 
 1709            vfp_count = (*base_byte_size == 8 ? homogeneous_count
 
 1710                                              : homogeneous_count * 2);
 
 1713          if (float_count == 1 && !is_complex) {
 
 1714            is_vfp_candidate = 
true;
 
 1716              vfp_byte_size = *base_byte_size;
 
 1717            vfp_count = homogeneous_count;
 
 1720      } 
else if (homogeneous_count == 0) {
 
 1721        const uint32_t num_children = compiler_type.
GetNumFields();
 
 1723        if (num_children > 0 && num_children <= 2) {
 
 1725          for (index = 0; index < num_children; index++) {
 
 1731              std::optional<uint64_t> base_byte_size =
 
 1732                  llvm::expectedToOptional(base_type.
GetByteSize(&thread));
 
 1733              if (float_count == 2 && is_complex) {
 
 1734                if (index != 0 && base_byte_size &&
 
 1735                    vfp_byte_size != *base_byte_size)
 
 1737                else if (base_byte_size)
 
 1738                  vfp_byte_size = *base_byte_size;
 
 1745          if (index == num_children) {
 
 1746            is_vfp_candidate = 
true;
 
 1747            vfp_byte_size = (vfp_byte_size >> 1);
 
 1748            vfp_count = (num_children << 1);
 
 1754    if (*byte_size <= 4) {
 
 1756      uint32_t raw_value =
 
 1758      value.
SetBytes(&raw_value, *byte_size);
 
 1759    } 
else if (!is_vfp_candidate) {
 
 1761        return return_valobj_sp;
 
 1765    return return_valobj_sp;
 
 1768  if (is_vfp_candidate) {
 
 1769    ProcessSP process_sp(thread.GetProcess());
 
 1770    ByteOrder byte_order = process_sp->GetByteOrder();
 
 1773    uint32_t data_offset = 0;
 
 1775    for (uint32_t reg_index = 0; reg_index < vfp_count; reg_index++) {
 
 1776      uint32_t regnum = 0;
 
 1778      if (vfp_byte_size == 4)
 
 1780      else if (vfp_byte_size == 8)
 
 1787      if (reg_info == 
nullptr)
 
 1795      if ((data_offset + vfp_byte_size) <= data_sp->GetByteSize()) {
 
 1798            *reg_info, data_sp->GetBytes() + data_offset, vfp_byte_size,
 
 1800        if (bytes_copied != vfp_byte_size)
 
 1803        data_offset += bytes_copied;
 
 1807    if (data_offset == *byte_size) {
 
 1816      return return_valobj_sp;
 
 1823      thread.GetStackFrameAtIndex(0).get(), value, 
ConstString(
""));
 
 1824  return return_valobj_sp;
 
 
 1830  if (!new_value_sp) {
 
 1835  CompilerType compiler_type = new_value_sp->GetCompilerType();
 
 1836  if (!compiler_type) {
 
 1841  Thread *thread = frame_sp->GetThread().get();
 
 1849  bool set_it_simple = 
false;
 
 1854    size_t num_bytes = new_value_sp->GetData(data, data_error);
 
 1855    if (data_error.
Fail()) {
 
 1857          "Couldn't convert return value to raw data: %s",
 
 1862    if (num_bytes <= 8) {
 
 1865      if (num_bytes <= 4) {
 
 1866        uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes);
 
 1869          set_it_simple = 
true;
 
 1871        uint32_t raw_value = data.
GetMaxU32(&offset, 4);
 
 1876          uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes - offset);
 
 1879            set_it_simple = 
true;
 
 1884          "We don't support returning longer than 64 bit " 
 1885          "integer values at present.");
 
 1890          "We don't support returning complex values at present");
 
 1893          "We don't support returning float values at present");
 
 1898        "We only support setting simple integer return types at present.");
 
 
 1916  plan_sp->AppendRow(std::move(row));
 
 1917  plan_sp->SetSourceName(
"arm at-func-entry default");
 
 
 1935  const int32_t ptr_size = 4;
 
 1944  plan_sp->AppendRow(std::move(row));
 
 1945  plan_sp->SetSourceName(
"arm default unwind plan");
 
 1947  plan_sp->SetUnwindPlanValidAtAllInstructions(
eLazyBoolNo);
 
 
 1971    const char *name = reg_info->
name;
 
 1972    if (name[0] == 
'r') {
 
 1975        return name[2] == 
'\0'; 
 
 1981          return name[3] == 
'\0'; 
 
 1988        return name[2] == 
'\0'; 
 
 1990        return name[2] == 
'\0'; 
 
 1994    } 
else if (name[0] == 
'd') {
 
 1997        return name[2] == 
'\0'; 
 
 2007          return name[3] == 
'\0'; 
 
 2027          return name[3] == 
'\0'; 
 
 2039          return name[3] == 
'\0'; 
 
 2048        return name[2] == 
'\0'; 
 
 2053    } 
else if (name[0] == 
's') {
 
 2056        return name[2] == 
'\0'; 
 
 2068          return name[3] == 
'\0'; 
 
 2082        return name[2] == 
'\0'; 
 
 2087    } 
else if (name[0] == 
'q') {
 
 2108        return name[2] == 
'\0'; 
 
 2111        return name[2] == 
'\0'; 
 
 2115    } 
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 bool GetReturnValuePassedInMemory(Thread &thread, RegisterContext *reg_ctx, size_t byte_size, Value &value)
#define MASK_CPSR_IT_MASK
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 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
lldb::UnwindPlanSP CreateDefaultUnwindPlan() 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()
const lldb_private::RegisterInfo * GetRegisterInfoArray(uint32_t &count) override
lldb::UnwindPlanSP CreateFunctionEntryUnwindPlan() 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.
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
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
uint32_t GetNumFields() const
bool IsIntegerOrEnumerationType(bool &is_signed) const
bool IsAggregateType() const
llvm::Expected< 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.
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()
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::UnwindPlan > UnwindPlanSP
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.