14#include "llvm/ADT/STLExtras.h"
15#include "llvm/TargetParser/Triple.h"
49 const llvm::Triple::ArchType arch_type = arch.
GetTriple().getArch();
50 const llvm::Triple::VendorType vendor_type = arch.
GetTriple().getVendor();
52 if (vendor_type != llvm::Triple::Apple) {
53 if (arch_type == llvm::Triple::aarch64 ||
54 arch_type == llvm::Triple::aarch64_32) {
65 llvm::ArrayRef<addr_t> args)
const {
74 s.
Printf(
"ABISysV_arm64::PrepareTrivialCall (tid = 0x%" PRIx64
75 ", sp = 0x%" PRIx64
", func_addr = 0x%" PRIx64
76 ", return_addr = 0x%" PRIx64,
77 thread.
GetID(), (uint64_t)
sp, (uint64_t)func_addr,
78 (uint64_t)return_addr);
80 for (
size_t i = 0; i < args.size(); ++i)
81 s.
Printf(
", arg%d = 0x%" PRIx64,
static_cast<int>(i + 1), args[i]);
90 for (
size_t i = 0; i < args.size(); ++i) {
93 LLDB_LOGF(log,
"About to write arg%d (0x%" PRIx64
") into %s",
94 static_cast<int>(i + 1), args[i], reg_info->
name);
125 uint32_t num_values = values.
GetSize();
138 for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) {
148 bool is_signed =
false;
149 size_t bit_width = 0;
150 std::optional<uint64_t> bit_size = value_type.
GetBitSize(&thread);
154 bit_width = *bit_size;
156 bit_width = *bit_size;
191 const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
219 CompilerType return_value_type = new_value_sp->GetCompilerType();
220 if (!return_value_type) {
225 Thread *thread = frame_sp->GetThread().get();
232 const uint64_t byte_size = new_value_sp->GetData(data, data_error);
233 if (data_error.
Fail()) {
235 "Couldn't convert return value to raw data: %s",
240 const uint32_t type_flags = return_value_type.
GetTypeInfo(
nullptr);
241 if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
242 if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
245 if (byte_size <= 16) {
248 if (byte_size <= 8) {
249 uint64_t raw_value = data.
GetMaxU64(&offset, byte_size);
254 uint64_t raw_value = data.
GetMaxU64(&offset, 8);
259 raw_value = data.
GetMaxU64(&offset, byte_size - offset);
267 "We don't support returning longer than 128 bit "
268 "integer values at present.");
270 }
else if (type_flags & eTypeIsFloat) {
271 if (type_flags & eTypeIsComplex) {
274 "returning complex float values are not supported");
279 if (byte_size <= 16) {
288 "returning float values longer than 128 "
289 "bits are not supported");
293 "v0 register is not available on this target");
296 }
else if (type_flags & eTypeIsVector) {
301 if (byte_size <= v0_info->byte_size) {
304 if (
error.Success()) {
329 row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0);
352 const int32_t ptr_size = 8;
354 row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
356 row->SetUnspecifiedRegistersAreUndefined(
true);
358 row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2,
true);
359 row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1,
true);
380 const char *name = reg_info->
name;
385 if (name[0] ==
'p' && name[1] ==
'c')
387 if (name[0] ==
'f' && name[1] ==
'p')
389 if (name[0] ==
's' && name[1] ==
'p')
391 if (name[0] ==
'l' && name[1] ==
'r')
394 if (name[0] ==
'x' || name[0] ==
'r') {
427 if (name[2] ==
'0' || name[2] ==
'1')
433 }
else if (name[0] ==
'v' || name[0] ==
's' || name[0] ==
'd') {
463 bool is_return_value,
467 std::optional<uint64_t> byte_size =
470 if (byte_size || *byte_size == 0)
473 std::unique_ptr<DataBufferHeap> heap_data_up(
479 const uint32_t homogeneous_count =
481 if (homogeneous_count > 0 && homogeneous_count <= 8) {
483 if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
486 std::optional<uint64_t> base_byte_size =
490 uint32_t data_offset = 0;
492 for (uint32_t i = 0; i < homogeneous_count; ++i) {
494 ::snprintf(v_name,
sizeof(v_name),
"v%u", NSRN);
497 if (reg_info ==
nullptr)
500 if (*base_byte_size > reg_info->
byte_size)
509 if ((data_offset + *base_byte_size) <= heap_data_up->GetByteSize()) {
511 *reg_info, heap_data_up->GetBytes() + data_offset,
512 *base_byte_size, byte_order,
error);
513 if (bytes_copied != *base_byte_size)
515 data_offset += bytes_copied;
527 const size_t max_reg_byte_size = 16;
528 if (*byte_size <= max_reg_byte_size) {
529 size_t bytes_left = *byte_size;
530 uint32_t data_offset = 0;
531 while (data_offset < *byte_size) {
537 if (reg_info ==
nullptr)
545 const size_t curr_byte_size = std::min<size_t>(8, bytes_left);
547 *reg_info, heap_data_up->GetBytes() + data_offset, curr_byte_size,
549 if (bytes_copied == 0)
551 if (bytes_copied >= bytes_left)
553 data_offset += bytes_copied;
554 bytes_left -= bytes_copied;
559 if (is_return_value) {
576 if (reg_info ==
nullptr)
588 value_addr, heap_data_up->GetBytes(), heap_data_up->GetByteSize(),
589 error) != heap_data_up->GetByteSize()) {
607 return return_valobj_sp;
614 return return_valobj_sp;
616 std::optional<uint64_t> byte_size = return_compiler_type.
GetByteSize(&thread);
618 return return_valobj_sp;
620 const uint32_t type_flags = return_compiler_type.
GetTypeInfo(
nullptr);
621 if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
624 bool success =
false;
625 if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
627 if (*byte_size <= 8) {
635 const bool is_signed = (type_flags & eTypeIsSigned) != 0;
636 switch (*byte_size) {
649 std::unique_ptr<DataBufferHeap> heap_data_up(
659 *x0_reg_info, heap_data_up->GetBytes() + 0, 8,
660 byte_order,
error) &&
662 *x1_reg_info, heap_data_up->GetBytes() + 8, 8,
663 byte_order,
error)) {
669 &thread, return_compiler_type,
ConstString(
""), data);
670 return return_valobj_sp;
677 case sizeof(uint64_t):
679 value.
GetScalar() = (int64_t)(raw_value);
681 value.
GetScalar() = (uint64_t)(raw_value);
685 case sizeof(uint32_t):
693 case sizeof(uint16_t):
695 value.
GetScalar() = (int16_t)(raw_value & UINT16_MAX);
697 value.
GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
701 case sizeof(uint8_t):
703 value.
GetScalar() = (int8_t)(raw_value & UINT8_MAX);
705 value.
GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
711 }
else if (type_flags & eTypeIsFloat) {
712 if (type_flags & eTypeIsComplex) {
715 if (*byte_size <=
sizeof(
long double)) {
723 if (*byte_size ==
sizeof(
float)) {
726 }
else if (*byte_size ==
sizeof(
double)) {
729 }
else if (*byte_size ==
sizeof(
long double)) {
742 }
else if (type_flags & eTypeIsVector && *byte_size <= 16) {
743 if (*byte_size > 0) {
747 std::unique_ptr<DataBufferHeap> heap_data_up(
754 heap_data_up->GetByteSize(), byte_order,
759 &thread, return_compiler_type,
ConstString(
""), data);
764 }
else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass ||
765 (type_flags & eTypeIsVector && *byte_size > 16)) {
770 const bool is_return_value =
true;
772 exe_ctx, reg_ctx, return_compiler_type, is_return_value, NGRN, NSRN,
775 &thread, return_compiler_type,
ConstString(
""), data);
778 return return_valobj_sp;
784 lldb::addr_t pac_sign_extension = 0x0080000000000000ULL;
785 return (
pc & pac_sign_extension) ?
pc | mask :
pc & (~mask);
790 llvm::StringRef reg_name) {
797 lldb::ThreadSP thread_sp = process_sp->GetThreadList().GetSelectedThread();
801 address_mask = ~((1ULL << 56) - 1);
808 reg_ctx_sp->GetRegisterInfoByName(reg_name, 0);
810 lldb::addr_t mask_reg_val = reg_ctx_sp->ReadRegisterAsUnsigned(
813 address_mask |= mask_reg_val;
822 if (process_sp->GetTarget().GetArchitecture().GetTriple().isOSLinux() &&
824 process_sp->SetCodeAddressMask(
829 const addr_t pac_sign_extension = 0x0080000000000000ULL;
830 addr_t mask = process_sp->GetCodeAddressMask();
832 if (
pc & pac_sign_extension &&
834 mask = process_sp->GetHighmemCodeAddressMask();
843 if (process_sp->GetTarget().GetArchitecture().GetTriple().isOSLinux() &&
845 process_sp->SetDataAddressMask(
850 const addr_t pac_sign_extension = 0x0080000000000000ULL;
851 addr_t mask = process_sp->GetDataAddressMask();
853 if (
pc & pac_sign_extension &&
855 mask = process_sp->GetHighmemDataAddressMask();
static bool LoadValueFromConsecutiveGPRRegisters(ExecutionContext &exe_ctx, RegisterContext *reg_ctx, const CompilerType &value_type, bool is_return_value, uint32_t &NGRN, uint32_t &NSRN, DataExtractor &data)
static bool LoadValueFromConsecutiveGPRRegisters(ExecutionContext &exe_ctx, RegisterContext *reg_ctx, const CompilerType &value_type, bool is_return_value, uint32_t &NGRN, uint32_t &NSRN, DataExtractor &data)
static lldb::addr_t ReadLinuxProcessAddressMask(lldb::ProcessSP process_sp, llvm::StringRef reg_name)
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const override
bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, llvm::ArrayRef< lldb::addr_t > args) const override
bool GetArgumentValues(lldb_private::Thread &thread, lldb_private::ValueList &values) const override
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch)
lldb_private::Status SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override
lldb::addr_t FixCodeAddress(lldb::addr_t pc) override
Some targets might use bits in a code address to indicate a mode switch.
lldb::addr_t FixDataAddress(lldb::addr_t pc) override
bool GetPointerReturnRegister(const char *&name) override
lldb::addr_t FixAddress(lldb::addr_t pc, lldb::addr_t mask) override
bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override
static llvm::StringRef GetPluginNameStatic()
size_t GetRedZoneSize() const override
bool CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
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.
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.
uint32_t IsHomogeneousAggregate(CompilerType *base_type_ptr) const
bool IsIntegerOrEnumerationType(bool &is_signed) const
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) 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
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.
ExecutionContextScope * GetBestExecutionContextScope() const
Process & GetProcessRef() const
Returns a reference to the process object.
Target * GetTargetPtr() const
Returns a pointer to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
void PutString(llvm::StringRef str)
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)
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
lldb::ByteOrder GetByteOrder() const
uint32_t GetAddressByteSize() const
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)
bool GetData(DataExtractor &data) const
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
Status SetValueFromData(const RegisterInfo ®_info, DataExtractor &data, lldb::offset_t offset, bool partial_data_ok)
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.
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
virtual lldb::RegisterContextSP GetRegisterContext()=0
void SetUnwindPlanForSignalTrap(lldb_private::LazyBool is_for_signal_trap)
void SetRegisterKind(lldb::RegisterKind kind)
void SetReturnAddressRegister(uint32_t regnum)
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)
void SetValueType(ValueType value_type)
const CompilerType & GetCompilerType()
#define LLDB_REGNUM_GENERIC_RA
#define LLDB_INVALID_ADDRESS_MASK
Address Mask Bits not used for addressing are set to 1 in the mask; all mask bits set is an invalid v...
#define LLDB_REGNUM_GENERIC_SP
#define LLDB_REGNUM_GENERIC_ARG1
#define LLDB_INVALID_ADDRESS
#define LLDB_REGNUM_GENERIC_ARG2
#define LLDB_REGNUM_GENERIC_PC
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Process > ProcessSP
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
@ eRegisterKindLLDB
lldb's internal register numbers
@ 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.
uint32_t kinds[lldb::kNumRegisterKinds]
Holds all of the various register numbers for all register kinds.
const char * name
Name of this register, can't be NULL.
lldb::user_id_t GetID() const
Get accessor for the user ID.