/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Target/DynamicRegisterInfo.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- DynamicRegisterInfo.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_TARGET_DYNAMICREGISTERINFO_H |
10 | | #define LLDB_TARGET_DYNAMICREGISTERINFO_H |
11 | | |
12 | | #include <map> |
13 | | #include <vector> |
14 | | |
15 | | #include "lldb/Target/RegisterFlags.h" |
16 | | #include "lldb/Utility/ConstString.h" |
17 | | #include "lldb/Utility/StructuredData.h" |
18 | | #include "lldb/lldb-private.h" |
19 | | |
20 | | namespace lldb_private { |
21 | | |
22 | | class DynamicRegisterInfo { |
23 | | protected: |
24 | 0 | DynamicRegisterInfo(DynamicRegisterInfo &) = default; |
25 | | DynamicRegisterInfo &operator=(DynamicRegisterInfo &) = default; |
26 | | |
27 | | public: |
28 | | struct Register { |
29 | | ConstString name; |
30 | | ConstString alt_name; |
31 | | ConstString set_name; |
32 | | uint32_t byte_size = LLDB_INVALID_INDEX32; |
33 | | uint32_t byte_offset = LLDB_INVALID_INDEX32; |
34 | | lldb::Encoding encoding = lldb::eEncodingUint; |
35 | | lldb::Format format = lldb::eFormatHex; |
36 | | uint32_t regnum_dwarf = LLDB_INVALID_REGNUM; |
37 | | uint32_t regnum_ehframe = LLDB_INVALID_REGNUM; |
38 | | uint32_t regnum_generic = LLDB_INVALID_REGNUM; |
39 | | uint32_t regnum_remote = LLDB_INVALID_REGNUM; |
40 | | std::vector<uint32_t> value_regs; |
41 | | std::vector<uint32_t> invalidate_regs; |
42 | | uint32_t value_reg_offset = 0; |
43 | | // Non-null if there is an XML provided type. |
44 | | const RegisterFlags *flags_type = nullptr; |
45 | | }; |
46 | | |
47 | 2.24k | DynamicRegisterInfo() = default; |
48 | | |
49 | | static std::unique_ptr<DynamicRegisterInfo> |
50 | | Create(const StructuredData::Dictionary &dict, const ArchSpec &arch); |
51 | | |
52 | 2.14k | virtual ~DynamicRegisterInfo() = default; |
53 | | |
54 | | DynamicRegisterInfo(DynamicRegisterInfo &&info); |
55 | | DynamicRegisterInfo &operator=(DynamicRegisterInfo &&info); |
56 | | |
57 | | size_t SetRegisterInfo(const lldb_private::StructuredData::Dictionary &dict, |
58 | | const lldb_private::ArchSpec &arch); |
59 | | |
60 | | size_t SetRegisterInfo(std::vector<Register> &®s, |
61 | | const lldb_private::ArchSpec &arch); |
62 | | |
63 | | size_t GetNumRegisters() const; |
64 | | |
65 | | size_t GetNumRegisterSets() const; |
66 | | |
67 | | size_t GetRegisterDataByteSize() const; |
68 | | |
69 | | const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(uint32_t i) const; |
70 | | |
71 | | const lldb_private::RegisterSet *GetRegisterSet(uint32_t i) const; |
72 | | |
73 | | uint32_t GetRegisterSetIndexByName(const lldb_private::ConstString &set_name, |
74 | | bool can_create); |
75 | | |
76 | | uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind, |
77 | | uint32_t num) const; |
78 | | |
79 | | const lldb_private::RegisterInfo *GetRegisterInfo(uint32_t kind, |
80 | | uint32_t num) const; |
81 | | |
82 | | void Dump() const; |
83 | | |
84 | | void Clear(); |
85 | | |
86 | | bool IsReconfigurable(); |
87 | | |
88 | | const lldb_private::RegisterInfo * |
89 | | GetRegisterInfo(llvm::StringRef reg_name) const; |
90 | | |
91 | | typedef std::vector<lldb_private::RegisterInfo> reg_collection; |
92 | 6 | llvm::iterator_range<reg_collection::const_iterator> registers() const { |
93 | 6 | return llvm::iterator_range<reg_collection::const_iterator>(m_regs); |
94 | 6 | } |
95 | | |
96 | | void ConfigureOffsets(); |
97 | | |
98 | | protected: |
99 | | // Classes that inherit from DynamicRegisterInfo can see and modify these |
100 | | typedef std::vector<lldb_private::RegisterSet> set_collection; |
101 | | typedef std::vector<uint32_t> reg_num_collection; |
102 | | typedef std::vector<reg_num_collection> set_reg_num_collection; |
103 | | typedef std::vector<lldb_private::ConstString> name_collection; |
104 | | typedef std::map<uint32_t, reg_num_collection> reg_to_regs_map; |
105 | | typedef std::map<uint32_t, uint32_t> reg_offset_map; |
106 | | |
107 | | llvm::Expected<uint32_t> ByteOffsetFromSlice(uint32_t index, |
108 | | llvm::StringRef slice_str, |
109 | | lldb::ByteOrder byte_order); |
110 | | llvm::Expected<uint32_t> ByteOffsetFromComposite( |
111 | | uint32_t index, lldb_private::StructuredData::Array &composite_reg_list, |
112 | | lldb::ByteOrder byte_order); |
113 | | llvm::Expected<uint32_t> ByteOffsetFromRegInfoDict( |
114 | | uint32_t index, lldb_private::StructuredData::Dictionary ®_info_dict, |
115 | | lldb::ByteOrder byte_order); |
116 | | |
117 | | void MoveFrom(DynamicRegisterInfo &&info); |
118 | | |
119 | | void Finalize(const lldb_private::ArchSpec &arch); |
120 | | |
121 | | reg_collection m_regs; |
122 | | set_collection m_sets; |
123 | | set_reg_num_collection m_set_reg_nums; |
124 | | name_collection m_set_names; |
125 | | reg_to_regs_map m_value_regs_map; |
126 | | reg_to_regs_map m_invalidate_regs_map; |
127 | | reg_offset_map m_value_reg_offset_map; |
128 | | size_t m_reg_data_byte_size = 0u; // The number of bytes required to store |
129 | | // all registers |
130 | | bool m_finalized = false; |
131 | | bool m_is_reconfigurable = false; |
132 | | }; |
133 | | |
134 | | void addSupplementaryRegister(std::vector<DynamicRegisterInfo::Register> ®s, |
135 | | DynamicRegisterInfo::Register new_reg_info); |
136 | | |
137 | | } // namespace lldb_private |
138 | | |
139 | | #endif // LLDB_TARGET_DYNAMICREGISTERINFO_H |