LLDB mainline
DynamicRegisterInfo.h
Go to the documentation of this file.
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 <string>
14#include <vector>
15
19#include "lldb/lldb-private.h"
20#include "llvm/ADT/StringSet.h"
21
22namespace lldb_private {
23class Stream;
24
26public:
27 struct Register {
28 std::string name;
29 std::string alt_name;
30 std::string set_name;
39 std::vector<uint32_t> value_regs;
40 std::vector<uint32_t> invalidate_regs;
41 uint32_t value_reg_offset = 0;
42 // Non-null if there is an XML provided type.
43 const RegisterType *register_type = nullptr;
44 };
45
49
50 static std::unique_ptr<DynamicRegisterInfo>
51 Create(const StructuredData::Dictionary &dict, const ArchSpec &arch);
52
53 virtual ~DynamicRegisterInfo() = default;
54
57
59 const lldb_private::ArchSpec &arch);
60
61 size_t SetRegisterInfo(std::vector<Register> &&regs,
62 const lldb_private::ArchSpec &arch);
63
64 size_t GetNumRegisters() const;
65
66 size_t GetNumRegisterSets() const;
67
68 size_t GetRegisterDataByteSize() const;
69
71
72 const lldb_private::RegisterSet *GetRegisterSet(uint32_t i) const;
73
74 uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind,
75 uint32_t num) const;
76
78 uint32_t num) const;
79
80 void Dump(Stream &s) const;
81
82 void Clear();
83
84 bool IsReconfigurable();
85
87 GetRegisterInfo(llvm::StringRef reg_name) const;
88
89 typedef std::vector<lldb_private::RegisterInfo> reg_collection;
90 typedef llvm::iterator_range<reg_collection::const_iterator>
92 typedef llvm::iterator_range<reg_collection::iterator> reg_collection_range;
93
94 template <typename T> T registers() = delete;
95
96 template <typename T> T registers() const = delete;
97
98 void ConfigureOffsets();
99
100protected:
101 // Classes that inherit from DynamicRegisterInfo can see and modify these
102 typedef std::vector<lldb_private::RegisterSet> set_collection;
103 typedef std::vector<uint32_t> reg_num_collection;
104 typedef std::vector<reg_num_collection> set_reg_num_collection;
105 typedef std::map<uint32_t, reg_num_collection> reg_to_regs_map;
106 typedef std::map<uint32_t, uint32_t> reg_offset_map;
107
108 llvm::Expected<uint32_t> ByteOffsetFromSlice(uint32_t index,
109 llvm::StringRef slice_str,
110 lldb::ByteOrder byte_order);
111 llvm::Expected<uint32_t> ByteOffsetFromComposite(
112 uint32_t index, lldb_private::StructuredData::Array &composite_reg_list,
113 lldb::ByteOrder byte_order);
114 llvm::Expected<uint32_t> ByteOffsetFromRegInfoDict(
115 uint32_t index, lldb_private::StructuredData::Dictionary &reg_info_dict,
116 lldb::ByteOrder byte_order);
117
118 void MoveFrom(DynamicRegisterInfo &&info);
119
120 void CopyFrom(const DynamicRegisterInfo &info);
121
122 void Finalize(const lldb_private::ArchSpec &arch);
123
124 // Returns a NUL-terminated copy of `str` owned by m_strings, or nullptr if
125 // `str` is empty.
126 const char *Intern(llvm::StringRef str);
127
128 // Owns the storage for all strings referenced by m_regs and m_sets.
129 llvm::StringSet<> m_strings;
136 size_t m_reg_data_byte_size = 0u; // The number of bytes required to store
137 // all registers
138 bool m_finalized = false;
140};
141
142template <>
147
148template <>
153
154template <>
159
160void addSupplementaryRegister(std::vector<DynamicRegisterInfo::Register> &regs,
161 DynamicRegisterInfo::Register new_reg_info);
162
163} // namespace lldb_private
164
165#endif // LLDB_TARGET_DYNAMICREGISTERINFO_H
An architecture specification class.
Definition ArchSpec.h:32
size_t SetRegisterInfo(const lldb_private::StructuredData::Dictionary &dict, const lldb_private::ArchSpec &arch)
std::vector< uint32_t > reg_num_collection
std::map< uint32_t, uint32_t > reg_offset_map
llvm::iterator_range< reg_collection::const_iterator > reg_collection_const_range
llvm::iterator_range< reg_collection::iterator > reg_collection_range
std::vector< reg_num_collection > set_reg_num_collection
const lldb_private::RegisterSet * GetRegisterSet(uint32_t i) const
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(uint32_t i) const
DynamicRegisterInfo & operator=(const DynamicRegisterInfo &info)
uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind, uint32_t num) const
static std::unique_ptr< DynamicRegisterInfo > Create(const StructuredData::Dictionary &dict, const ArchSpec &arch)
void CopyFrom(const DynamicRegisterInfo &info)
std::map< uint32_t, reg_num_collection > reg_to_regs_map
virtual ~DynamicRegisterInfo()=default
llvm::Expected< uint32_t > ByteOffsetFromComposite(uint32_t index, lldb_private::StructuredData::Array &composite_reg_list, lldb::ByteOrder byte_order)
void Finalize(const lldb_private::ArchSpec &arch)
void MoveFrom(DynamicRegisterInfo &&info)
llvm::Expected< uint32_t > ByteOffsetFromSlice(uint32_t index, llvm::StringRef slice_str, lldb::ByteOrder byte_order)
const char * Intern(llvm::StringRef str)
std::vector< lldb_private::RegisterSet > set_collection
const lldb_private::RegisterInfo * GetRegisterInfo(uint32_t kind, uint32_t num) const
std::vector< lldb_private::RegisterInfo > reg_collection
llvm::Expected< uint32_t > ByteOffsetFromRegInfoDict(uint32_t index, lldb_private::StructuredData::Dictionary &reg_info_dict, lldb::ByteOrder byte_order)
A stream class that can stream formatted output to a file.
Definition Stream.h:28
#define LLDB_INVALID_INDEX32
#define LLDB_INVALID_REGNUM
A class that represents a running process on the host machine.
void addSupplementaryRegister(std::vector< DynamicRegisterInfo::Register > &regs, DynamicRegisterInfo::Register new_reg_info)
Format
Display format definitions.
Encoding
Register encoding definitions.
@ eEncodingUint
unsigned integer
ByteOrder
Byte ordering definitions.
Every register is described in detail including its name, alternate name (optional),...
Registers are grouped into register sets.