20#include <sys/ptrace.h>
24#define PTRACE_GETREGS 12
28#define PTRACE_SETREGS 13
31#ifndef PTRACE_GETFPREGS
32#define PTRACE_GETFPREGS 14
35#ifndef PTRACE_SETFPREGS
36#define PTRACE_SETFPREGS 15
39#ifndef PTRACE_GETREGSET
40#define PTRACE_GETREGSET 0x4204
43#ifndef PTRACE_SETREGSET
44#define PTRACE_SETREGSET 0x4205
51 return m_thread.GetProcess().GetByteOrder();
68 uint32_t reg_to_write = reg_index;
73 assert(reg_info &&
"Expected valid register info for reg_index.");
94 *full_reg_info, dst.
data(), dst.size(), byte_order,
error);
95 if (
error.Success() && dest_size) {
100 *reg_info, src.
data(), src.size(), byte_order,
error);
101 if (
error.Success() && src_size && (src_size < dest_size)) {
103 memcpy(dst.data() + (reg_info->
byte_offset & 0x1), src.data(),
108 value_to_write.
SetType(*full_reg_info);
109 reg_to_write = full_reg;
116 assert(register_to_write_info_p &&
117 "register to write does not have valid RegisterInfo");
118 if (!register_to_write_info_p)
120 "NativeRegisterContextLinux::%s failed to get RegisterInfo "
121 "for write register index %" PRIu32,
122 __FUNCTION__, reg_to_write);
151 unsigned int regset) {
153 static_cast<void *
>(®set), buf,
158 unsigned int regset) {
160 static_cast<void *
>(®set), buf,
165 const char *reg_name,
172 PTRACE_PEEKUSER,
m_thread.GetID(),
reinterpret_cast<void *
>(offset),
177 value.
SetUInt(
static_cast<unsigned long>(data), size);
179 LLDB_LOG(log,
"{0}: {1:x}", reg_name, data);
184 uint32_t offset,
const char *reg_name,
const RegisterValue &value) {
187 void *buf =
reinterpret_cast<void *
>(value.
GetAsUInt64());
188 LLDB_LOG(log,
"{0}: {1}", reg_name, buf);
191 PTRACE_POKEUSER,
m_thread.GetID(),
reinterpret_cast<void *
>(offset), buf);
194llvm::Expected<ArchSpec>
197 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(gpr64_size);
199 iov.iov_base = data.get();
200 iov.iov_len = gpr64_size;
201 unsigned int regset = llvm::ELF::NT_PRSTATUS;
206 return HostInfo::GetArchitecture(
207 iov.iov_len < gpr64_size ? HostInfo::eArchKind32 : HostInfo::eArchKind64);
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
const RegisterInfo * GetRegisterInfoAtIndex(uint32_t reg_index) const override
virtual Status ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value)=0
NativeThreadProtocol & m_thread
bool SetUInt(uint64_t uint, uint32_t byte_size)
uint32_t GetAsMemoryData(const RegisterInfo ®_info, void *dst, uint32_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
uint64_t GetAsUInt64(uint64_t fail_value=UINT64_MAX, bool *success_ptr=nullptr) const
void SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order)
void SetType(RegisterValue::Type type)
uint32_t GetByteSize() const
llvm::SmallVector< uint8_t, kTypicalRegisterByteSize > BytesContainer
llvm::Error ToError() const
FIXME: Replace all uses with takeError() instead.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
bool Fail() const
Test for error condition.
static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr=nullptr, void *data=nullptr, size_t data_size=0, long *result=nullptr)
}
virtual Status ReadRegisterSet(void *buf, size_t buf_size, unsigned int regset)
lldb::ByteOrder GetByteOrder() const
virtual Status WriteRegisterRaw(uint32_t reg_index, const RegisterValue ®_value)
virtual Status WriteRegisterSet(void *buf, size_t buf_size, unsigned int regset)
virtual Status ReadRegisterRaw(uint32_t reg_index, RegisterValue ®_value)
virtual Status WriteFPR()
virtual uint32_t GetPtraceOffset(uint32_t reg_index)
virtual Status DoReadRegisterValue(uint32_t offset, const char *reg_name, uint32_t size, RegisterValue &value)
virtual size_t GetFPRSize()=0
static llvm::Expected< ArchSpec > DetermineArchitectureViaGPR(lldb::tid_t tid, size_t gpr64_size)
virtual Status WriteGPR()
virtual size_t GetGPRSize() const
virtual Status DoWriteRegisterValue(uint32_t offset, const char *reg_name, const RegisterValue &value)
virtual void * GetGPRBuffer()=0
virtual void * GetFPRBuffer()=0
#define LLDB_INVALID_REGNUM
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.
ByteOrder
Byte ordering definitions.
Every register is described in detail including its name, alternate name (optional),...
uint32_t byte_offset
The byte offset in the register context data where this register's value is found.
uint32_t byte_size
Size in bytes of the register.
llvm::ArrayRef< uint8_t > data(const uint8_t *context_base) const
const char * name
Name of this register, can't be NULL.
uint32_t * invalidate_regs
List of registers (terminated with LLDB_INVALID_REGNUM).