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 <vector>
14
18#include "lldb/lldb-private.h"
19
20namespace lldb_private {
21
23protected:
26
27public:
28 struct Register {
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
48
49 static std::unique_ptr<DynamicRegisterInfo>
50 Create(const StructuredData::Dictionary &dict, const ArchSpec &arch);
51
52 virtual ~DynamicRegisterInfo() = default;
53
56
58 const lldb_private::ArchSpec &arch);
59
60 size_t SetRegisterInfo(std::vector<Register> &&regs,
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
70
71 const lldb_private::RegisterSet *GetRegisterSet(uint32_t i) const;
72
74 bool can_create);
75
76 uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind,
77 uint32_t num) const;
78
80 uint32_t num) const;
81
82 void Dump() const;
83
84 void Clear();
85
86 bool IsReconfigurable();
87
89 GetRegisterInfo(llvm::StringRef reg_name) const;
90
91 typedef std::vector<lldb_private::RegisterInfo> reg_collection;
92 typedef llvm::iterator_range<reg_collection::const_iterator>
94 typedef llvm::iterator_range<reg_collection::iterator> reg_collection_range;
95
96 template <typename T> T registers() = 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::vector<lldb_private::ConstString> name_collection;
106 typedef std::map<uint32_t, reg_num_collection> reg_to_regs_map;
107 typedef std::map<uint32_t, uint32_t> reg_offset_map;
108
109 llvm::Expected<uint32_t> ByteOffsetFromSlice(uint32_t index,
110 llvm::StringRef slice_str,
111 lldb::ByteOrder byte_order);
112 llvm::Expected<uint32_t> ByteOffsetFromComposite(
113 uint32_t index, lldb_private::StructuredData::Array &composite_reg_list,
114 lldb::ByteOrder byte_order);
115 llvm::Expected<uint32_t> ByteOffsetFromRegInfoDict(
116 uint32_t index, lldb_private::StructuredData::Dictionary &reg_info_dict,
117 lldb::ByteOrder byte_order);
118
119 void MoveFrom(DynamicRegisterInfo &&info);
120
121 void Finalize(const lldb_private::ArchSpec &arch);
122
130 size_t m_reg_data_byte_size = 0u; // The number of bytes required to store
131 // all registers
132 bool m_finalized = false;
134};
135
136template <>
140}
141
142template <>
146}
147
148void addSupplementaryRegister(std::vector<DynamicRegisterInfo::Register> &regs,
149 DynamicRegisterInfo::Register new_reg_info);
150
151} // namespace lldb_private
152
153#endif // LLDB_TARGET_DYNAMICREGISTERINFO_H
An architecture specification class.
Definition: ArchSpec.h:31
A uniqued constant string class.
Definition: ConstString.h:40
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
uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind, uint32_t num) const
static std::unique_ptr< DynamicRegisterInfo > Create(const StructuredData::Dictionary &dict, const ArchSpec &arch)
DynamicRegisterInfo(DynamicRegisterInfo &)=default
std::map< uint32_t, reg_num_collection > reg_to_regs_map
virtual ~DynamicRegisterInfo()=default
std::vector< lldb_private::ConstString > name_collection
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)
uint32_t GetRegisterSetIndexByName(const lldb_private::ConstString &set_name, bool can_create)
std::vector< lldb_private::RegisterSet > set_collection
const lldb_private::RegisterInfo * GetRegisterInfo(uint32_t kind, uint32_t num) const
DynamicRegisterInfo & operator=(DynamicRegisterInfo &)=default
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)
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:83
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:87
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.