11#include "llvm/ADT/STLExtras.h"
12#include "llvm/TargetParser/Triple.h"
559 const llvm::Triple::ArchType arch_type = arch.
GetTriple().getArch();
560 if ((arch_type == llvm::Triple::mips) ||
561 (arch_type == llvm::Triple::mipsel)) {
570 llvm::ArrayRef<addr_t> args)
const {
575 s.
Printf(
"ABISysV_mips::PrepareTrivialCall (tid = 0x%" PRIx64
576 ", sp = 0x%" PRIx64
", func_addr = 0x%" PRIx64
577 ", return_addr = 0x%" PRIx64,
578 thread.
GetID(), (uint64_t)
sp, (uint64_t)func_addr,
579 (uint64_t)return_addr);
581 for (
size_t i = 0; i < args.size(); ++i)
582 s.
Printf(
", arg%zd = 0x%" PRIx64, i + 1, args[i]);
596 const char *reg_names[] = {
"r4",
"r5",
"r6",
"r7"};
598 llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end();
601 for (
size_t i = 0; i < std::size(reg_names); ++i) {
607 LLDB_LOGF(log,
"About to write arg%zd (0x%" PRIx64
") into %s", i + 1,
608 args[i], reg_info->
name);
619 size_t num_stack_regs = args.size();
622 sp -= (num_stack_regs * 4);
625 sp &= ~(8ull - 1ull);
634 for (; ai != ae; ++ai) {
636 LLDB_LOGF(log,
"About to write arg%zd (0x%" PRIx64
") at 0x%" PRIx64
"",
637 i + 1, args[i], arg_pos);
640 ->WriteRegisterValueToMemory(reg_info, arg_pos,
659 LLDB_LOGF(log,
"Writing R0: 0x%" PRIx64, (uint64_t)0);
668 LLDB_LOGF(log,
"Writing SP: 0x%" PRIx64, (uint64_t)
sp);
674 LLDB_LOGF(log,
"Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
680 LLDB_LOGF(log,
"Writing PC: 0x%" PRIx64, (uint64_t)func_addr);
686 LLDB_LOGF(log,
"Writing r25: 0x%" PRIx64, (uint64_t)func_addr);
704 error.SetErrorString(
"Empty value object for return value.");
708 CompilerType compiler_type = new_value_sp->GetCompilerType();
709 if (!compiler_type) {
710 error.SetErrorString(
"Null clang type for return value.");
714 Thread *thread = frame_sp->GetThread().get();
722 bool set_it_simple =
false;
727 size_t num_bytes = new_value_sp->GetData(data, data_error);
728 if (data_error.
Fail()) {
729 error.SetErrorStringWithFormat(
730 "Couldn't convert return value to raw data: %s",
736 if (num_bytes <= 8) {
738 if (num_bytes <= 4) {
739 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes);
742 set_it_simple =
true;
744 uint32_t raw_value = data.
GetMaxU32(&offset, 4);
748 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes - offset);
751 set_it_simple =
true;
755 error.SetErrorString(
"We don't support returning longer than 64 bit "
756 "integer values at present.");
760 error.SetErrorString(
761 "We don't support returning complex values at present");
763 error.SetErrorString(
764 "We don't support returning float values at present");
768 error.SetErrorString(
769 "We only support setting simple integer return types at present.");
777 return return_valobj_sp;
785 if (!return_compiler_type)
786 return return_valobj_sp;
790 return return_valobj_sp;
801 return return_valobj_sp;
803 bool is_signed =
false;
804 bool is_complex =
false;
809 std::optional<uint64_t> bit_width = return_compiler_type.
GetBitSize(&thread);
811 return return_valobj_sp;
813 switch (*bit_width) {
815 return return_valobj_sp;
865 &thread,
"",
Address(mem_address,
nullptr), return_compiler_type);
866 return return_valobj_sp;
870 if (count != 1 && is_complex)
871 return return_valobj_sp;
872 switch (*bit_width) {
874 return return_valobj_sp;
876 static_assert(
sizeof(float) ==
sizeof(uint32_t));
877 value.
GetScalar() = *((
float *)(&raw_value));
880 static_assert(
sizeof(double) ==
sizeof(uint64_t));
888 raw_value = (raw_value << 32) |
890 value.
GetScalar() = *((
double *)(&raw_value));
903 if (count == 1 && !is_complex) {
904 switch (*bit_width) {
906 return return_valobj_sp;
908 static_assert(
sizeof(double) ==
sizeof(uint64_t));
916 data_sp, target_byte_order,
920 copy_from_extractor = &f0_data;
922 offset, 4, data_sp->GetBytes(), 4, target_byte_order);
924 copy_from_extractor = &f1_data;
926 offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order);
928 copy_from_extractor = &f0_data;
930 offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order);
932 copy_from_extractor = &f1_data;
934 offset, 4, data_sp->GetBytes(), 4, target_byte_order);
940 static_assert(
sizeof(float) ==
sizeof(uint32_t));
947 return return_valobj_sp;
952 return return_valobj_sp;
959 return return_valobj_sp;
969 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
989 row->SetUnspecifiedRegistersAreUndefined(
true);
990 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
1014 const char *name = reg_info->
name;
1016 if (name[0] ==
'r') {
1019 if (name[2] ==
'6' || name[2] ==
'7' || name[2] ==
'8' ||
1021 return name[3] ==
'\0';
1024 if (name[2] ==
'0' || name[2] ==
'1' || name[2] ==
'2' ||
1026 || name[2] ==
'8' || name[2] ==
'9')
1027 return name[3] ==
'\0';
1030 if (name[2] ==
'0' || name[2] ==
'1')
1031 return name[3] ==
'\0';
1035 if (name[0] ==
'g' && name[1] ==
'p' && name[2] ==
'\0')
1037 if (name[0] ==
's' && name[1] ==
'p' && name[2] ==
'\0')
1039 if (name[0] ==
'f' && name[1] ==
'p' && name[2] ==
'\0')
1041 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)
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.