1 | //===-- RegisterContextMemory.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_UTILITY_REGISTERCONTEXTMEMORY_H |
10 | #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMEMORY_H |
11 | |
12 | #include <vector> |
13 | |
14 | #include "lldb/Target/DynamicRegisterInfo.h" |
15 | #include "lldb/Target/RegisterContext.h" |
16 | #include "lldb/Utility/DataExtractor.h" |
17 | #include "lldb/lldb-private.h" |
18 | |
19 | class RegisterContextMemory : public lldb_private::RegisterContext { |
20 | public: |
21 | RegisterContextMemory(lldb_private::Thread &thread, |
22 | uint32_t concrete_frame_idx, |
23 | lldb_private::DynamicRegisterInfo ®_info, |
24 | lldb::addr_t reg_data_addr); |
25 | |
26 | ~RegisterContextMemory() override; |
27 | |
28 | void InvalidateAllRegisters() override; |
29 | |
30 | size_t GetRegisterCount() override; |
31 | |
32 | const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override; |
33 | |
34 | size_t GetRegisterSetCount() override; |
35 | |
36 | const lldb_private::RegisterSet *GetRegisterSet(size_t reg_set) override; |
37 | |
38 | uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, |
39 | uint32_t num) override; |
40 | |
41 | // If all of the thread register are in a contiguous buffer in |
42 | // memory, then the default ReadRegister/WriteRegister and |
43 | // ReadAllRegisterValues/WriteAllRegisterValues will work. If thread |
44 | // registers are not contiguous, clients will want to subclass this |
45 | // class and modify the read/write functions as needed. |
46 | |
47 | bool ReadRegister(const lldb_private::RegisterInfo *reg_info, |
48 | lldb_private::RegisterValue ®_value) override; |
49 | |
50 | bool WriteRegister(const lldb_private::RegisterInfo *reg_info, |
51 | const lldb_private::RegisterValue ®_value) override; |
52 | |
53 | bool ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override; |
54 | |
55 | bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override; |
56 | |
57 | void SetAllRegisterData(const lldb::DataBufferSP &data_sp); |
58 | |
59 | protected: |
60 | void SetAllRegisterValid(bool b); |
61 | |
62 | lldb_private::DynamicRegisterInfo &m_reg_infos; |
63 | std::vector<bool> m_reg_valid; |
64 | lldb::WritableDataBufferSP m_data; |
65 | lldb_private::DataExtractor m_reg_data; |
66 | lldb::addr_t m_reg_data_addr; // If this is valid, then we have a register |
67 | // context that is stored in memmory |
68 | |
69 | private: |
70 | RegisterContextMemory(const RegisterContextMemory &) = delete; |
71 | const RegisterContextMemory & |
72 | operator=(const RegisterContextMemory &) = delete; |
73 | }; |
74 | |
75 | #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMEMORY_H |
76 | |