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
17#include "lldb/lldb-private.h"
18
19namespace lldb_private {
20
22protected:
25
26public:
27 struct Register {
39 std::vector<uint32_t> value_regs;
40 std::vector<uint32_t> invalidate_regs;
42 };
43
45
47 const lldb_private::ArchSpec &arch);
48
49 virtual ~DynamicRegisterInfo() = default;
50
53
55 const lldb_private::ArchSpec &arch);
56
57 size_t SetRegisterInfo(std::vector<Register> &&regs,
58 const lldb_private::ArchSpec &arch);
59
60 size_t GetNumRegisters() const;
61
62 size_t GetNumRegisterSets() const;
63
64 size_t GetRegisterDataByteSize() const;
65
66 const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(uint32_t i) const;
67
68 const lldb_private::RegisterSet *GetRegisterSet(uint32_t i) const;
69
71 bool can_create);
72
74 uint32_t num) const;
75
76 const lldb_private::RegisterInfo *GetRegisterInfo(uint32_t kind,
77 uint32_t num) const;
78
79 void Dump() const;
80
81 void Clear();
82
83 bool IsReconfigurable();
84
85 const lldb_private::RegisterInfo *
86 GetRegisterInfo(llvm::StringRef reg_name) const;
87
88 typedef std::vector<lldb_private::RegisterInfo> reg_collection;
89 llvm::iterator_range<reg_collection::const_iterator> registers() const {
90 return llvm::iterator_range<reg_collection::const_iterator>(m_regs);
91 }
92
93protected:
94 // Classes that inherit from DynamicRegisterInfo can see and modify these
95 typedef std::vector<lldb_private::RegisterSet> set_collection;
96 typedef std::vector<uint32_t> reg_num_collection;
97 typedef std::vector<reg_num_collection> set_reg_num_collection;
98 typedef std::vector<lldb_private::ConstString> name_collection;
99 typedef std::map<uint32_t, reg_num_collection> reg_to_regs_map;
100 typedef std::map<uint32_t, uint32_t> reg_offset_map;
101
102 llvm::Expected<uint32_t> ByteOffsetFromSlice(uint32_t index,
103 llvm::StringRef slice_str,
104 lldb::ByteOrder byte_order);
105 llvm::Expected<uint32_t> ByteOffsetFromComposite(
106 uint32_t index, lldb_private::StructuredData::Array &composite_reg_list,
107 lldb::ByteOrder byte_order);
108 llvm::Expected<uint32_t> ByteOffsetFromRegInfoDict(
110 lldb::ByteOrder byte_order);
111
112 void MoveFrom(DynamicRegisterInfo &&info);
113
114 void Finalize(const lldb_private::ArchSpec &arch);
115
116 void ConfigureOffsets();
117
125 size_t m_reg_data_byte_size = 0u; // The number of bytes required to store
126 // all registers
127 bool m_finalized = false;
129};
130
131void addSupplementaryRegister(std::vector<DynamicRegisterInfo::Register> &regs,
132 DynamicRegisterInfo::Register new_reg_info);
133
134} // namespace lldb_private
135
136#endif // LLDB_TARGET_DYNAMICREGISTERINFO_H
An architecture specification class.
Definition: ArchSpec.h:32
A uniqued constant string class.
Definition: ConstString.h:39
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
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
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
llvm::iterator_range< reg_collection::const_iterator > registers() 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)
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:75
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:79
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
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.