22#include <sys/ptrace.h>
32NativeRegisterContextFreeBSD::CreateHostNativeRegisterContextFreeBSD(
34 return new NativeRegisterContextFreeBSD_mips64(target_arch, native_thread);
37NativeRegisterContextFreeBSD_mips64::NativeRegisterContextFreeBSD_mips64(
43NativeRegisterContextFreeBSD_mips64::GetRegisterInfo()
const {
45 *m_register_info_interface_up);
48uint32_t NativeRegisterContextFreeBSD_mips64::GetRegisterSetCount()
const {
53NativeRegisterContextFreeBSD_mips64::GetRegisterSet(uint32_t set_index)
const {
54 return GetRegisterInfo().GetRegisterSet(set_index);
57uint32_t NativeRegisterContextFreeBSD_mips64::GetUserRegisterCount()
const {
59 for (uint32_t set_index = 0; set_index < GetRegisterSetCount(); ++set_index)
64std::optional<NativeRegisterContextFreeBSD_mips64::RegSetKind>
65NativeRegisterContextFreeBSD_mips64::GetSetForNativeRegNum(
66 uint32_t reg_num)
const {
67 switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
68 case llvm::Triple::mips64:
69 if (reg_num >= k_first_gpr_mips64 && reg_num <= k_last_gpr_mips64)
71 if (reg_num >= k_first_fpr_mips64 && reg_num <= k_last_fpr_mips64)
75 llvm_unreachable(
"Unhandled target architecture.");
78 llvm_unreachable(
"Register does not belong to any register set");
81Status NativeRegisterContextFreeBSD_mips64::ReadRegisterSet(RegSetKind set) {
84 return NativeProcessFreeBSD::PtraceWrapper(PT_GETREGS, m_thread.GetID(),
87 return NativeProcessFreeBSD::PtraceWrapper(
88 PT_GETFPREGS, m_thread.GetID(),
89 m_reg_data.data() + GetRegisterInfo().GetGPRSize());
91 llvm_unreachable(
"NativeRegisterContextFreeBSD_mips64::ReadRegisterSet");
94Status NativeRegisterContextFreeBSD_mips64::WriteRegisterSet(RegSetKind set) {
97 return NativeProcessFreeBSD::PtraceWrapper(PT_SETREGS, m_thread.GetID(),
100 return NativeProcessFreeBSD::PtraceWrapper(
101 PT_SETFPREGS, m_thread.GetID(),
102 m_reg_data.data() + GetRegisterInfo().GetGPRSize());
104 llvm_unreachable(
"NativeRegisterContextFreeBSD_mips64::WriteRegisterSet");
108NativeRegisterContextFreeBSD_mips64::ReadRegister(
const RegisterInfo *reg_info,
113 error.SetErrorString(
"reg_info NULL");
120 return Status(
"no lldb regnum for %s", reg_info && reg_info->
name
122 :
"<unknown register>");
124 std::optional<RegSetKind> opt_set = GetSetForNativeRegNum(reg);
128 error.SetErrorStringWithFormat(
"register \"%s\" is in unrecognized set",
133 RegSetKind set = *opt_set;
134 error = ReadRegisterSet(set);
140 reg_info->
byte_size, endian::InlHostByteOrder());
144Status NativeRegisterContextFreeBSD_mips64::WriteRegister(
149 return Status(
"reg_info NULL");
154 return Status(
"no lldb regnum for %s", reg_info && reg_info->
name
156 :
"<unknown register>");
158 std::optional<RegSetKind> opt_set = GetSetForNativeRegNum(reg);
162 error.SetErrorStringWithFormat(
"register \"%s\" is in unrecognized set",
167 RegSetKind set = *opt_set;
168 error = ReadRegisterSet(set);
176 return WriteRegisterSet(set);
179Status NativeRegisterContextFreeBSD_mips64::ReadAllRegisterValues(
183 error = ReadRegisterSet(GPRegSet);
187 error = ReadRegisterSet(FPRegSet);
192 uint8_t *dst = data_sp->GetBytes();
193 ::memcpy(dst, m_reg_data.data(), m_reg_data.size());
198Status NativeRegisterContextFreeBSD_mips64::WriteAllRegisterValues(
203 error.SetErrorStringWithFormat(
204 "NativeRegisterContextFreeBSD_mips64::%s invalid data_sp provided",
209 if (data_sp->GetByteSize() != m_reg_data.size()) {
210 error.SetErrorStringWithFormat(
211 "NativeRegisterContextFreeBSD_mips64::%s data_sp contained mismatched "
212 "data size, expected %" PRIu64
", actual %" PRIu64,
213 __FUNCTION__, m_reg_data.size(), data_sp->GetByteSize());
217 const uint8_t *src = data_sp->GetBytes();
218 if (src ==
nullptr) {
219 error.SetErrorStringWithFormat(
"NativeRegisterContextFreeBSD_mips64::%s "
220 "DataBuffer::GetBytes() returned a null "
225 ::memcpy(m_reg_data.data(), src, m_reg_data.size());
227 error = WriteRegisterSet(GPRegSet);
231 return WriteRegisterSet(FPRegSet);
234llvm::Error NativeRegisterContextFreeBSD_mips64::CopyHardwareWatchpointsFrom(
236 return llvm::Error::success();
static llvm::raw_ostream & error(Stream &strm)
size_t GetRegisterSetCount() const
An architecture specification class.
A subclass of DataBuffer that stores a data buffer on the heap.
void SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order)
const void * GetBytes() const
#define LLDB_INVALID_REGNUM
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
@ eRegisterKindLLDB
lldb's internal register numbers
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.
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.
Registers are grouped into register sets.
size_t num_registers
The number of registers in REGISTERS array below.