11#include "llvm/ADT/STLExtras.h"
12#include "llvm/TargetParser/Triple.h"
562 llvm::ArrayRef<addr_t> args)
const {
567 s.
Printf(
"ABISysV_mips64::PrepareTrivialCall (tid = 0x%" PRIx64
568 ", sp = 0x%" PRIx64
", func_addr = 0x%" PRIx64
569 ", return_addr = 0x%" PRIx64,
570 thread.
GetID(), (uint64_t)
sp, (uint64_t)func_addr,
571 (uint64_t)return_addr);
573 for (
size_t i = 0; i < args.size(); ++i)
574 s.
Printf(
", arg%zd = 0x%" PRIx64, i + 1, args[i]);
588 for (
size_t i = 0; i < args.size(); ++i) {
591 LLDB_LOGF(log,
"About to write arg%zd (0x%" PRIx64
") into %s", i + 1,
592 args[i], reg_info->
name);
599 LLDB_LOGF(log,
"16-byte aligning SP: 0x%" PRIx64
" to 0x%" PRIx64,
600 (uint64_t)
sp, (uint64_t)(
sp & ~0xfull));
614 LLDB_LOGF(log,
"Writing R0: 0x%" PRIx64, (uint64_t)0);
623 LLDB_LOGF(log,
"Writing SP: 0x%" PRIx64, (uint64_t)
sp);
629 LLDB_LOGF(log,
"Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
635 LLDB_LOGF(log,
"Writing PC: 0x%" PRIx64, (uint64_t)func_addr);
641 LLDB_LOGF(log,
"Writing r25: 0x%" PRIx64, (uint64_t)func_addr);
664 CompilerType compiler_type = new_value_sp->GetCompilerType();
665 if (!compiler_type) {
670 Thread *thread = frame_sp->GetThread().get();
679 size_t num_bytes = new_value_sp->GetData(data, data_error);
680 if (data_error.
Fail()) {
682 "Couldn't convert return value to raw data: %s",
687 const uint32_t type_flags = compiler_type.
GetTypeInfo(
nullptr);
689 if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
690 if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
693 if (num_bytes <= 16) {
695 if (num_bytes <= 8) {
696 uint64_t raw_value = data.
GetMaxU64(&offset, num_bytes);
701 uint64_t raw_value = data.
GetMaxU64(&offset, 8);
705 raw_value = data.
GetMaxU64(&offset, num_bytes - offset);
714 "We don't support returning longer than 128 bit "
715 "integer values at present.");
717 }
else if (type_flags & eTypeIsFloat) {
720 }
else if (type_flags & eTypeIsVector) {
731 return return_valobj_sp;
742 return return_valobj_sp;
748 return return_valobj_sp;
753 std::optional<uint64_t> byte_size = return_compiler_type.
GetByteSize(&thread);
755 return return_valobj_sp;
756 const uint32_t type_flags = return_compiler_type.
GetTypeInfo(
nullptr);
762 assert(r2_info && r3_info &&
"Basic registers should always be present.");
764 if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
767 bool success =
false;
768 if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
774 const bool is_signed = (type_flags & eTypeIsSigned) != 0;
775 switch (*byte_size) {
779 case sizeof(uint64_t):
781 value.
GetScalar() = (int64_t)(raw_value);
783 value.
GetScalar() = (uint64_t)(raw_value);
787 case sizeof(uint32_t):
795 case sizeof(uint16_t):
797 value.
GetScalar() = (int16_t)(raw_value & UINT16_MAX);
799 value.
GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
803 case sizeof(uint8_t):
805 value.
GetScalar() = (int8_t)(raw_value & UINT8_MAX);
807 value.
GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
811 }
else if (type_flags & eTypeIsFloat) {
812 if (type_flags & eTypeIsComplex) {
816 switch (*byte_size) {
818 value.
GetScalar() = *((
float *)(&raw_value));
822 value.
GetScalar() = *((
double *)(&raw_value));
828 result[0] = raw_value;
830 value.
GetScalar() = *((
long double *)(result));
833 result[1] = raw_value;
834 value.
GetScalar() = *((
long double *)(result));
841 if (*byte_size <=
sizeof(
long double)) {
852 if (*byte_size ==
sizeof(
float)) {
855 }
else if (*byte_size ==
sizeof(
double)) {
858 }
else if (*byte_size ==
sizeof(
long double)) {
867 data_sp, target_byte_order,
871 copy_from_extractor = &f0_data;
873 0, 8, data_sp->GetBytes(), *byte_size - 8, target_byte_order);
875 copy_from_extractor = &f2_data;
877 0, 8, data_sp->GetBytes() + 8, *byte_size - 8,
880 copy_from_extractor = &f0_data;
882 0, 8, data_sp->GetBytes() + 8, *byte_size - 8,
885 copy_from_extractor = &f2_data;
887 0, 8, data_sp->GetBytes(), *byte_size - 8, target_byte_order);
891 &thread, return_compiler_type,
ConstString(
""), return_ext);
892 return return_valobj_sp;
901 }
else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass ||
902 type_flags & eTypeIsVector) {
904 if (*byte_size <= 16) {
909 RegisterValue r2_value, r3_value, f0_value, f1_value, f2_value;
911 uint32_t integer_bytes = 0;
914 bool use_fp_regs =
false;
916 bool found_non_fp_field =
false;
926 const uint32_t num_children = return_compiler_type.
GetNumFields();
930 if (num_children <= 2) {
931 uint64_t field_bit_offset = 0;
934 for (uint32_t idx = 0; idx < num_children; idx++) {
942 found_non_fp_field =
true;
945 if (use_fp_regs && !found_non_fp_field) {
958 for (uint32_t idx = 0; idx < num_children; idx++) {
961 idx, name, &field_bit_offset,
nullptr,
nullptr);
962 std::optional<uint64_t> field_byte_width =
964 if (!field_byte_width)
965 return return_valobj_sp;
968 uint64_t return_value[2];
973 if (*field_byte_width == 16) {
978 return_value[0] = f0_data.
GetU64(&offset);
982 return_value[1] = f1_data.
GetU64(&offset);
984 return_value[1] = f0_data.
GetU64(&offset);
988 return_value[0] = f1_data.
GetU64(&offset);
991 f0_data.
SetData(return_value, *field_byte_width,
994 copy_from_extractor = &f0_data;
1000 copy_from_extractor = &f2_data;
1004 if (!copy_from_extractor ||
1005 *field_byte_width > copy_from_extractor->
GetByteSize())
1006 return return_valobj_sp;
1010 0, *field_byte_width,
1011 data_sp->GetBytes() + (field_bit_offset / 8), *field_byte_width,
1018 &thread, return_compiler_type,
ConstString(
""), return_ext);
1020 return return_valobj_sp;
1027 for (uint32_t idx = 0; idx < num_children; idx++) {
1028 uint64_t field_bit_offset = 0;
1033 idx, name, &field_bit_offset,
nullptr,
nullptr);
1034 std::optional<uint64_t> field_byte_width =
1039 if (!field_byte_width || *field_byte_width == 0)
1042 uint32_t field_byte_offset = field_bit_offset / 8;
1047 padding = field_byte_offset - integer_bytes;
1049 if (integer_bytes < 8) {
1051 if (integer_bytes + *field_byte_width + padding <= 8) {
1054 integer_bytes = integer_bytes + *field_byte_width +
1060 integer_bytes = integer_bytes + *field_byte_width +
1067 else if (integer_bytes + *field_byte_width + padding <= 16) {
1068 integer_bytes = integer_bytes + *field_byte_width + padding;
1075 return return_valobj_sp;
1080 if (type_flags & eTypeIsVector) {
1081 if (*byte_size <= 8)
1093 *r2_info, data_sp->GetBytes(), r2_info->
byte_size,
1094 target_byte_order,
error);
1096 return return_valobj_sp;
1102 *r3_info, data_sp->GetBytes() + r2_info->
byte_size,
1106 return return_valobj_sp;
1113 &thread, return_compiler_type,
ConstString(
""), return_ext);
1115 return return_valobj_sp;
1125 &thread,
"",
Address(mem_address,
nullptr), return_compiler_type);
1127 return return_valobj_sp;
1131 unwind_plan.
Clear();
1137 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
1152 unwind_plan.
Clear();
1157 row->SetUnspecifiedRegistersAreUndefined(
true);
1158 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
1185 bool save = (reg >= 16) && (reg <= 23);
1186 save |= (reg >= 28) && (reg <= 31);
static const uint32_t k_num_register_infos
static const uint32_t k_num_register_infos
static const RegisterInfo g_register_infos_mips64[]
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
static llvm::StringRef GetPluginNameStatic()
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info)
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
lldb_private::Status SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override
bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override
const lldb_private::RegisterInfo * GetRegisterInfoArray(uint32_t &count) override
lldb::ValueObjectSP GetReturnValueObjectSimple(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const
bool GetArgumentValues(lldb_private::Thread &thread, lldb_private::ValueList &values) const override
lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread, lldb_private::CompilerType &type) const override
bool IsSoftFloat(uint32_t fp_flag) const
bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
size_t GetRedZoneSize() const override
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch)
bool CreateFunctionEntryUnwindPlan(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.
A section + offset based address class.
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
llvm::Triple & GetTriple()
Architecture triple accessor.
uint32_t GetFlags() const
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
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.
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
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_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.
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)
uint64_t ReadRegisterAsUnsigned(uint32_t reg, uint64_t fail_value)
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 GetData(DataExtractor &data) const
uint32_t GetAsMemoryData(const RegisterInfo ®_info, void *dst, uint32_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
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.
const ArchSpec & GetArchitecture() const
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)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, llvm::StringRef name, const Address &address, lldb::TypeSP &type_sp)
const Scalar & GetScalar() const
void SetCompilerType(const CompilerType &compiler_type)
void SetValueType(ValueType value_type)
#define LLDB_REGNUM_GENERIC_RA
#define LLDB_REGNUM_GENERIC_ARG8
#define LLDB_REGNUM_GENERIC_ARG6
#define LLDB_REGNUM_GENERIC_SP
#define LLDB_REGNUM_GENERIC_ARG4
#define LLDB_REGNUM_GENERIC_ARG3
#define LLDB_REGNUM_GENERIC_ARG1
#define LLDB_REGNUM_GENERIC_ARG7
#define LLDB_REGNUM_GENERIC_FLAGS
#define LLDB_INVALID_REGNUM
#define LLDB_REGNUM_GENERIC_ARG2
#define LLDB_REGNUM_GENERIC_PC
#define LLDB_REGNUM_GENERIC_FP
#define LLDB_REGNUM_GENERIC_ARG5
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::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Process > ProcessSP
@ eEncodingUint
unsigned integer
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
@ 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_offset
The byte offset in the register context data where this register's value is found.
uint32_t byte_size
Size in bytes of the register.
const char * name
Name of this register, can't be NULL.
lldb::user_id_t GetID() const
Get accessor for the user ID.