9#if defined(__powerpc__)
24#include <sys/ptrace.h>
69NativeRegisterContextFreeBSD::CreateHostNativeRegisterContextFreeBSD(
71 return new NativeRegisterContextFreeBSD_powerpc(target_arch, native_thread);
75CreateRegisterInfoInterface(
const ArchSpec &target_arch) {
76 if (HostInfo::GetArchitecture().GetAddressByteSize() == 4) {
79 assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
80 "Register setting path assumes this is a 64-bit host");
85NativeRegisterContextFreeBSD_powerpc::NativeRegisterContextFreeBSD_powerpc(
88 native_thread, CreateRegisterInfoInterface(target_arch)) {}
91NativeRegisterContextFreeBSD_powerpc::GetRegisterInfo()
const {
93 *m_register_info_interface_up);
96uint32_t NativeRegisterContextFreeBSD_powerpc::GetRegisterSetCount()
const {
101NativeRegisterContextFreeBSD_powerpc::GetRegisterSet(uint32_t set_index)
const {
102 switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
103 case llvm::Triple::ppc:
106 llvm_unreachable(
"Unhandled target architecture.");
110std::optional<NativeRegisterContextFreeBSD_powerpc::RegSetKind>
111NativeRegisterContextFreeBSD_powerpc::GetSetForNativeRegNum(
112 uint32_t reg_num)
const {
113 switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
114 case llvm::Triple::ppc:
121 llvm_unreachable(
"Unhandled target architecture.");
124 llvm_unreachable(
"Register does not belong to any register set");
127uint32_t NativeRegisterContextFreeBSD_powerpc::GetUserRegisterCount()
const {
129 for (uint32_t set_index = 0; set_index < GetRegisterSetCount(); ++set_index)
130 count += GetRegisterSet(set_index)->num_registers;
134Status NativeRegisterContextFreeBSD_powerpc::ReadRegisterSet(RegSetKind set) {
137 return NativeProcessFreeBSD::PtraceWrapper(PT_GETREGS, m_thread.GetID(),
140 return NativeProcessFreeBSD::PtraceWrapper(PT_GETFPREGS, m_thread.GetID(),
141 m_reg_data.data() +
sizeof(reg));
143 llvm_unreachable(
"NativeRegisterContextFreeBSD_powerpc::ReadRegisterSet");
146Status NativeRegisterContextFreeBSD_powerpc::WriteRegisterSet(RegSetKind set) {
149 return NativeProcessFreeBSD::PtraceWrapper(PT_SETREGS, m_thread.GetID(),
152 return NativeProcessFreeBSD::PtraceWrapper(PT_SETFPREGS, m_thread.GetID(),
153 m_reg_data.data() +
sizeof(reg));
155 llvm_unreachable(
"NativeRegisterContextFreeBSD_powerpc::WriteRegisterSet");
159NativeRegisterContextFreeBSD_powerpc::ReadRegister(
const RegisterInfo *reg_info,
164 error.SetErrorString(
"reg_info NULL");
171 return Status(
"no lldb regnum for %s", reg_info && reg_info->
name
173 :
"<unknown register>");
175 std::optional<RegSetKind> opt_set = GetSetForNativeRegNum(reg);
179 error.SetErrorStringWithFormat(
"register \"%s\" is in unrecognized set",
184 RegSetKind set = *opt_set;
185 error = ReadRegisterSet(set);
191 reg_info->
byte_size, endian::InlHostByteOrder());
195Status NativeRegisterContextFreeBSD_powerpc::WriteRegister(
200 return Status(
"reg_info NULL");
205 return Status(
"no lldb regnum for %s", reg_info && reg_info->
name
207 :
"<unknown register>");
209 std::optional<RegSetKind> opt_set = GetSetForNativeRegNum(reg);
213 error.SetErrorStringWithFormat(
"register \"%s\" is in unrecognized set",
218 RegSetKind set = *opt_set;
219 error = ReadRegisterSet(set);
227 return WriteRegisterSet(set);
230Status NativeRegisterContextFreeBSD_powerpc::ReadAllRegisterValues(
234 error = ReadRegisterSet(GPRegSet);
238 error = ReadRegisterSet(FPRegSet);
243 uint8_t *dst = data_sp->GetBytes();
244 ::memcpy(dst, m_reg_data.data(), m_reg_data.size());
249Status NativeRegisterContextFreeBSD_powerpc::WriteAllRegisterValues(
254 error.SetErrorStringWithFormat(
255 "NativeRegisterContextFreeBSD_powerpc::%s invalid data_sp provided",
260 if (data_sp->GetByteSize() != m_reg_data.size()) {
261 error.SetErrorStringWithFormat(
262 "NativeRegisterContextFreeBSD_powerpc::%s data_sp contained mismatched "
263 "data size, expected %zu, actual %" PRIu64,
264 __FUNCTION__, m_reg_data.size(), data_sp->GetByteSize());
268 const uint8_t *src = data_sp->GetBytes();
269 if (src ==
nullptr) {
270 error.SetErrorStringWithFormat(
"NativeRegisterContextFreeBSD_powerpc::%s "
271 "DataBuffer::GetBytes() returned a null "
276 ::memcpy(m_reg_data.data(), src, m_reg_data.size());
278 error = WriteRegisterSet(GPRegSet);
282 return WriteRegisterSet(FPRegSet);
285llvm::Error NativeRegisterContextFreeBSD_powerpc::CopyHardwareWatchpointsFrom(
287 return llvm::Error::success();
static llvm::raw_ostream & error(Stream &strm)
constexpr size_t k_num_register_sets
const uint32_t g_gpr_regnums[]
static const uint32_t g_fpr_regnums[]
static const RegisterSet g_reg_sets_powerpc[k_num_register_sets]
@ k_num_fpr_registers_powerpc
@ k_num_gpr_registers_powerpc
An architecture specification class.
A subclass of DataBuffer that stores a data buffer on the heap.
RegisterInfo interface to patch RegisterInfo structure for archs.
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.