LLDB  mainline
GDBRemoteRegisterContext.h
Go to the documentation of this file.
1 //===-- GDBRemoteRegisterContext.h ------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERCONTEXT_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERCONTEXT_H
11 
12 #include <vector>
13 
18 #include "lldb/lldb-enumerations.h"
19 #include "lldb/lldb-private.h"
20 
22 
23 class StringExtractor;
24 
25 namespace lldb_private {
26 namespace process_gdb_remote {
27 
28 class ThreadGDBRemote;
29 class ProcessGDBRemote;
31 
32 typedef std::shared_ptr<GDBRemoteDynamicRegisterInfo>
34 
36 public:
38 
39  ~GDBRemoteDynamicRegisterInfo() override = default;
40 
41  bool UpdateARM64SVERegistersInfos(uint64_t vg);
42 };
43 
45 public:
46  GDBRemoteRegisterContext(ThreadGDBRemote &thread, uint32_t concrete_frame_idx,
48  bool read_all_at_once, bool write_all_at_once);
49 
50  ~GDBRemoteRegisterContext() override;
51 
52  void InvalidateAllRegisters() override;
53 
54  size_t GetRegisterCount() override;
55 
56  const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
57 
58  size_t GetRegisterSetCount() override;
59 
60  const RegisterSet *GetRegisterSet(size_t reg_set) override;
61 
62  bool ReadRegister(const RegisterInfo *reg_info,
63  RegisterValue &value) override;
64 
65  bool WriteRegister(const RegisterInfo *reg_info,
66  const RegisterValue &value) override;
67 
68  bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
69 
70  bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
71 
72  bool ReadAllRegisterValues(RegisterCheckpoint &reg_checkpoint) override;
73 
74  bool
75  WriteAllRegisterValues(const RegisterCheckpoint &reg_checkpoint) override;
76 
78  uint32_t num) override;
79 
80  bool AArch64SVEReconfigure();
81 
82 protected:
83  friend class ThreadGDBRemote;
84 
85  bool ReadRegisterBytes(const RegisterInfo *reg_info);
86 
87  bool WriteRegisterBytes(const RegisterInfo *reg_info, DataExtractor &data,
88  uint32_t data_offset);
89 
90  bool PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef<uint8_t> data);
91 
92  bool PrivateSetRegisterValue(uint32_t reg, uint64_t val);
93 
94  void SetAllRegisterValid(bool b);
95 
96  bool GetRegisterIsValid(uint32_t reg) const {
97  assert(reg < m_reg_valid.size());
98  if (reg < m_reg_valid.size())
99  return m_reg_valid[reg];
100  return false;
101  }
102 
103  void SetRegisterIsValid(const RegisterInfo *reg_info, bool valid) {
104  if (reg_info)
105  return SetRegisterIsValid(reg_info->kinds[lldb::eRegisterKindLLDB],
106  valid);
107  }
108 
109  void SetRegisterIsValid(uint32_t reg, bool valid) {
110  assert(reg < m_reg_valid.size());
111  if (reg < m_reg_valid.size())
112  m_reg_valid[reg] = valid;
113  }
114 
116  std::vector<bool> m_reg_valid;
121 
122 private:
123  // Helper function for ReadRegisterBytes().
124  bool GetPrimordialRegister(const RegisterInfo *reg_info,
125  GDBRemoteCommunicationClient &gdb_comm);
126  // Helper function for WriteRegisterBytes().
127  bool SetPrimordialRegister(const RegisterInfo *reg_info,
128  GDBRemoteCommunicationClient &gdb_comm);
129 
132  operator=(const GDBRemoteRegisterContext &) = delete;
133 };
134 
135 } // namespace process_gdb_remote
136 } // namespace lldb_private
137 
138 #endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERCONTEXT_H
lldb_private::process_gdb_remote::GDBRemoteRegisterContext
Definition: GDBRemoteRegisterContext.h:44
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::PrivateSetRegisterValue
bool PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef< uint8_t > data)
Definition: GDBRemoteRegisterContext.cpp:122
lldb_private::process_gdb_remote::GDBRemoteDynamicRegisterInfo
Definition: GDBRemoteRegisterContext.h:35
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient
Definition: GDBRemoteCommunicationClient.h:58
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::~GDBRemoteRegisterContext
~GDBRemoteRegisterContext() override
DynamicRegisterInfo.h
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::WriteAllRegisterValues
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
Definition: GDBRemoteRegisterContext.cpp:584
lldb_private::process_gdb_remote::GDBRemoteDynamicRegisterInfoSP
std::shared_ptr< GDBRemoteDynamicRegisterInfo > GDBRemoteDynamicRegisterInfoSP
Definition: GDBRemoteRegisterContext.h:30
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::SetRegisterIsValid
void SetRegisterIsValid(const RegisterInfo *reg_info, bool valid)
Definition: GDBRemoteRegisterContext.h:103
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::m_read_all_at_once
bool m_read_all_at_once
Definition: GDBRemoteRegisterContext.h:118
StringExtractor
Definition: StringExtractor.h:19
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::SetAllRegisterValid
void SetAllRegisterValid(bool b)
Definition: GDBRemoteRegisterContext.cpp:59
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::InvalidateAllRegisters
void InvalidateAllRegisters() override
Definition: GDBRemoteRegisterContext.cpp:55
lldb_private::process_gdb_remote::ThreadGDBRemote
Definition: ThreadGDBRemote.h:28
lldb::eRegisterKindLLDB
@ eRegisterKindLLDB
lldb's internal register numbers
Definition: lldb-enumerations.h:234
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::GDBRemoteRegisterContext
GDBRemoteRegisterContext(ThreadGDBRemote &thread, uint32_t concrete_frame_idx, GDBRemoteDynamicRegisterInfoSP reg_info_sp, bool read_all_at_once, bool write_all_at_once)
Definition: GDBRemoteRegisterContext.cpp:32
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::GetRegisterSetCount
size_t GetRegisterSetCount() override
Definition: GDBRemoteRegisterContext.cpp:75
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::GetPrimordialRegister
bool GetPrimordialRegister(const RegisterInfo *reg_info, GDBRemoteCommunicationClient &gdb_comm)
Definition: GDBRemoteRegisterContext.cpp:191
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::operator=
const GDBRemoteRegisterContext & operator=(const GDBRemoteRegisterContext &)=delete
lldb-enumerations.h
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::GetRegisterIsValid
bool GetRegisterIsValid(uint32_t reg) const
Definition: GDBRemoteRegisterContext.h:96
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::ReadRegister
bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &value) override
Definition: GDBRemoteRegisterContext.cpp:83
lldb_private::process_gdb_remote::GDBRemoteDynamicRegisterInfo::UpdateARM64SVERegistersInfos
bool UpdateARM64SVERegistersInfos(uint64_t vg)
Definition: GDBRemoteRegisterContext.cpp:795
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::GetRegisterInfoAtIndex
const RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
Definition: GDBRemoteRegisterContext.cpp:71
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::AArch64SVEReconfigure
bool AArch64SVEReconfigure()
Definition: GDBRemoteRegisterContext.cpp:763
lldb_private::RegisterContext
Definition: RegisterContext.h:17
lldb_private::process_gdb_remote::GDBRemoteDynamicRegisterInfo::GDBRemoteDynamicRegisterInfo
GDBRemoteDynamicRegisterInfo()
Definition: GDBRemoteRegisterContext.h:37
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:227
lldb-private.h
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::ReadAllRegisterValues
bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override
Definition: GDBRemoteRegisterContext.cpp:521
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::m_write_all_at_once
bool m_write_all_at_once
Definition: GDBRemoteRegisterContext.h:119
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::WriteRegisterBytes
bool WriteRegisterBytes(const RegisterInfo *reg_info, DataExtractor &data, uint32_t data_offset)
Definition: GDBRemoteRegisterContext.cpp:349
lldb_private::process_gdb_remote::GDBRemoteDynamicRegisterInfo::~GDBRemoteDynamicRegisterInfo
~GDBRemoteDynamicRegisterInfo() override=default
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::m_reg_info_sp
GDBRemoteDynamicRegisterInfoSP m_reg_info_sp
Definition: GDBRemoteRegisterContext.h:115
uint32_t
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::m_gpacket_cached
bool m_gpacket_cached
Definition: GDBRemoteRegisterContext.h:120
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::SetRegisterIsValid
void SetRegisterIsValid(uint32_t reg, bool valid)
Definition: GDBRemoteRegisterContext.h:109
lldb_private::RegisterCheckpoint
Definition: RegisterCheckpoint.h:21
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::m_reg_data
DataExtractor m_reg_data
Definition: GDBRemoteRegisterContext.h:117
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::GetRegisterSet
const RegisterSet * GetRegisterSet(size_t reg_set) override
Definition: GDBRemoteRegisterContext.cpp:79
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::ReadRegisterBytes
bool ReadRegisterBytes(const RegisterInfo *reg_info)
Definition: GDBRemoteRegisterContext.cpp:204
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::WriteRegister
bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value) override
Definition: GDBRemoteRegisterContext.cpp:296
DataExtractor.h
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::GetRegisterCount
size_t GetRegisterCount() override
Definition: GDBRemoteRegisterContext.cpp:66
arm64_dwarf::vg
@ vg
Definition: ARM64_DWARF_Registers.h:57
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
ConstString.h
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::ConvertRegisterKindToRegisterNumber
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override
Convert from a given register numbering scheme to the lldb register numbering scheme.
Definition: GDBRemoteRegisterContext.cpp:758
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::SetPrimordialRegister
bool SetPrimordialRegister(const RegisterInfo *reg_info, GDBRemoteCommunicationClient &gdb_comm)
Definition: GDBRemoteRegisterContext.cpp:335
lldb_private::DynamicRegisterInfo
Definition: DynamicRegisterInfo.h:21
lldb_private::process_gdb_remote::GDBRemoteRegisterContext::m_reg_valid
std::vector< bool > m_reg_valid
Definition: GDBRemoteRegisterContext.h:116
RegisterContext.h
GDBRemoteCommunicationClient.h