11#include "llvm/ADT/STLExtras.h"
12#include "llvm/TargetParser/Triple.h"
509const lldb_private::RegisterInfo *
529 llvm::ArrayRef<addr_t> args)
const {
534 s.
Printf(
"ABISysV_mips64::PrepareTrivialCall (tid = 0x%" PRIx64
535 ", sp = 0x%" PRIx64
", func_addr = 0x%" PRIx64
536 ", return_addr = 0x%" PRIx64,
537 thread.
GetID(), (uint64_t)
sp, (uint64_t)func_addr,
538 (uint64_t)return_addr);
540 for (
size_t i = 0; i < args.size(); ++i)
541 s.
Printf(
", arg%zd = 0x%" PRIx64, i + 1, args[i]);
550 const RegisterInfo *reg_info =
nullptr;
555 for (
size_t i = 0; i < args.size(); ++i) {
558 LLDB_LOGF(log,
"About to write arg%zd (0x%" PRIx64
") into %s", i + 1,
559 args[i], reg_info->name);
566 LLDB_LOGF(log,
"16-byte aligning SP: 0x%" PRIx64
" to 0x%" PRIx64,
567 (uint64_t)
sp, (uint64_t)(
sp & ~0xfull));
572 const RegisterInfo *pc_reg_info =
574 const RegisterInfo *sp_reg_info =
576 const RegisterInfo *ra_reg_info =
581 LLDB_LOGF(log,
"Writing R0: 0x%" PRIx64, (uint64_t)0);
590 LLDB_LOGF(log,
"Writing SP: 0x%" PRIx64, (uint64_t)
sp);
596 LLDB_LOGF(log,
"Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
602 LLDB_LOGF(log,
"Writing PC: 0x%" PRIx64, (uint64_t)func_addr);
608 LLDB_LOGF(log,
"Writing r25: 0x%" PRIx64, (uint64_t)func_addr);
624 lldb::ValueObjectSP &new_value_sp) {
627 error.SetErrorString(
"Empty value object for return value.");
631 CompilerType compiler_type = new_value_sp->GetCompilerType();
632 if (!compiler_type) {
633 error.SetErrorString(
"Null clang type for return value.");
637 Thread *thread = frame_sp->GetThread().get();
642 error.SetErrorString(
"no registers are available");
646 size_t num_bytes = new_value_sp->GetData(data, data_error);
647 if (data_error.
Fail()) {
648 error.SetErrorStringWithFormat(
649 "Couldn't convert return value to raw data: %s",
656 if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
657 if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
660 if (num_bytes <= 16) {
662 if (num_bytes <= 8) {
663 uint64_t raw_value = data.
GetMaxU64(&offset, num_bytes);
666 error.SetErrorString(
"failed to write register r2");
668 uint64_t raw_value = data.
GetMaxU64(&offset, 8);
670 const RegisterInfo *r3_info =
672 raw_value = data.
GetMaxU64(&offset, num_bytes - offset);
675 error.SetErrorString(
"failed to write register r3");
677 error.SetErrorString(
"failed to write register r2");
680 error.SetErrorString(
"We don't support returning longer than 128 bit "
681 "integer values at present.");
683 }
else if (type_flags & eTypeIsFloat) {
684 error.SetErrorString(
"TODO: Handle Float Types.");
686 }
else if (type_flags & eTypeIsVector) {
687 error.SetErrorString(
"returning vector values are not supported");
695 ValueObjectSP return_valobj_sp;
696 return return_valobj_sp;
701 ValueObjectSP return_valobj_sp;
707 return return_valobj_sp;
713 return return_valobj_sp;
718 std::optional<uint64_t> byte_size = return_compiler_type.
GetByteSize(&thread);
720 return return_valobj_sp;
727 assert(r2_info && r3_info &&
"Basic registers should always be present.");
729 if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
732 bool success =
false;
733 if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
739 const bool is_signed = (type_flags & eTypeIsSigned) != 0;
740 switch (*byte_size) {
744 case sizeof(uint64_t):
746 value.
GetScalar() = (int64_t)(raw_value);
748 value.
GetScalar() = (uint64_t)(raw_value);
762 value.
GetScalar() = (int16_t)(raw_value & UINT16_MAX);
768 case sizeof(uint8_t):
770 value.
GetScalar() = (int8_t)(raw_value & UINT8_MAX);
772 value.
GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
776 }
else if (type_flags & eTypeIsFloat) {
777 if (type_flags & eTypeIsComplex) {
781 switch (*byte_size) {
783 value.
GetScalar() = *((
float *)(&raw_value));
787 value.
GetScalar() = *((
double *)(&raw_value));
793 result[0] = raw_value;
795 value.
GetScalar() = *((
long double *)(result));
798 result[1] = raw_value;
799 value.
GetScalar() = *((
long double *)(result));
806 if (*byte_size <=
sizeof(
long double)) {
817 if (*byte_size ==
sizeof(
float)) {
820 }
else if (*byte_size ==
sizeof(
double)) {
823 }
else if (*byte_size ==
sizeof(
long double)) {
824 const RegisterInfo *f2_info =
832 data_sp, target_byte_order,
836 copy_from_extractor = &f0_data;
838 0, 8, data_sp->GetBytes(), *byte_size - 8, target_byte_order);
840 copy_from_extractor = &f2_data;
842 0, 8, data_sp->GetBytes() + 8, *byte_size - 8,
845 copy_from_extractor = &f0_data;
847 0, 8, data_sp->GetBytes() + 8, *byte_size - 8,
850 copy_from_extractor = &f2_data;
852 0, 8, data_sp->GetBytes(), *byte_size - 8, target_byte_order);
856 &thread, return_compiler_type,
ConstString(
""), return_ext);
857 return return_valobj_sp;
866 }
else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass ||
867 type_flags & eTypeIsVector) {
869 if (*byte_size <= 16) {
874 RegisterValue r2_value, r3_value, f0_value, f1_value, f2_value;
879 bool use_fp_regs =
false;
881 bool found_non_fp_field =
false;
895 if (num_children <= 2) {
896 uint64_t field_bit_offset = 0;
899 for (
uint32_t idx = 0; idx < num_children; idx++) {
907 found_non_fp_field =
true;
910 if (use_fp_regs && !found_non_fp_field) {
923 for (
uint32_t idx = 0; idx < num_children; idx++) {
926 idx, name, &field_bit_offset,
nullptr,
nullptr);
927 std::optional<uint64_t> field_byte_width =
929 if (!field_byte_width)
930 return return_valobj_sp;
933 uint64_t return_value[2];
938 if (*field_byte_width == 16) {
943 return_value[0] = f0_data.
GetU64(&offset);
947 return_value[1] = f1_data.
GetU64(&offset);
949 return_value[1] = f0_data.
GetU64(&offset);
953 return_value[0] = f1_data.
GetU64(&offset);
956 f0_data.
SetData(return_value, *field_byte_width,
959 copy_from_extractor = &f0_data;
965 copy_from_extractor = &f2_data;
969 if (!copy_from_extractor ||
970 *field_byte_width > copy_from_extractor->
GetByteSize())
971 return return_valobj_sp;
975 0, *field_byte_width,
976 data_sp->GetBytes() + (field_bit_offset / 8), *field_byte_width,
983 &thread, return_compiler_type,
ConstString(
""), return_ext);
985 return return_valobj_sp;
992 for (
uint32_t idx = 0; idx < num_children; idx++) {
993 uint64_t field_bit_offset = 0;
998 idx, name, &field_bit_offset,
nullptr,
nullptr);
999 std::optional<uint64_t> field_byte_width =
1004 if (!field_byte_width || *field_byte_width == 0)
1007 uint32_t field_byte_offset = field_bit_offset / 8;
1012 padding = field_byte_offset - integer_bytes;
1014 if (integer_bytes < 8) {
1016 if (integer_bytes + *field_byte_width + padding <= 8) {
1019 integer_bytes = integer_bytes + *field_byte_width +
1025 integer_bytes = integer_bytes + *field_byte_width +
1032 else if (integer_bytes + *field_byte_width + padding <= 16) {
1033 integer_bytes = integer_bytes + *field_byte_width + padding;
1040 return return_valobj_sp;
1045 if (type_flags & eTypeIsVector) {
1046 if (*byte_size <= 8)
1058 *r2_info, data_sp->GetBytes(), r2_info->byte_size,
1059 target_byte_order,
error);
1060 if (bytes_copied != r2_info->byte_size)
1061 return return_valobj_sp;
1067 *r3_info, data_sp->GetBytes() + r2_info->byte_size,
1068 r3_info->byte_size, target_byte_order,
error);
1070 if (bytes_copied != r3_info->byte_size)
1071 return return_valobj_sp;
1078 &thread, return_compiler_type,
ConstString(
""), return_ext);
1080 return return_valobj_sp;
1090 &thread,
"",
Address(mem_address,
nullptr), return_compiler_type);
1092 return return_valobj_sp;
1096 unwind_plan.
Clear();
1102 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
1117 unwind_plan.
Clear();
1122 row->SetUnspecifiedRegistersAreUndefined(
true);
1123 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
1148 int reg = ((reg_info->byte_offset) / 8);
1150 bool save = (reg >= 16) && (reg <= 23);
1151 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.
@ 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
lldb::user_id_t GetID() const
Get accessor for the user ID.