14#include "llvm/ADT/STLExtras.h"
15#include "llvm/TargetParser/Triple.h"
1192const lldb_private::RegisterInfo *
1204 const llvm::Triple::ArchType arch_type = arch.
GetTriple().getArch();
1205 const llvm::Triple::VendorType vendor_type = arch.
GetTriple().getVendor();
1207 if (vendor_type == llvm::Triple::Apple) {
1208 if ((arch_type == llvm::Triple::arm) ||
1209 (arch_type == llvm::Triple::thumb)) {
1220 llvm::ArrayRef<addr_t> args)
const {
1234 const char *reg_names[] = {
"r0",
"r1",
"r2",
"r3"};
1236 llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end();
1238 for (
size_t i = 0; i < std::size(reg_names); ++i) {
1252 size_t num_stack_regs = ae - ai;
1254 sp -= (num_stack_regs * 4);
1256 sp &= ~(16ull - 1ull);
1264 for (; ai != ae; ++ai) {
1267 ->WriteRegisterValueToMemory(reg_info, arg_pos,
1268 reg_info->byte_size, reg_value)
1271 arg_pos += reg_info->byte_size;
1297 uint32_t new_cpsr = curr_cpsr & ~MASK_CPSR_IT_MASK;
1299 if (function_addr & 1ull)
1302 new_cpsr &= ~MASK_CPSR_T;
1304 if (new_cpsr != curr_cpsr) {
1340 for (
uint32_t value_idx = 0; value_idx < num_values; ++value_idx) {
1349 if (compiler_type) {
1350 bool is_signed =
false;
1351 size_t bit_width = 0;
1352 std::optional<uint64_t> bit_size = compiler_type.
GetBitSize(&thread);
1356 bit_width = *bit_size;
1358 bit_width = *bit_size;
1364 if (value_idx < 4) {
1366 const RegisterInfo *arg_reg_info =
nullptr;
1373 switch (value_idx) {
1410 const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
1416 sp += arg_byte_size;
1425 bool is_armv7k =
false;
1428 const ArchSpec &arch(process_sp->GetTarget().GetArchitecture());
1440 ValueObjectSP return_valobj_sp;
1443 return return_valobj_sp;
1449 return return_valobj_sp;
1458 std::optional<uint64_t> bit_width = compiler_type.
GetBitSize(&thread);
1460 return return_valobj_sp;
1462 switch (*bit_width) {
1464 return return_valobj_sp;
1471 const RegisterInfo *r1_reg_info =
1473 const RegisterInfo *r2_reg_info =
1475 const RegisterInfo *r3_reg_info =
1477 if (r1_reg_info && r2_reg_info && r3_reg_info) {
1478 std::optional<uint64_t> byte_size =
1481 return return_valobj_sp;
1483 if (*byte_size <= r0_reg_info->byte_size + r1_reg_info->byte_size +
1484 r2_reg_info->byte_size +
1485 r3_reg_info->byte_size &&
1487 std::unique_ptr<DataBufferHeap> heap_data_up(
1489 const ByteOrder byte_order = process_sp->GetByteOrder();
1494 if (reg_ctx->
ReadRegister(r0_reg_info, r0_reg_value) &&
1500 heap_data_up->GetBytes() + 0,
1501 4, byte_order,
error) &&
1503 heap_data_up->GetBytes() + 4,
1504 4, byte_order,
error) &&
1506 heap_data_up->GetBytes() + 8,
1507 4, byte_order,
error) &&
1509 heap_data_up->GetBytes() + 12,
1510 4, byte_order,
error)) {
1513 process_sp->GetAddressByteSize());
1517 return return_valobj_sp;
1524 return return_valobj_sp;
1537 value.
GetScalar() = (uint64_t)raw_value;
1571 return return_valobj_sp;
1578 return return_valobj_sp;
1582 lldb::ValueObjectSP &new_value_sp) {
1584 if (!new_value_sp) {
1585 error.SetErrorString(
"Empty value object for return value.");
1589 CompilerType compiler_type = new_value_sp->GetCompilerType();
1590 if (!compiler_type) {
1591 error.SetErrorString(
"Null clang type for return value.");
1595 Thread *thread = frame_sp->GetThread().get();
1603 bool set_it_simple =
false;
1608 size_t num_bytes = new_value_sp->GetData(data, data_error);
1609 if (data_error.
Fail()) {
1610 error.SetErrorStringWithFormat(
1611 "Couldn't convert return value to raw data: %s",
1616 if (num_bytes <= 8) {
1618 if (num_bytes <= 4) {
1622 set_it_simple =
true;
1631 set_it_simple =
true;
1647 bytes_written <= num_bytes) {
1650 if (bytes_written <= num_bytes &&
1654 if (bytes_written <= num_bytes &&
1658 if (bytes_written <= num_bytes &&
1660 set_it_simple =
true;
1666 error.SetErrorString(
"We don't support returning longer than 64 bit "
1667 "integer values at present.");
1671 error.SetErrorString(
1672 "We don't support returning complex values at present");
1674 error.SetErrorString(
1675 "We don't support returning float values at present");
1679 error.SetErrorString(
1680 "We only support setting simple integer return types at present.");
1686 unwind_plan.
Clear();
1696 row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0);
1699 row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num,
true);
1711 unwind_plan.
Clear();
1719 const int32_t ptr_size = 4;
1721 row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
1723 row->SetUnspecifiedRegistersAreUndefined(
true);
1725 row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2,
true);
1726 row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1,
true);
1729 unwind_plan.
SetSourceName(
"arm-apple-ios default unwind plan");
1764 const char *name = reg_info->name;
1765 if (name[0] ==
'r') {
1768 return name[2] ==
'\0';
1775 return name[3] ==
'\0';
1782 return name[2] ==
'\0';
1784 return name[2] ==
'\0';
1786 return name[2] ==
'\0';
1790 }
else if (name[0] ==
'd') {
1793 return name[2] ==
'\0';
1803 return name[3] ==
'\0';
1823 return name[3] ==
'\0';
1835 return name[3] ==
'\0';
1844 return name[2] ==
'\0';
1849 }
else if (name[0] ==
's') {
1852 return name[2] ==
'\0';
1864 return name[3] ==
'\0';
1878 return name[2] ==
'\0';
1883 }
else if (name[0] ==
'q') {
1903 return name[2] ==
'\0';
1906 return name[2] ==
'\0';
1910 }
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.
@ eEncodingUint
unsigned integer
ByteOrder
Byte ordering definitions.
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
@ eRegisterKindDWARF
the register numbers seen DWARF