36 bool write_all_at_once)
38 m_reg_info_sp(std::move(reg_info_sp)), m_reg_valid(), m_reg_data(),
39 m_read_all_at_once(read_all_at_once),
40 m_write_all_at_once(write_all_at_once), m_gpacket_cached(false) {
62 std::vector<bool>::iterator pos, end =
m_reg_valid.end();
94 std::vector<char> combined_data;
101 combined_data.resize(offset + parent_reg->
byte_size);
103 combined_data.data() + offset) !=
111 *reg_info, combined_data.
data(), combined_data.size(),
114 const bool partial_data_ok =
false;
117 return error.Success();
124 uint32_t reg, llvm::ArrayRef<uint8_t> data) {
126 if (reg_info ==
nullptr)
132 const size_t reg_byte_size = reg_info->
byte_size;
133 memcpy(
const_cast<uint8_t *
>(
135 data.data(), std::min(data.size(), reg_byte_size));
136 bool success = data.size() >= reg_byte_size;
139 }
else if (data.size() > 0) {
148 uint64_t new_reg_val) {
150 if (reg_info ==
nullptr)
173 uint8_t *dst =
const_cast<uint8_t *
>(
200 lldb_reg, llvm::ArrayRef<uint8_t>(buffer_sp->GetBytes(),
201 buffer_sp->GetByteSize()));
210 if (process ==
nullptr || thread ==
nullptr)
225 buffer_sp->GetBytes(),
230 }
else if (buffer_sp->GetByteSize() > 0) {
231 for (
auto x : llvm::enumerate(
237 buffer_sp->GetByteSize());
247 "error: GDBRemoteRegisterContext::ReadRegisterBytes tried "
249 "entire register context at once, expected at least %" PRId64
251 "but only got %" PRId64
" bytes.",
263 for (uint32_t idx = 0; success; ++idx) {
264 const uint32_t prim_reg = reg_info->
value_regs[idx];
271 if (prim_reg_info ==
nullptr)
305 uint32_t combined_size = 0;
328 assert(offset == combined_size);
347 {m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size),
348 reg_info->byte_size});
353 uint32_t data_offset) {
358 if (process ==
nullptr || thread ==
nullptr)
373 uint8_t *dst =
const_cast<uint8_t *
>(
379 const bool should_reconfigure_registers =
397 {m_reg_data.GetDataStart(), size_t(m_reg_data.GetByteSize())}))
400 if (should_reconfigure_registers)
418 for (uint32_t idx = 0; success; ++idx) {
419 const uint32_t reg = reg_info->
value_regs[idx];
426 if (value_reg_info ==
nullptr)
447 if (success && should_reconfigure_registers &&
460 "error: failed to get packet sequence mutex, not sending "
461 "write register for \"%s\":\n%s",
465 "error: failed to get packet sequence mutex, not sending "
466 "write register for \"%s\"",
480 if (process ==
nullptr || thread ==
nullptr)
486 uint32_t save_id = 0;
488 reg_checkpoint.
SetID(save_id);
489 reg_checkpoint.
GetData().reset();
492 reg_checkpoint.
SetID(0);
499 uint32_t save_id = reg_checkpoint.
GetID();
505 if (process ==
nullptr || thread ==
nullptr)
523 if (process ==
nullptr || thread ==
nullptr)
529 const bool use_g_packet =
540 data_sp = std::make_shared<DataBufferHeap>(*data_buffer);
558 data_sp = std::make_shared<DataBufferHeap>(
569 "error: failed to get packet sequence mutex, not sending "
570 "read all registers:\n%s",
574 "error: failed to get packet sequence mutex, not sending "
575 "read all registers");
585 if (!data_sp || data_sp->GetBytes() ==
nullptr || data_sp->GetByteSize() == 0)
592 if (process ==
nullptr || thread ==
nullptr)
598 const bool use_g_packet =
607 {data_sp->GetBytes(), size_t(data_sp->GetByteSize())}))
610 uint32_t num_restored = 0;
629 uint64_t size_including_slice_registers = 0;
630 uint64_t size_not_including_slice_registers = 0;
631 uint64_t size_by_highest_offset = 0;
633 for (uint32_t reg_idx = 0;
635 size_including_slice_registers += reg_info->
byte_size;
637 size_not_including_slice_registers += reg_info->
byte_size;
638 if (reg_info->
byte_offset >= size_by_highest_offset)
642 bool use_byte_offset_into_buffer;
643 if (size_by_highest_offset == restore_data.
GetByteSize()) {
646 use_byte_offset_into_buffer =
true;
647 }
else if (size_not_including_slice_registers ==
651 use_byte_offset_into_buffer =
true;
652 }
else if (size_including_slice_registers == restore_data.
GetByteSize()) {
656 use_byte_offset_into_buffer =
false;
661 use_byte_offset_into_buffer =
false;
666 uint32_t running_byte_offset = 0;
667 for (uint32_t reg_idx = 0;
669 ++reg_idx, running_byte_offset += reg_info->
byte_size) {
676 uint32_t register_offset;
677 if (use_byte_offset_into_buffer) {
680 register_offset = running_byte_offset;
683 const uint32_t reg_byte_size = reg_info->
byte_size;
685 const uint8_t *restore_src =
686 restore_data.
PeekData(register_offset, reg_byte_size);
692 {restore_src, reg_byte_size}))
696 return num_restored > 0;
702 bool arm64_debugserver =
false;
707 arch.
GetMachine() == llvm::Triple::aarch64_32) &&
708 arch.
GetTriple().getVendor() == llvm::Triple::Apple &&
709 arch.
GetTriple().getOS() == llvm::Triple::IOS) {
710 arm64_debugserver =
true;
713 uint32_t num_restored = 0;
723 if (arm64_debugserver && (strcmp(reg_info->
name,
"fpsr") == 0 ||
724 strcmp(reg_info->
name,
"fpcr") == 0)) {
731 {data_sp->GetBytes() + reg_info->byte_offset,
732 reg_info->byte_size}))
735 return num_restored > 0;
744 "error: failed to get packet sequence mutex, not sending "
745 "write all registers:\n%s",
749 "error: failed to get packet sequence mutex, not sending "
750 "write all registers");
758 return m_reg_info_sp->ConvertRegisterKindToRegisterNumber(kind, num);
762 const llvm::StringRef name) {
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
virtual bool ReconfigureRegisterInfo(DynamicRegisterInfo ®_info, DataExtractor ®_data, RegisterContext ®_context) const
virtual bool RegisterWriteCausesReconfigure(const llvm::StringRef name) const
A subclass of DataBuffer that stores a data buffer on the heap.
llvm::iterator_range< reg_collection::const_iterator > reg_collection_const_range
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Process & GetProcessRef() const
Returns a reference to the process object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
A plug-in interface definition class for debugging a process.
virtual void DumpPluginHistory(Stream &s)
The underlying plugin might store the low-level communication history for this session.
Target & GetTarget()
Get the target object pointer for this module.
lldb::WritableDataBufferSP & GetData()
void InvalidateIfNeeded(bool force)
const RegisterInfo * GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num)
lldb::ThreadSP CalculateThread() override
uint32_t SetFromMemoryData(const RegisterInfo ®_info, const void *src, uint32_t src_len, lldb::ByteOrder src_byte_order, Status &error)
bool GetData(DataExtractor &data) const
Status SetValueFromData(const RegisterInfo ®_info, DataExtractor &data, lldb::offset_t offset, bool partial_data_ok)
const char * GetData() const
Architecture * GetArchitecturePlugin() const
virtual lldb::user_id_t GetProtocolID() const
lldb::ProcessSP GetProcess() const
lldb::DataBufferSP ReadRegister(lldb::tid_t tid, uint32_t reg_num)
bool RestoreRegisterState(lldb::tid_t tid, uint32_t save_id)
bool AvoidGPackets(ProcessGDBRemote *process)
bool WriteAllRegisters(lldb::tid_t tid, llvm::ArrayRef< uint8_t > data)
bool WriteRegister(lldb::tid_t tid, uint32_t reg_num, llvm::ArrayRef< uint8_t > data)
bool SyncThreadState(lldb::tid_t tid)
lldb::DataBufferSP ReadAllRegisters(lldb::tid_t tid)
bool SaveRegisterState(lldb::tid_t tid, uint32_t &save_id)
const RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
const RegisterSet * GetRegisterSet(size_t reg_set) override
bool ReadRegisterBytes(const RegisterInfo *reg_info)
~GDBRemoteRegisterContext() override
std::vector< bool > m_reg_valid
void SetAllRegisterValid(bool b)
bool GetRegisterIsValid(uint32_t reg) const
bool RegisterWriteCausesReconfigure(const llvm::StringRef name) override
GDBRemoteRegisterContext(ThreadGDBRemote &thread, uint32_t concrete_frame_idx, GDBRemoteDynamicRegisterInfoSP reg_info_sp, bool read_all_at_once, bool write_all_at_once)
GDBRemoteDynamicRegisterInfoSP m_reg_info_sp
bool WriteRegisterBytes(const RegisterInfo *reg_info, DataExtractor &data, uint32_t data_offset)
bool PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef< uint8_t > data)
bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &value) override
size_t GetRegisterCount() override
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
void InvalidateAllRegisters() override
bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value) override
bool ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override
size_t GetRegisterSetCount() override
void SetRegisterIsValid(const RegisterInfo *reg_info, bool valid)
bool SetPrimordialRegister(const RegisterInfo *reg_info, GDBRemoteCommunicationClient &gdb_comm)
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override
Convert from a given register numbering scheme to the lldb register numbering scheme.
bool ReconfigureRegisterInfo() override
bool GetPrimordialRegister(const RegisterInfo *reg_info, GDBRemoteCommunicationClient &gdb_comm)
#define LLDB_INVALID_REGNUM
lldb::ByteOrder InlHostByteOrder()
std::shared_ptr< GDBRemoteDynamicRegisterInfo > GDBRemoteDynamicRegisterInfoSP
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::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
RegisterKind
Register numbering types.
@ eRegisterKindLLDB
lldb's internal register numbers
@ eRegisterKindProcessPlugin
num used by the process plugin - e.g.
Every register is described in detail including its name, alternate name (optional),...
uint32_t * value_regs
List of registers (terminated with LLDB_INVALID_REGNUM).
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.
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).
Registers are grouped into register sets.
lldb::user_id_t GetID() const
Get accessor for the user ID.
void SetID(lldb::user_id_t uid)
Set accessor for the user ID.