11#include "llvm/ADT/STLExtras.h"
12#include "llvm/TargetParser/Triple.h"
568 llvm::ArrayRef<addr_t> args)
const {
573 s.
Printf(
"ABISysV_mips64::PrepareTrivialCall (tid = 0x%" PRIx64
574 ", sp = 0x%" PRIx64
", func_addr = 0x%" PRIx64
575 ", return_addr = 0x%" PRIx64,
576 thread.
GetID(), (uint64_t)
sp, (uint64_t)func_addr,
577 (uint64_t)return_addr);
579 for (
size_t i = 0; i < args.size(); ++i)
580 s.
Printf(
", arg%zd = 0x%" PRIx64, i + 1, args[i]);
594 for (
size_t i = 0; i < args.size(); ++i) {
597 LLDB_LOGF(log,
"About to write arg%zd (0x%" PRIx64
") into %s", i + 1,
598 args[i], reg_info->
name);
605 LLDB_LOGF(log,
"16-byte aligning SP: 0x%" PRIx64
" to 0x%" PRIx64,
606 (uint64_t)
sp, (uint64_t)(
sp & ~0xfull));
620 LLDB_LOGF(log,
"Writing R0: 0x%" PRIx64, (uint64_t)0);
629 LLDB_LOGF(log,
"Writing SP: 0x%" PRIx64, (uint64_t)
sp);
635 LLDB_LOGF(log,
"Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
641 LLDB_LOGF(log,
"Writing PC: 0x%" PRIx64, (uint64_t)func_addr);
647 LLDB_LOGF(log,
"Writing r25: 0x%" PRIx64, (uint64_t)func_addr);
666 error.SetErrorString(
"Empty value object for return value.");
670 CompilerType compiler_type = new_value_sp->GetCompilerType();
671 if (!compiler_type) {
672 error.SetErrorString(
"Null clang type for return value.");
676 Thread *thread = frame_sp->GetThread().get();
681 error.SetErrorString(
"no registers are available");
685 size_t num_bytes = new_value_sp->GetData(data, data_error);
686 if (data_error.
Fail()) {
687 error.SetErrorStringWithFormat(
688 "Couldn't convert return value to raw data: %s",
693 const uint32_t type_flags = compiler_type.
GetTypeInfo(
nullptr);
695 if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
696 if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
699 if (num_bytes <= 16) {
701 if (num_bytes <= 8) {
702 uint64_t raw_value = data.
GetMaxU64(&offset, num_bytes);
705 error.SetErrorString(
"failed to write register r2");
707 uint64_t raw_value = data.
GetMaxU64(&offset, 8);
711 raw_value = data.
GetMaxU64(&offset, num_bytes - offset);
714 error.SetErrorString(
"failed to write register r3");
716 error.SetErrorString(
"failed to write register r2");
719 error.SetErrorString(
"We don't support returning longer than 128 bit "
720 "integer values at present.");
722 }
else if (type_flags & eTypeIsFloat) {
723 error.SetErrorString(
"TODO: Handle Float Types.");
725 }
else if (type_flags & eTypeIsVector) {
726 error.SetErrorString(
"returning vector values are not supported");
735 return return_valobj_sp;
746 return return_valobj_sp;
752 return return_valobj_sp;
757 std::optional<uint64_t> byte_size = return_compiler_type.
GetByteSize(&thread);
759 return return_valobj_sp;
760 const uint32_t type_flags = return_compiler_type.
GetTypeInfo(
nullptr);
766 assert(r2_info && r3_info &&
"Basic registers should always be present.");
768 if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
771 bool success =
false;
772 if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
778 const bool is_signed = (type_flags & eTypeIsSigned) != 0;
779 switch (*byte_size) {
783 case sizeof(uint64_t):
785 value.
GetScalar() = (int64_t)(raw_value);
787 value.
GetScalar() = (uint64_t)(raw_value);
791 case sizeof(uint32_t):
799 case sizeof(uint16_t):
801 value.
GetScalar() = (int16_t)(raw_value & UINT16_MAX);
803 value.
GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
807 case sizeof(uint8_t):
809 value.
GetScalar() = (int8_t)(raw_value & UINT8_MAX);
811 value.
GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
815 }
else if (type_flags & eTypeIsFloat) {
816 if (type_flags & eTypeIsComplex) {
820 switch (*byte_size) {
822 value.
GetScalar() = *((
float *)(&raw_value));
826 value.
GetScalar() = *((
double *)(&raw_value));
832 result[0] = raw_value;
834 value.
GetScalar() = *((
long double *)(result));
837 result[1] = raw_value;
838 value.
GetScalar() = *((
long double *)(result));
845 if (*byte_size <=
sizeof(
long double)) {
856 if (*byte_size ==
sizeof(
float)) {
859 }
else if (*byte_size ==
sizeof(
double)) {
862 }
else if (*byte_size ==
sizeof(
long double)) {
871 data_sp, target_byte_order,
875 copy_from_extractor = &f0_data;
877 0, 8, data_sp->GetBytes(), *byte_size - 8, target_byte_order);
879 copy_from_extractor = &f2_data;
881 0, 8, data_sp->GetBytes() + 8, *byte_size - 8,
884 copy_from_extractor = &f0_data;
886 0, 8, data_sp->GetBytes() + 8, *byte_size - 8,
889 copy_from_extractor = &f2_data;
891 0, 8, data_sp->GetBytes(), *byte_size - 8, target_byte_order);
895 &thread, return_compiler_type,
ConstString(
""), return_ext);
896 return return_valobj_sp;
905 }
else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass ||
906 type_flags & eTypeIsVector) {
908 if (*byte_size <= 16) {
913 RegisterValue r2_value, r3_value, f0_value, f1_value, f2_value;
915 uint32_t integer_bytes = 0;
918 bool use_fp_regs =
false;
920 bool found_non_fp_field =
false;
930 const uint32_t num_children = return_compiler_type.
GetNumFields();
934 if (num_children <= 2) {
935 uint64_t field_bit_offset = 0;
938 for (uint32_t idx = 0; idx < num_children; idx++) {
946 found_non_fp_field =
true;
949 if (use_fp_regs && !found_non_fp_field) {
962 for (uint32_t idx = 0; idx < num_children; idx++) {
965 idx, name, &field_bit_offset,
nullptr,
nullptr);
966 std::optional<uint64_t> field_byte_width =
968 if (!field_byte_width)
969 return return_valobj_sp;
972 uint64_t return_value[2];
977 if (*field_byte_width == 16) {
982 return_value[0] = f0_data.
GetU64(&offset);
986 return_value[1] = f1_data.
GetU64(&offset);
988 return_value[1] = f0_data.
GetU64(&offset);
992 return_value[0] = f1_data.
GetU64(&offset);
995 f0_data.
SetData(return_value, *field_byte_width,
998 copy_from_extractor = &f0_data;
1004 copy_from_extractor = &f2_data;
1008 if (!copy_from_extractor ||
1009 *field_byte_width > copy_from_extractor->
GetByteSize())
1010 return return_valobj_sp;
1014 0, *field_byte_width,
1015 data_sp->GetBytes() + (field_bit_offset / 8), *field_byte_width,
1022 &thread, return_compiler_type,
ConstString(
""), return_ext);
1024 return return_valobj_sp;
1031 for (uint32_t idx = 0; idx < num_children; idx++) {
1032 uint64_t field_bit_offset = 0;
1037 idx, name, &field_bit_offset,
nullptr,
nullptr);
1038 std::optional<uint64_t> field_byte_width =
1043 if (!field_byte_width || *field_byte_width == 0)
1046 uint32_t field_byte_offset = field_bit_offset / 8;
1051 padding = field_byte_offset - integer_bytes;
1053 if (integer_bytes < 8) {
1055 if (integer_bytes + *field_byte_width + padding <= 8) {
1058 integer_bytes = integer_bytes + *field_byte_width +
1064 integer_bytes = integer_bytes + *field_byte_width +
1071 else if (integer_bytes + *field_byte_width + padding <= 16) {
1072 integer_bytes = integer_bytes + *field_byte_width + padding;
1079 return return_valobj_sp;
1084 if (type_flags & eTypeIsVector) {
1085 if (*byte_size <= 8)
1097 *r2_info, data_sp->GetBytes(), r2_info->
byte_size,
1098 target_byte_order,
error);
1100 return return_valobj_sp;
1106 *r3_info, data_sp->GetBytes() + r2_info->
byte_size,
1110 return return_valobj_sp;
1117 &thread, return_compiler_type,
ConstString(
""), return_ext);
1119 return return_valobj_sp;
1129 &thread,
"",
Address(mem_address,
nullptr), return_compiler_type);
1131 return return_valobj_sp;
1135 unwind_plan.
Clear();
1141 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
1156 unwind_plan.
Clear();
1161 row->SetUnspecifiedRegistersAreUndefined(
true);
1162 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
1189 bool save = (reg >= 16) && (reg <= 23);
1190 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
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.