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),
225 ProcessSP process_sp(thread.GetProcess());
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) {
290 scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
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 =
360 llvm::expectedToOptional(compiler_type.
GetBitSize(&thread));
367 argument_register_ids, current_argument_register,
368 current_stack_argument);
371 argument_register_ids, current_argument_register,
372 current_stack_argument);
387 CompilerType compiler_type = new_value_sp->GetCompilerType();
388 if (!compiler_type) {
393 Thread *thread = frame_sp->GetThread().get();
401 bool set_it_simple =
false;
408 size_t num_bytes = new_value_sp->GetData(data, data_error);
409 if (data_error.
Fail()) {
411 "Couldn't convert return value to raw data: %s",
416 if (num_bytes <= 8) {
417 uint64_t raw_value = data.
GetMaxU64(&offset, num_bytes);
420 set_it_simple =
true;
423 "We don't support returning longer than 64 bit "
424 "integer values at present.");
429 "We don't support returning complex values at present");
431 std::optional<uint64_t> bit_width =
432 llvm::expectedToOptional(compiler_type.
GetBitSize(frame_sp.get()));
437 if (*bit_width <= 64) {
442 size_t num_bytes = new_value_sp->GetData(data, data_error);
443 if (data_error.
Fail()) {
445 "Couldn't convert return value to raw data: %s",
450 unsigned char buffer[8];
454 f0_value.
SetBytes(buffer, 8, byte_order);
456 set_it_simple =
true;
460 "We don't support returning float values > 64 bits at present");
465 if (!set_it_simple) {
470 "We only support setting simple integer and float "
471 "return types at present.");
482 if (!return_compiler_type)
483 return return_valobj_sp;
490 return return_valobj_sp;
492 const uint32_t type_flags = return_compiler_type.
GetTypeInfo();
493 if (type_flags & eTypeIsScalar) {
496 bool success =
false;
497 if (type_flags & eTypeIsInteger) {
499 std::optional<uint64_t> byte_size =
500 llvm::expectedToOptional(return_compiler_type.
GetByteSize(&thread));
502 return return_valobj_sp;
503 uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
505 const bool is_signed = (type_flags & eTypeIsSigned) != 0;
506 switch (*byte_size) {
510 case sizeof(uint64_t):
512 value.
GetScalar() = (int64_t)(raw_value);
514 value.
GetScalar() = (uint64_t)(raw_value);
518 case sizeof(uint32_t):
526 case sizeof(uint16_t):
528 value.
GetScalar() = (int16_t)(raw_value & UINT16_MAX);
530 value.
GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
534 case sizeof(uint8_t):
536 value.
GetScalar() = (int8_t)(raw_value & UINT8_MAX);
538 value.
GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
542 }
else if (type_flags & eTypeIsFloat) {
543 if (type_flags & eTypeIsComplex) {
546 std::optional<uint64_t> byte_size =
547 llvm::expectedToOptional(return_compiler_type.
GetByteSize(&thread));
548 if (byte_size && *byte_size <=
sizeof(
long double)) {
555 if (*byte_size ==
sizeof(
float)) {
558 }
else if (*byte_size ==
sizeof(
double)) {
561 }
else if (*byte_size ==
sizeof(
long double)) {
572 thread.GetStackFrameAtIndex(0).get(), value,
ConstString(
""));
573 }
else if (type_flags & eTypeIsPointer) {
577 (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_id, 0);
580 thread.GetStackFrameAtIndex(0).get(), value,
ConstString(
""));
583 return return_valobj_sp;
590 if (!return_compiler_type)
591 return return_valobj_sp;
595 if (return_valobj_sp)
596 return return_valobj_sp;
600 return return_valobj_sp;
613 (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_id, 0);
615 &thread,
"",
Address(storage_addr,
nullptr), return_compiler_type);
618 return return_valobj_sp;
632 plan_sp->AppendRow(std::move(row));
633 plan_sp->SetSourceName(
"s390x at-func-entry default");
668 const char *name = reg_info->
name;
669 if (name[0] ==
'r') {
675 return name[2] ==
'\0';
678 if ((name[2] >=
'0' && name[2] <=
'3') || name[2] ==
'5')
679 return name[3] ==
'\0';
686 if (name[0] ==
'f') {
690 return name[2] ==
'\0';
693 if (name[2] >=
'0' && name[2] <=
'5')
694 return name[3] ==
'\0';
703 if (name[0] ==
's' && name[1] ==
'p' && name[2] ==
'\0')
705 if (name[0] ==
'f' && name[1] ==
'p' && name[2] ==
'\0')
707 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 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::UnwindPlanSP CreateDefaultUnwindPlan() override
lldb_private::Status SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) 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::UnwindPlanSP CreateFunctionEntryUnwindPlan() override
lldb::ValueObjectSP GetReturnValueObjectSimple(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const
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.
llvm::Expected< 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
llvm::Expected< 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.
void SetIsRegisterPlusOffset(uint32_t reg_num, int32_t offset)
const FAValue & GetCFAValue() const
bool SetRegisterLocationToRegister(uint32_t reg_num, uint32_t other_reg_num, bool can_replace)
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
See comment on m_scalar to understand what GetScalar returns.
@ Scalar
A raw scalar value.
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::UnwindPlan > UnwindPlanSP
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.