11#include "llvm/ADT/STLExtras.h"
12#include "llvm/TargetParser/Triple.h"
115#define DEFINE_REG(name, size, alt, generic) \
117 #name, alt, size, 0, eEncodingUint, eFormatHex, \
118 {dwarf_##name##_s390x, dwarf_##name##_s390x, generic, \
119 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, \
120 nullptr, nullptr, nullptr, \
190 if (arch.
GetTriple().getArch() == llvm::Triple::systemz) {
198 llvm::ArrayRef<addr_t> args)
const {
203 s.
Printf(
"ABISysV_s390x::PrepareTrivialCall (tid = 0x%" PRIx64
204 ", sp = 0x%" PRIx64
", func_addr = 0x%" PRIx64
205 ", return_addr = 0x%" PRIx64,
206 thread.
GetID(), (uint64_t)
sp, (uint64_t)func_addr,
207 (uint64_t)return_addr);
209 for (
size_t i = 0; i < args.size(); ++i)
210 s.
Printf(
", arg%" PRIu64
" = 0x%" PRIx64,
static_cast<uint64_t
>(i + 1),
230 if (args.size() > 5) {
231 sp -= 8 * (args.size() - 5);
239 for (
size_t i = 0; i < args.size(); ++i) {
243 LLDB_LOGF(log,
"About to write arg%" PRIu64
" (0x%" PRIx64
") into %s",
244 static_cast<uint64_t
>(i + 1), args[i], reg_info->
name);
249 LLDB_LOGF(log,
"About to write arg%" PRIu64
" (0x%" PRIx64
") onto stack",
250 static_cast<uint64_t
>(i + 1), args[i]);
251 if (!process_sp->WritePointerToMemory(arg_pos, args[i],
error))
259 LLDB_LOGF(log,
"Writing RA: 0x%" PRIx64, (uint64_t)return_addr);
266 LLDB_LOGF(log,
"Writing SP: 0x%" PRIx64, (uint64_t)
sp);
273 LLDB_LOGF(log,
"Writing PC: 0x%" PRIx64, (uint64_t)func_addr);
282 bool is_signed,
Thread &thread,
283 uint32_t *argument_register_ids,
284 unsigned int ¤t_argument_register,
285 addr_t ¤t_stack_argument) {
289 if (current_argument_register < 5) {
291 argument_register_ids[current_argument_register], 0);
292 current_argument_register++;
296 uint32_t byte_size = (bit_width + (8 - 1)) / 8;
298 if (thread.
GetProcess()->ReadScalarIntegerFromMemory(
299 current_stack_argument + 8 - byte_size, byte_size, is_signed,
301 current_stack_argument += 8;
310 unsigned int num_values = values.
GetSize();
311 unsigned int value_index;
328 addr_t current_stack_argument =
sp + 160;
330 uint32_t argument_register_ids[5];
332 argument_register_ids[0] =
335 argument_register_ids[1] =
338 argument_register_ids[2] =
341 argument_register_ids[3] =
344 argument_register_ids[4] =
348 unsigned int current_argument_register = 0;
350 for (value_index = 0; value_index < num_values; ++value_index) {
359 std::optional<uint64_t> bit_size = compiler_type.
GetBitSize(&thread);
366 argument_register_ids, current_argument_register,
367 current_stack_argument);
370 argument_register_ids, current_argument_register,
371 current_stack_argument);
386 CompilerType compiler_type = new_value_sp->GetCompilerType();
387 if (!compiler_type) {
392 Thread *thread = frame_sp->GetThread().get();
400 bool set_it_simple =
false;
407 size_t num_bytes = new_value_sp->GetData(data, data_error);
408 if (data_error.
Fail()) {
410 "Couldn't convert return value to raw data: %s",
415 if (num_bytes <= 8) {
416 uint64_t raw_value = data.
GetMaxU64(&offset, num_bytes);
419 set_it_simple =
true;
422 "We don't support returning longer than 64 bit "
423 "integer values at present.");
428 "We don't support returning complex values at present");
430 std::optional<uint64_t> bit_width =
436 if (*bit_width <= 64) {
441 size_t num_bytes = new_value_sp->GetData(data, data_error);
442 if (data_error.
Fail()) {
444 "Couldn't convert return value to raw data: %s",
449 unsigned char buffer[8];
453 f0_value.
SetBytes(buffer, 8, byte_order);
455 set_it_simple =
true;
459 "We don't support returning float values > 64 bits at present");
464 if (!set_it_simple) {
469 "We only support setting simple integer and float "
470 "return types at present.");
481 if (!return_compiler_type)
482 return return_valobj_sp;
489 return return_valobj_sp;
491 const uint32_t type_flags = return_compiler_type.
GetTypeInfo();
492 if (type_flags & eTypeIsScalar) {
495 bool success =
false;
496 if (type_flags & eTypeIsInteger) {
498 std::optional<uint64_t> byte_size =
501 return return_valobj_sp;
504 const bool is_signed = (type_flags & eTypeIsSigned) != 0;
505 switch (*byte_size) {
509 case sizeof(uint64_t):
511 value.
GetScalar() = (int64_t)(raw_value);
513 value.
GetScalar() = (uint64_t)(raw_value);
517 case sizeof(uint32_t):
525 case sizeof(uint16_t):
527 value.
GetScalar() = (int16_t)(raw_value & UINT16_MAX);
529 value.
GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
533 case sizeof(uint8_t):
535 value.
GetScalar() = (int8_t)(raw_value & UINT8_MAX);
537 value.
GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
541 }
else if (type_flags & eTypeIsFloat) {
542 if (type_flags & eTypeIsComplex) {
545 std::optional<uint64_t> byte_size =
547 if (byte_size && *byte_size <=
sizeof(
long double)) {
554 if (*byte_size ==
sizeof(
float)) {
557 }
else if (*byte_size ==
sizeof(
double)) {
560 }
else if (*byte_size ==
sizeof(
long double)) {
572 }
else if (type_flags & eTypeIsPointer) {
582 return return_valobj_sp;
589 if (!return_compiler_type)
590 return return_valobj_sp;
594 if (return_valobj_sp)
595 return return_valobj_sp;
599 return return_valobj_sp;
614 &thread,
"",
Address(storage_addr,
nullptr), return_compiler_type);
617 return return_valobj_sp;
669 const char *name = reg_info->
name;
670 if (name[0] ==
'r') {
676 return name[2] ==
'\0';
679 if ((name[2] >=
'0' && name[2] <=
'3') || name[2] ==
'5')
680 return name[3] ==
'\0';
687 if (name[0] ==
'f') {
691 return name[2] ==
'\0';
694 if (name[2] >=
'0' && name[2] <=
'5')
695 return name[3] ==
'\0';
704 if (name[0] ==
's' && name[1] ==
'p' && name[2] ==
'\0')
706 if (name[0] ==
'f' && name[1] ==
'p' && name[2] ==
'\0')
708 if (name[0] ==
'p' && name[1] ==
'c' && name[2] ==
'\0')
static const uint32_t k_num_register_infos
static const RegisterInfo g_register_infos[]
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 const uint32_t k_num_register_infos
static const RegisterInfo g_register_infos[]
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)
#define DEFINE_REG(name, size, alt, generic)
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
#define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName)
lldb_private::Status SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override
bool CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override
bool GetFallbackRegisterLocation(const lldb_private::RegisterInfo *reg_info, lldb_private::UnwindPlan::Row::AbstractRegisterLocation &unwind_regloc) override
lldb::ValueObjectSP GetReturnValueObjectSimple(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const
bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override
const lldb_private::RegisterInfo * GetRegisterInfoArray(uint32_t &count) override
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch)
lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread, lldb_private::CompilerType &type) const override
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info)
bool GetArgumentValues(lldb_private::Thread &thread, lldb_private::ValueList &values) const 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
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.
A section + offset based address class.
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
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.
bool IsFloatingPointType(uint32_t &count, bool &is_complex) const
bool IsIntegerOrEnumerationType(bool &is_signed) const
bool IsAggregateType() const
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) 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.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
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 GetSP(uint64_t fail_value=LLDB_INVALID_ADDRESS)
virtual bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value)=0
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 SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order)
bool SignExtend(uint32_t bit_pos)
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.
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
virtual lldb::RegisterContextSP GetRegisterContext()=0
lldb::ProcessSP GetProcess() const
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 *)
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)
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)
const CompilerType & GetCompilerType()
#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
#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.
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
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
@ 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 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.
lldb::user_id_t GetID() const
Get accessor for the user ID.