1 //===-- DynamicRegisterInfo.h -----------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef lldb_DynamicRegisterInfo_h_
11 #define lldb_DynamicRegisterInfo_h_
12 
13 // C Includes
14 // C++ Includes
15 #include <vector>
16 #include <map>
17 
18 // Other libraries and framework includes
19 // Project includes
20 #include "lldb/lldb-private.h"
21 #include "lldb/Core/ConstString.h"
22 #include "lldb/Core/StructuredData.h"
23 
24 class DynamicRegisterInfo
25 {
26 public:
27     DynamicRegisterInfo ();
28 
29     DynamicRegisterInfo(const lldb_private::StructuredData::Dictionary &dict,
30                         const lldb_private::ArchSpec &arch);
31 
32     virtual
33     ~DynamicRegisterInfo ();
34 
35     size_t SetRegisterInfo(const lldb_private::StructuredData::Dictionary &dict,
36                            const lldb_private::ArchSpec &arch);
37 
38     void
39     AddRegister (lldb_private::RegisterInfo &reg_info,
40                  lldb_private::ConstString &reg_name,
41                  lldb_private::ConstString &reg_alt_name,
42                  lldb_private::ConstString &set_name);
43 
44     void
45     Finalize (const lldb_private::ArchSpec &arch);
46 
47     size_t
48     GetNumRegisters() const;
49 
50     size_t
51     GetNumRegisterSets() const;
52 
53     size_t
54     GetRegisterDataByteSize() const;
55 
56     const lldb_private::RegisterInfo *
57     GetRegisterInfoAtIndex (uint32_t i) const;
58 
59     lldb_private::RegisterInfo *
60     GetRegisterInfoAtIndex (uint32_t i);
61 
62     const lldb_private::RegisterSet *
63     GetRegisterSet (uint32_t i) const;
64 
65     uint32_t
66     GetRegisterSetIndexByName (lldb_private::ConstString &set_name, bool can_create);
67 
68     uint32_t
69     ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) const;
70 
71     void
72     Dump () const;
73 
74     void
75     Clear();
76 
77 protected:
78     //------------------------------------------------------------------
79     // Classes that inherit from DynamicRegisterInfo can see and modify these
80     //------------------------------------------------------------------
81     typedef std::vector <lldb_private::RegisterInfo> reg_collection;
82     typedef std::vector <lldb_private::RegisterSet> set_collection;
83     typedef std::vector <uint32_t> reg_num_collection;
84     typedef std::vector <reg_num_collection> set_reg_num_collection;
85     typedef std::vector <lldb_private::ConstString> name_collection;
86     typedef std::map<uint32_t, reg_num_collection> reg_to_regs_map;
87     typedef std::vector <uint8_t> dwarf_opcode;
88     typedef std::map<uint32_t, dwarf_opcode> dynamic_reg_size_map;
89 
90     lldb_private::RegisterInfo *
91     GetRegisterInfo (const lldb_private::ConstString &reg_name);
92 
93     reg_collection m_regs;
94     set_collection m_sets;
95     set_reg_num_collection m_set_reg_nums;
96     name_collection m_set_names;
97     reg_to_regs_map m_value_regs_map;
98     reg_to_regs_map m_invalidate_regs_map;
99     dynamic_reg_size_map m_dynamic_reg_size_map;
100     size_t m_reg_data_byte_size;   // The number of bytes required to store all registers
101     bool m_finalized;
102 };
103 
104 #endif  // lldb_DynamicRegisterInfo_h_
105