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 
19 namespace lldb_private {
20 
22 protected:
25 
26 public:
27  struct Register {
39  std::vector<uint32_t> value_regs;
40  std::vector<uint32_t> invalidate_regs;
42  };
43 
44  DynamicRegisterInfo() = default;
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 
93 protected:
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;
128  bool m_is_reconfigurable = false;
129 };
130 
131 void addSupplementaryRegister(std::vector<DynamicRegisterInfo::Register> &regs,
132  DynamicRegisterInfo::Register new_reg_info);
133 
134 } // namespace lldb_private
135 
136 #endif // LLDB_TARGET_DYNAMICREGISTERINFO_H
lldb_private::DynamicRegisterInfo::Register::byte_size
uint32_t byte_size
Definition: DynamicRegisterInfo.h:31
lldb_private::DynamicRegisterInfo::m_is_reconfigurable
bool m_is_reconfigurable
Definition: DynamicRegisterInfo.h:128
lldb_private::DynamicRegisterInfo::MoveFrom
void MoveFrom(DynamicRegisterInfo &&info)
Definition: DynamicRegisterInfo.cpp:38
lldb_private::StructuredData::Dictionary
Definition: StructuredData.h:352
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::DynamicRegisterInfo::ByteOffsetFromSlice
llvm::Expected< uint32_t > ByteOffsetFromSlice(uint32_t index, llvm::StringRef slice_str, lldb::ByteOrder byte_order)
Definition: DynamicRegisterInfo.cpp:58
LLDB_INVALID_REGNUM
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:91
lldb_private::DynamicRegisterInfo::m_set_reg_nums
set_reg_num_collection m_set_reg_nums
Definition: DynamicRegisterInfo.h:120
lldb::Format
Format
Display format definitions.
Definition: lldb-enumerations.h:155
lldb_private::DynamicRegisterInfo::Register::alt_name
ConstString alt_name
Definition: DynamicRegisterInfo.h:29
lldb_private::StructuredData::Array
Definition: StructuredData.h:165
lldb_private::DynamicRegisterInfo::Register::set_name
ConstString set_name
Definition: DynamicRegisterInfo.h:30
StructuredData.h
lldb_private::DynamicRegisterInfo::reg_to_regs_map
std::map< uint32_t, reg_num_collection > reg_to_regs_map
Definition: DynamicRegisterInfo.h:99
lldb_private::DynamicRegisterInfo::m_invalidate_regs_map
reg_to_regs_map m_invalidate_regs_map
Definition: DynamicRegisterInfo.h:123
lldb_private::DynamicRegisterInfo::reg_offset_map
std::map< uint32_t, uint32_t > reg_offset_map
Definition: DynamicRegisterInfo.h:100
lldb_private::DynamicRegisterInfo::m_sets
set_collection m_sets
Definition: DynamicRegisterInfo.h:119
lldb_private::addSupplementaryRegister
void addSupplementaryRegister(std::vector< DynamicRegisterInfo::Register > &regs, DynamicRegisterInfo::Register new_reg_info)
Definition: DynamicRegisterInfo.cpp:796
lldb_private::DynamicRegisterInfo::Clear
void Clear()
Definition: DynamicRegisterInfo.cpp:725
lldb_private::DynamicRegisterInfo::name_collection
std::vector< lldb_private::ConstString > name_collection
Definition: DynamicRegisterInfo.h:98
lldb_private::DynamicRegisterInfo::m_regs
reg_collection m_regs
Definition: DynamicRegisterInfo.h:118
lldb_private::DynamicRegisterInfo::m_reg_data_byte_size
size_t m_reg_data_byte_size
Definition: DynamicRegisterInfo.h:125
lldb_private::DynamicRegisterInfo::Register::format
lldb::Format format
Definition: DynamicRegisterInfo.h:34
lldb_private::DynamicRegisterInfo::m_value_regs_map
reg_to_regs_map m_value_regs_map
Definition: DynamicRegisterInfo.h:122
lldb_private::DynamicRegisterInfo::set_reg_num_collection
std::vector< reg_num_collection > set_reg_num_collection
Definition: DynamicRegisterInfo.h:97
lldb_private::DynamicRegisterInfo::SetRegisterInfo
size_t SetRegisterInfo(const lldb_private::StructuredData::Dictionary &dict, const lldb_private::ArchSpec &arch)
Definition: DynamicRegisterInfo.cpp:193
lldb_private::DynamicRegisterInfo::Register::encoding
lldb::Encoding encoding
Definition: DynamicRegisterInfo.h:33
lldb_private::DynamicRegisterInfo::GetNumRegisterSets
size_t GetNumRegisterSets() const
Definition: DynamicRegisterInfo.cpp:670
lldb_private::DynamicRegisterInfo::Register::invalidate_regs
std::vector< uint32_t > invalidate_regs
Definition: DynamicRegisterInfo.h:40
lldb_private::DynamicRegisterInfo::Register::regnum_remote
uint32_t regnum_remote
Definition: DynamicRegisterInfo.h:38
lldb_private::DynamicRegisterInfo::Register::regnum_dwarf
uint32_t regnum_dwarf
Definition: DynamicRegisterInfo.h:35
lldb_private::DynamicRegisterInfo::GetRegisterSetIndexByName
uint32_t GetRegisterSetIndexByName(const lldb_private::ConstString &set_name, bool can_create)
Definition: DynamicRegisterInfo.cpp:698
lldb::eEncodingUint
@ eEncodingUint
unsigned integer
Definition: lldb-enumerations.h:148
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::DynamicRegisterInfo::registers
llvm::iterator_range< reg_collection::const_iterator > registers() const
Definition: DynamicRegisterInfo.h:89
lldb_private::DynamicRegisterInfo::reg_collection
std::vector< lldb_private::RegisterInfo > reg_collection
Definition: DynamicRegisterInfo.h:88
lldb_private::DynamicRegisterInfo::Register::byte_offset
uint32_t byte_offset
Definition: DynamicRegisterInfo.h:32
lldb_private::DynamicRegisterInfo::m_set_names
name_collection m_set_names
Definition: DynamicRegisterInfo.h:121
lldb_private::DynamicRegisterInfo::IsReconfigurable
bool IsReconfigurable()
Definition: DynamicRegisterInfo.cpp:666
lldb_private::DynamicRegisterInfo::Register
Definition: DynamicRegisterInfo.h:27
lldb_private::DynamicRegisterInfo::operator=
DynamicRegisterInfo & operator=(DynamicRegisterInfo &)=default
lldb_private::DynamicRegisterInfo::GetRegisterInfoAtIndex
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(uint32_t i) const
Definition: DynamicRegisterInfo.cpp:677
lldb-private.h
lldb_private::DynamicRegisterInfo::ByteOffsetFromRegInfoDict
llvm::Expected< uint32_t > ByteOffsetFromRegInfoDict(uint32_t index, lldb_private::StructuredData::Dictionary &reg_info_dict, lldb::ByteOrder byte_order)
Definition: DynamicRegisterInfo.cpp:168
lldb_private::DynamicRegisterInfo::Register::value_regs
std::vector< uint32_t > value_regs
Definition: DynamicRegisterInfo.h:39
lldb_private::DynamicRegisterInfo::Register::value_reg_offset
uint32_t value_reg_offset
Definition: DynamicRegisterInfo.h:41
lldb_private::DynamicRegisterInfo::m_finalized
bool m_finalized
Definition: DynamicRegisterInfo.h:127
uint32_t
lldb_private::DynamicRegisterInfo::reg_num_collection
std::vector< uint32_t > reg_num_collection
Definition: DynamicRegisterInfo.h:96
lldb_private::DynamicRegisterInfo::Register::regnum_generic
uint32_t regnum_generic
Definition: DynamicRegisterInfo.h:37
lldb_private::DynamicRegisterInfo::~DynamicRegisterInfo
virtual ~DynamicRegisterInfo()=default
lldb_private::DynamicRegisterInfo::GetRegisterInfo
const lldb_private::RegisterInfo * GetRegisterInfo(uint32_t kind, uint32_t num) const
Definition: DynamicRegisterInfo.cpp:683
lldb_private::DynamicRegisterInfo::m_value_reg_offset_map
reg_offset_map m_value_reg_offset_map
Definition: DynamicRegisterInfo.h:124
lldb::Encoding
Encoding
Register encoding definitions.
Definition: lldb-enumerations.h:146
lldb_private::DynamicRegisterInfo::GetRegisterDataByteSize
size_t GetRegisterDataByteSize() const
Definition: DynamicRegisterInfo.cpp:672
lldb_private::DynamicRegisterInfo::Register::regnum_ehframe
uint32_t regnum_ehframe
Definition: DynamicRegisterInfo.h:36
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::eFormatHex
@ eFormatHex
Definition: lldb-enumerations.h:169
lldb_private::DynamicRegisterInfo::Finalize
void Finalize(const lldb_private::ArchSpec &arch)
Definition: DynamicRegisterInfo.cpp:425
lldb_private::DynamicRegisterInfo::ConfigureOffsets
void ConfigureOffsets()
Definition: DynamicRegisterInfo.cpp:617
ConstString.h
LLDB_INVALID_INDEX32
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:87
lldb_private::DynamicRegisterInfo::GetNumRegisters
size_t GetNumRegisters() const
Definition: DynamicRegisterInfo.cpp:668
lldb_private::DynamicRegisterInfo
Definition: DynamicRegisterInfo.h:21
lldb_private::DynamicRegisterInfo::Register::name
ConstString name
Definition: DynamicRegisterInfo.h:28
lldb_private::DynamicRegisterInfo::DynamicRegisterInfo
DynamicRegisterInfo()=default
lldb_private::DynamicRegisterInfo::Dump
void Dump() const
Definition: DynamicRegisterInfo.cpp:736
lldb_private::DynamicRegisterInfo::GetRegisterSet
const lldb_private::RegisterSet * GetRegisterSet(uint32_t i) const
Definition: DynamicRegisterInfo.cpp:691
lldb_private::DynamicRegisterInfo::set_collection
std::vector< lldb_private::RegisterSet > set_collection
Definition: DynamicRegisterInfo.h:95
lldb_private::DynamicRegisterInfo::ConvertRegisterKindToRegisterNumber
uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind, uint32_t num) const
Definition: DynamicRegisterInfo.cpp:714
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition: lldb-enumerations.h:138
lldb_private::DynamicRegisterInfo::ByteOffsetFromComposite
llvm::Expected< uint32_t > ByteOffsetFromComposite(uint32_t index, lldb_private::StructuredData::Array &composite_reg_list, lldb::ByteOrder byte_order)
Definition: DynamicRegisterInfo.cpp:128