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_SOURCE_PLUGINS_PROCESS_UTILITY_DYNAMICREGISTERINFO_H 10 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_DYNAMICREGISTERINFO_H 11 12 #include <map> 13 #include <vector> 14 15 #include "lldb/Utility/ConstString.h" 16 #include "lldb/Utility/StructuredData.h" 17 #include "lldb/lldb-private.h" 18 19 class DynamicRegisterInfo { 20 protected: 21 DynamicRegisterInfo(DynamicRegisterInfo &) = default; 22 DynamicRegisterInfo &operator=(DynamicRegisterInfo &) = default; 23 24 public: 25 DynamicRegisterInfo() = default; 26 27 DynamicRegisterInfo(const lldb_private::StructuredData::Dictionary &dict, 28 const lldb_private::ArchSpec &arch); 29 30 virtual ~DynamicRegisterInfo() = default; 31 32 DynamicRegisterInfo(DynamicRegisterInfo &&info); 33 DynamicRegisterInfo &operator=(DynamicRegisterInfo &&info); 34 35 size_t SetRegisterInfo(const lldb_private::StructuredData::Dictionary &dict, 36 const lldb_private::ArchSpec &arch); 37 38 void AddRegister(lldb_private::RegisterInfo ®_info, 39 lldb_private::ConstString ®_name, 40 lldb_private::ConstString ®_alt_name, 41 lldb_private::ConstString &set_name); 42 43 void Finalize(const lldb_private::ArchSpec &arch); 44 45 size_t GetNumRegisters() const; 46 47 size_t GetNumRegisterSets() const; 48 49 size_t GetRegisterDataByteSize() const; 50 51 const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(uint32_t i) const; 52 53 lldb_private::RegisterInfo *GetRegisterInfoAtIndex(uint32_t i); 54 55 const lldb_private::RegisterSet *GetRegisterSet(uint32_t i) const; 56 57 uint32_t GetRegisterSetIndexByName(lldb_private::ConstString &set_name, 58 bool can_create); 59 60 uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind, 61 uint32_t num) const; 62 63 const lldb_private::RegisterInfo *GetRegisterInfo(uint32_t kind, 64 uint32_t num) const; 65 66 void Dump() const; 67 68 void Clear(); 69 70 bool IsReconfigurable(); 71 72 const lldb_private::RegisterInfo * 73 GetRegisterInfo(llvm::StringRef reg_name) const; 74 75 protected: 76 // Classes that inherit from DynamicRegisterInfo can see and modify these 77 typedef std::vector<lldb_private::RegisterInfo> reg_collection; 78 typedef std::vector<lldb_private::RegisterSet> set_collection; 79 typedef std::vector<uint32_t> reg_num_collection; 80 typedef std::vector<reg_num_collection> set_reg_num_collection; 81 typedef std::vector<lldb_private::ConstString> name_collection; 82 typedef std::map<uint32_t, reg_num_collection> reg_to_regs_map; 83 typedef std::vector<uint8_t> dwarf_opcode; 84 typedef std::map<uint32_t, dwarf_opcode> dynamic_reg_size_map; 85 86 void MoveFrom(DynamicRegisterInfo &&info); 87 88 void ConfigureOffsets(); 89 90 reg_collection m_regs; 91 set_collection m_sets; 92 set_reg_num_collection m_set_reg_nums; 93 name_collection m_set_names; 94 reg_to_regs_map m_value_regs_map; 95 reg_to_regs_map m_invalidate_regs_map; 96 dynamic_reg_size_map m_dynamic_reg_size_map; 97 size_t m_reg_data_byte_size = 0u; // The number of bytes required to store 98 // all registers 99 bool m_finalized = false; 100 bool m_is_reconfigurable = false; 101 }; 102 #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_DYNAMICREGISTERINFO_H 103