11#include "llvm/ADT/STLExtras.h"
12#include "llvm/TargetParser/Triple.h"
509const lldb_private::RegisterInfo *
521 const llvm::Triple::ArchType arch_type = arch.
GetTriple().getArch();
522 if ((arch_type == llvm::Triple::mips) ||
523 (arch_type == llvm::Triple::mipsel)) {
532 llvm::ArrayRef<addr_t> args)
const {
537 s.
Printf(
"ABISysV_mips::PrepareTrivialCall (tid = 0x%" PRIx64
538 ", sp = 0x%" PRIx64
", func_addr = 0x%" PRIx64
539 ", return_addr = 0x%" PRIx64,
540 thread.
GetID(), (uint64_t)
sp, (uint64_t)func_addr,
541 (uint64_t)return_addr);
543 for (
size_t i = 0; i < args.size(); ++i)
544 s.
Printf(
", arg%zd = 0x%" PRIx64, i + 1, args[i]);
553 const RegisterInfo *reg_info =
nullptr;
558 const char *reg_names[] = {
"r4",
"r5",
"r6",
"r7"};
560 llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end();
563 for (
size_t i = 0; i < std::size(reg_names); ++i) {
569 LLDB_LOGF(log,
"About to write arg%zd (0x%" PRIx64
") into %s", i + 1,
570 args[i], reg_info->name);
581 size_t num_stack_regs = args.size();
584 sp -= (num_stack_regs * 4);
587 sp &= ~(8ull - 1ull);
596 for (; ai != ae; ++ai) {
598 LLDB_LOGF(log,
"About to write arg%zd (0x%" PRIx64
") at 0x%" PRIx64
"",
599 i + 1, args[i], arg_pos);
602 ->WriteRegisterValueToMemory(reg_info, arg_pos,
603 reg_info->byte_size, reg_value)
606 arg_pos += reg_info->byte_size;
612 const RegisterInfo *pc_reg_info =
614 const RegisterInfo *sp_reg_info =
616 const RegisterInfo *ra_reg_info =
621 LLDB_LOGF(log,
"Writing R0: 0x%" PRIx64, (uint64_t)0);
630 LLDB_LOGF(log,
"Writing SP: 0x%" PRIx64, (uint64_t)
sp);
636 LLDB_LOGF(log,
"Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
642 LLDB_LOGF(log,
"Writing PC: 0x%" PRIx64, (uint64_t)func_addr);
648 LLDB_LOGF(log,
"Writing r25: 0x%" PRIx64, (uint64_t)func_addr);
663 lldb::ValueObjectSP &new_value_sp) {
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();
684 bool set_it_simple =
false;
689 size_t num_bytes = new_value_sp->GetData(data, data_error);
690 if (data_error.
Fail()) {
691 error.SetErrorStringWithFormat(
692 "Couldn't convert return value to raw data: %s",
698 if (num_bytes <= 8) {
700 if (num_bytes <= 4) {
704 set_it_simple =
true;
713 set_it_simple =
true;
717 error.SetErrorString(
"We don't support returning longer than 64 bit "
718 "integer values at present.");
722 error.SetErrorString(
723 "We don't support returning complex values at present");
725 error.SetErrorString(
726 "We don't support returning float values at present");
730 error.SetErrorString(
731 "We only support setting simple integer return types at present.");
738 ValueObjectSP return_valobj_sp;
739 return return_valobj_sp;
744 ValueObjectSP return_valobj_sp;
747 if (!return_compiler_type)
748 return return_valobj_sp;
752 return return_valobj_sp;
763 return return_valobj_sp;
765 bool is_signed =
false;
766 bool is_complex =
false;
771 std::optional<uint64_t> bit_width = return_compiler_type.
GetBitSize(&thread);
773 return return_valobj_sp;
775 switch (*bit_width) {
777 return return_valobj_sp;
827 &thread,
"",
Address(mem_address,
nullptr), return_compiler_type);
828 return return_valobj_sp;
832 if (count != 1 && is_complex)
833 return return_valobj_sp;
834 switch (*bit_width) {
836 return return_valobj_sp;
838 static_assert(
sizeof(float) ==
sizeof(
uint32_t));
839 value.
GetScalar() = *((
float *)(&raw_value));
842 static_assert(
sizeof(double) ==
sizeof(uint64_t));
843 const RegisterInfo *r3_reg_info =
850 raw_value = (raw_value << 32) |
852 value.
GetScalar() = *((
double *)(&raw_value));
865 if (count == 1 && !is_complex) {
866 switch (*bit_width) {
868 return return_valobj_sp;
870 static_assert(
sizeof(double) ==
sizeof(uint64_t));
878 data_sp, target_byte_order,
882 copy_from_extractor = &f0_data;
884 offset, 4, data_sp->GetBytes(), 4, target_byte_order);
886 copy_from_extractor = &f1_data;
888 offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order);
890 copy_from_extractor = &f0_data;
892 offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order);
894 copy_from_extractor = &f1_data;
896 offset, 4, data_sp->GetBytes(), 4, target_byte_order);
902 static_assert(
sizeof(float) ==
sizeof(
uint32_t));
909 return return_valobj_sp;
914 return return_valobj_sp;
921 return return_valobj_sp;
931 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
951 row->SetUnspecifiedRegistersAreUndefined(
true);
952 row->GetCFAValue().SetIsRegisterPlusOffset(
dwarf_r29, 0);
976 const char *name = reg_info->name;
978 if (name[0] ==
'r') {
981 if (name[2] ==
'6' || name[2] ==
'7' || name[2] ==
'8' ||
983 return name[3] ==
'\0';
986 if (name[2] ==
'0' || name[2] ==
'1' || name[2] ==
'2' ||
988 || name[2] ==
'8' || name[2] ==
'9')
989 return name[3] ==
'\0';
992 if (name[2] ==
'0' || name[2] ==
'1')
993 return name[3] ==
'\0';
997 if (name[0] ==
'g' && name[1] ==
'p' && name[2] ==
'\0')
999 if (name[0] ==
's' && name[1] ==
'p' && name[2] ==
'\0')
1001 if (name[0] ==
'f' && name[1] ==
'p' && name[2] ==
'\0')
1003 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.
@ 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.