[Utils] Identity map module-level debug info on first use in CloneFunction* (#118627)
[llvm-project.git] / lldb / source / Plugins / Process / gdb-remote / GDBRemoteRegisterContext.h
blob6a90f911353fe2a28952d797a39780bfae3735bf
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 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERCONTEXT_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERCONTEXT_H
12 #include <vector>
14 #include "lldb/Target/DynamicRegisterInfo.h"
15 #include "lldb/Target/RegisterContext.h"
16 #include "lldb/Utility/ConstString.h"
17 #include "lldb/Utility/DataExtractor.h"
18 #include "lldb/lldb-enumerations.h"
19 #include "lldb/lldb-private.h"
21 #include "GDBRemoteCommunicationClient.h"
23 class StringExtractor;
25 namespace lldb_private {
26 namespace process_gdb_remote {
28 class ThreadGDBRemote;
29 class ProcessGDBRemote;
30 class GDBRemoteDynamicRegisterInfo;
32 typedef std::shared_ptr<GDBRemoteDynamicRegisterInfo>
33 GDBRemoteDynamicRegisterInfoSP;
35 class GDBRemoteDynamicRegisterInfo final : public DynamicRegisterInfo {
36 public:
37 GDBRemoteDynamicRegisterInfo() : DynamicRegisterInfo() {}
39 ~GDBRemoteDynamicRegisterInfo() override = default;
41 void UpdateARM64SVERegistersInfos(uint64_t vg);
42 void UpdateARM64SMERegistersInfos(uint64_t svg);
45 class GDBRemoteRegisterContext : public RegisterContext {
46 public:
47 GDBRemoteRegisterContext(ThreadGDBRemote &thread, uint32_t concrete_frame_idx,
48 GDBRemoteDynamicRegisterInfoSP reg_info_sp,
49 bool read_all_at_once, bool write_all_at_once);
51 ~GDBRemoteRegisterContext() override;
53 void InvalidateAllRegisters() override;
55 size_t GetRegisterCount() override;
57 const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
59 size_t GetRegisterSetCount() override;
61 const RegisterSet *GetRegisterSet(size_t reg_set) override;
63 bool ReadRegister(const RegisterInfo *reg_info,
64 RegisterValue &value) override;
66 bool WriteRegister(const RegisterInfo *reg_info,
67 const RegisterValue &value) override;
69 bool ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override;
71 bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
73 bool ReadAllRegisterValues(RegisterCheckpoint &reg_checkpoint) override;
75 bool
76 WriteAllRegisterValues(const RegisterCheckpoint &reg_checkpoint) override;
78 uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
79 uint32_t num) override;
81 bool RegisterWriteCausesReconfigure(const llvm::StringRef name) override;
83 bool ReconfigureRegisterInfo() override;
85 protected:
86 friend class ThreadGDBRemote;
88 bool ReadRegisterBytes(const RegisterInfo *reg_info);
90 bool WriteRegisterBytes(const RegisterInfo *reg_info, DataExtractor &data,
91 uint32_t data_offset);
93 bool PrivateSetRegisterValue(uint32_t reg, llvm::ArrayRef<uint8_t> data);
95 bool PrivateSetRegisterValue(uint32_t reg, uint64_t val);
97 void SetAllRegisterValid(bool b);
99 bool GetRegisterIsValid(uint32_t reg) const {
100 assert(reg < m_reg_valid.size());
101 if (reg < m_reg_valid.size())
102 return m_reg_valid[reg];
103 return false;
106 void SetRegisterIsValid(const RegisterInfo *reg_info, bool valid) {
107 if (reg_info)
108 return SetRegisterIsValid(reg_info->kinds[lldb::eRegisterKindLLDB],
109 valid);
112 void SetRegisterIsValid(uint32_t reg, bool valid) {
113 assert(reg < m_reg_valid.size());
114 if (reg < m_reg_valid.size())
115 m_reg_valid[reg] = valid;
118 GDBRemoteDynamicRegisterInfoSP m_reg_info_sp;
119 std::vector<bool> m_reg_valid;
120 DataExtractor m_reg_data;
121 bool m_read_all_at_once;
122 bool m_write_all_at_once;
123 bool m_gpacket_cached;
125 private:
126 // Helper function for ReadRegisterBytes().
127 bool GetPrimordialRegister(const RegisterInfo *reg_info,
128 GDBRemoteCommunicationClient &gdb_comm);
129 // Helper function for WriteRegisterBytes().
130 bool SetPrimordialRegister(const RegisterInfo *reg_info,
131 GDBRemoteCommunicationClient &gdb_comm);
133 GDBRemoteRegisterContext(const GDBRemoteRegisterContext &) = delete;
134 const GDBRemoteRegisterContext &
135 operator=(const GDBRemoteRegisterContext &) = delete;
138 } // namespace process_gdb_remote
139 } // namespace lldb_private
141 #endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERCONTEXT_H