11#include "llvm/ADT/STLExtras.h"
12#include "llvm/TargetParser/Triple.h"
553 const llvm::Triple::ArchType arch_type = arch.
GetTriple().getArch();
554 if ((arch_type == llvm::Triple::mips) ||
555 (arch_type == llvm::Triple::mipsel)) {
564 llvm::ArrayRef<addr_t> args)
const {
569 s.
Printf(
"ABISysV_mips::PrepareTrivialCall (tid = 0x%" PRIx64
570 ", sp = 0x%" PRIx64
", func_addr = 0x%" PRIx64
571 ", return_addr = 0x%" PRIx64,
572 thread.
GetID(), (uint64_t)
sp, (uint64_t)func_addr,
573 (uint64_t)return_addr);
575 for (
size_t i = 0; i < args.size(); ++i)
576 s.
Printf(
", arg%zd = 0x%" PRIx64, i + 1, args[i]);
590 const char *reg_names[] = {
"r4",
"r5",
"r6",
"r7"};
592 llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end();
595 for (
size_t i = 0; i < std::size(reg_names); ++i) {
601 LLDB_LOGF(log,
"About to write arg%zd (0x%" PRIx64
") into %s", i + 1,
602 args[i], reg_info->
name);
613 size_t num_stack_regs = args.size();
616 sp -= (num_stack_regs * 4);
619 sp &= ~(8ull - 1ull);
628 for (; ai != ae; ++ai) {
630 LLDB_LOGF(log,
"About to write arg%zd (0x%" PRIx64
") at 0x%" PRIx64
"",
631 i + 1, args[i], arg_pos);
634 ->WriteRegisterValueToMemory(reg_info, arg_pos,
653 LLDB_LOGF(log,
"Writing R0: 0x%" PRIx64, (uint64_t)0);
662 LLDB_LOGF(log,
"Writing SP: 0x%" PRIx64, (uint64_t)
sp);
668 LLDB_LOGF(log,
"Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
674 LLDB_LOGF(log,
"Writing PC: 0x%" PRIx64, (uint64_t)func_addr);
680 LLDB_LOGF(log,
"Writing r25: 0x%" PRIx64, (uint64_t)func_addr);
702 CompilerType compiler_type = new_value_sp->GetCompilerType();
703 if (!compiler_type) {
708 Thread *thread = frame_sp->GetThread().get();
716 bool set_it_simple =
false;
721 size_t num_bytes = new_value_sp->GetData(data, data_error);
722 if (data_error.
Fail()) {
724 "Couldn't convert return value to raw data: %s",
730 if (num_bytes <= 8) {
732 if (num_bytes <= 4) {
733 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes);
736 set_it_simple =
true;
738 uint32_t raw_value = data.
GetMaxU32(&offset, 4);
742 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes - offset);
745 set_it_simple =
true;
750 "We don't support returning longer than 64 bit "
751 "integer values at present.");
756 "We don't support returning complex values at present");
759 "We don't support returning float values at present");
764 "We only support setting simple integer return types at present.");
772 return return_valobj_sp;
780 if (!return_compiler_type)
781 return return_valobj_sp;
785 return return_valobj_sp;
796 return return_valobj_sp;
798 bool is_signed =
false;
799 bool is_complex =
false;
804 std::optional<uint64_t> bit_width = return_compiler_type.
GetBitSize(&thread);
806 return return_valobj_sp;
808 switch (*bit_width) {
810 return return_valobj_sp;
860 &thread,
"",
Address(mem_address,
nullptr), return_compiler_type);
861 return return_valobj_sp;
865 if (count != 1 && is_complex)
866 return return_valobj_sp;
867 switch (*bit_width) {
869 return return_valobj_sp;
871 static_assert(
sizeof(float) ==
sizeof(uint32_t));
872 value.
GetScalar() = *((
float *)(&raw_value));
875 static_assert(
sizeof(double) ==
sizeof(uint64_t));
883 raw_value = (raw_value << 32) |
885 value.
GetScalar() = *((
double *)(&raw_value));
898 if (count == 1 && !is_complex) {
899 switch (*bit_width) {
901 return return_valobj_sp;
903 static_assert(
sizeof(double) ==
sizeof(uint64_t));
911 data_sp, target_byte_order,
915 copy_from_extractor = &f0_data;
917 offset, 4, data_sp->GetBytes(), 4, target_byte_order);
919 copy_from_extractor = &f1_data;
921 offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order);
923 copy_from_extractor = &f0_data;
925 offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order);
927 copy_from_extractor = &f1_data;
929 offset, 4, data_sp->GetBytes(), 4, target_byte_order);
935 static_assert(
sizeof(float) ==
sizeof(uint32_t));
942 return return_valobj_sp;
947 return return_valobj_sp;
954 return return_valobj_sp;
964 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
984 row->SetUnspecifiedRegistersAreUndefined(
true);
985 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
1009 const char *name = reg_info->
name;
1011 if (name[0] ==
'r') {
1014 if (name[2] ==
'6' || name[2] ==
'7' || name[2] ==
'8' ||
1016 return name[3] ==
'\0';
1019 if (name[2] ==
'0' || name[2] ==
'1' || name[2] ==
'2' ||
1021 || name[2] ==
'8' || name[2] ==
'9')
1022 return name[3] ==
'\0';
1025 if (name[2] ==
'0' || name[2] ==
'1')
1026 return name[3] ==
'\0';
1030 if (name[0] ==
'g' && name[1] ==
'p' && name[2] ==
'\0')
1032 if (name[0] ==
's' && name[1] ==
'p' && name[2] ==
'\0')
1034 if (name[0] ==
'f' && name[1] ==
'p' && name[2] ==
'\0')
1036 if (name[0] ==
'r' && name[1] ==
'a' && name[2] ==
'\0')
static const uint32_t k_num_register_infos
static const RegisterInfo g_register_infos[]
static const uint32_t k_num_register_infos
static const RegisterInfo g_register_infos[]
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override
static llvm::StringRef GetPluginNameStatic()
lldb_private::Status SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override
lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread, lldb_private::CompilerType &type) const override
bool CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
bool IsSoftFloat(uint32_t fp_flag) const
const lldb_private::RegisterInfo * GetRegisterInfoArray(uint32_t &count) override
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch)
bool GetArgumentValues(lldb_private::Thread &thread, lldb_private::ValueList &values) const override
lldb::ValueObjectSP GetReturnValueObjectSimple(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const
bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) 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
size_t GetRedZoneSize() const override
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info)
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.
bool IsFloatingPointType(uint32_t &count, bool &is_complex) const
bool IsIntegerOrEnumerationType(bool &is_signed) const
bool IsAggregateType() const
std::optional< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
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
void SetUInt32(uint32_t uint, Type t=eTypeUInt32)
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)
#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.
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_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.