14#include "llvm/ADT/STLExtras.h"
15#include "llvm/TargetParser/Triple.h"
53 if ((arch.
GetTriple().getArch() == llvm::Triple::x86) &&
64 llvm::ArrayRef<addr_t> args)
const {
87 sp -= 4 * args.size();
90 sp &= ~(16ull - 1ull);
97 reg_info_32, arg_pos, reg_info_32->
byte_size, reg_value);
108 reg_info_32,
sp, reg_info_32->
byte_size, reg_value);
126 bool is_signed,
Process *process,
127 addr_t ¤t_stack_argument) {
129 uint32_t byte_size = (bit_width + (8 - 1)) / 8;
132 is_signed, scalar,
error)) {
133 current_stack_argument += byte_size;
141 unsigned int num_values = values.
GetSize();
142 unsigned int value_index;
157 addr_t current_stack_argument =
sp + 4;
159 for (value_index = 0; value_index < num_values; ++value_index) {
168 std::optional<uint64_t> bit_size = compiler_type.
GetBitSize(&thread);
173 thread.
GetProcess().get(), current_stack_argument);
176 thread.
GetProcess().get(), current_stack_argument);
187 error.SetErrorString(
"Empty value object for return value.");
191 CompilerType compiler_type = new_value_sp->GetCompilerType();
192 if (!compiler_type) {
193 error.SetErrorString(
"Null clang type for return value.");
197 Thread *thread = frame_sp->GetThread().get();
205 bool set_it_simple =
false;
210 size_t num_bytes = new_value_sp->GetData(data, data_error);
211 if (data_error.
Fail()) {
212 error.SetErrorStringWithFormat(
213 "Couldn't convert return value to raw data: %s",
218 if (num_bytes <= 8) {
220 if (num_bytes <= 4) {
221 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes);
224 set_it_simple =
true;
226 uint32_t raw_value = data.
GetMaxU32(&offset, 4);
231 uint32_t raw_value = data.
GetMaxU32(&offset, num_bytes - offset);
234 set_it_simple =
true;
238 error.SetErrorString(
"We don't support returning longer than 64 bit "
239 "integer values at present.");
243 error.SetErrorString(
244 "We don't support returning complex values at present");
246 error.SetErrorString(
247 "We don't support returning float values at present");
251 error.SetErrorString(
252 "We only support setting simple integer return types at present.");
264 return return_valobj_sp;
272 return return_valobj_sp;
277 std::optional<uint64_t> bit_width = compiler_type.
GetBitSize(&thread);
279 return return_valobj_sp;
285 switch (*bit_width) {
289 return return_valobj_sp;
344 return return_valobj_sp;
351 return return_valobj_sp;
366 row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 4);
367 row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -4,
false);
368 row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0,
true);
389 const int32_t ptr_size = 4;
391 row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
393 row->SetUnspecifiedRegistersAreUndefined(
true);
395 row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2,
true);
396 row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1,
true);
397 row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0,
true);
425 const char *name = reg_info->
name;
426 if (name[0] ==
'e') {
429 if (name[2] ==
'x' || name[2] ==
'p')
430 return name[3] ==
'\0';
434 return name[3] ==
'\0';
438 return name[3] ==
'\0';
441 if (name[2] ==
'i' || name[2] ==
'p')
442 return name[3] ==
'\0';
446 if (name[0] ==
's' && name[1] ==
'p' && name[2] ==
'\0')
448 if (name[0] ==
'f' && name[1] ==
'p' && name[2] ==
'\0')
450 if (name[0] ==
'p' && name[1] ==
'c' && name[2] ==
'\0')
static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width, bool is_signed, Process *process, addr_t ¤t_stack_argument)
static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width, bool is_signed, Thread &thread, uint32_t *argument_register_ids, unsigned int ¤t_argument_register, addr_t ¤t_stack_argument)
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_PLUGIN_DEFINE(PluginName)
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info)
bool GetArgumentValues(lldb_private::Thread &thread, lldb_private::ValueList &values) const override
bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch)
bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, lldb::addr_t func_addr, lldb::addr_t return_addr, llvm::ArrayRef< lldb::addr_t > args) const override
bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override
bool CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const override
lldb_private::Status SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override
static llvm::StringRef GetPluginNameStatic()
size_t GetRedZoneSize() const override
static std::unique_ptr< llvm::MCRegisterInfo > MakeMCRegisterInfo(const ArchSpec &arch)
Utility function to construct a MCRegisterInfo using the ArchSpec triple.
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
Generic representation of a type in a programming language.
bool IsFloatingPointType(uint32_t &count, bool &is_complex) const
bool IsIntegerOrEnumerationType(bool &is_signed) 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.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
size_t ReadScalarIntegerFromMemory(lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Status &error)
virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num)
Convert from a given register numbering scheme to the lldb register numbering scheme.
uint64_t GetSP(uint64_t fail_value=LLDB_INVALID_ADDRESS)
virtual Status WriteRegisterValueToMemory(const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue ®_value)
bool WriteRegisterFromUnsigned(uint32_t reg, uint64_t uval)
const RegisterInfo * GetRegisterInfoByName(llvm::StringRef reg_name, uint32_t start_idx=0)
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.
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
virtual lldb::RegisterContextSP GetRegisterContext()=0
lldb::ProcessSP GetProcess() const
void SetUnwindPlanForSignalTrap(lldb_private::LazyBool is_for_signal_trap)
void SetRegisterKind(lldb::RegisterKind kind)
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)
Value * GetValueAtIndex(size_t idx)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
const Scalar & GetScalar() const
void SetCompilerType(const CompilerType &compiler_type)
const CompilerType & GetCompilerType()
#define LLDB_REGNUM_GENERIC_SP
#define LLDB_REGNUM_GENERIC_PC
A class that represents a running process on the host machine.
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
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
@ eRegisterKindLLDB
lldb's internal register numbers
@ 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.
uint32_t kinds[lldb::kNumRegisterKinds]
Holds all of the various register numbers for all register kinds.
const char * name
Name of this register, can't be NULL.