]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Host/common/NativeRegisterContext.h
Update llvm, clang and lldb to 3.7.0 release.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Host / common / NativeRegisterContext.h
1 //===-- NativeRegisterContext.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 liblldb_NativeRegisterContext_h_
11 #define liblldb_NativeRegisterContext_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/lldb-private.h"
18 #include "lldb/Host/common/NativeWatchpointList.h"
19
20 namespace lldb_private {
21
22 class NativeThreadProtocol;
23
24 class NativeRegisterContext:
25     public std::enable_shared_from_this<NativeRegisterContext>
26 {
27 public:
28     //------------------------------------------------------------------
29     // Constructors and Destructors
30     //------------------------------------------------------------------
31     NativeRegisterContext (NativeThreadProtocol &thread, uint32_t concrete_frame_idx);
32
33     virtual
34     ~NativeRegisterContext ();
35
36     // void
37     // InvalidateIfNeeded (bool force);
38
39     //------------------------------------------------------------------
40     // Subclasses must override these functions
41     //------------------------------------------------------------------
42     // virtual void
43     // InvalidateAllRegisters () = 0;
44
45     virtual uint32_t
46     GetRegisterCount () const = 0;
47
48     virtual uint32_t
49     GetUserRegisterCount () const = 0;
50
51     virtual const RegisterInfo *
52     GetRegisterInfoAtIndex (uint32_t reg) const = 0;
53
54     const char *
55     GetRegisterSetNameForRegisterAtIndex (uint32_t reg_index) const;
56
57     virtual uint32_t
58     GetRegisterSetCount () const = 0;
59
60     virtual const RegisterSet *
61     GetRegisterSet (uint32_t set_index) const = 0;
62
63     virtual Error
64     ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value) = 0;
65
66     virtual Error
67     WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value) = 0;
68
69     virtual Error
70     ReadAllRegisterValues (lldb::DataBufferSP &data_sp) = 0;
71
72     virtual Error
73     WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) = 0;
74
75     uint32_t
76     ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) const;
77
78     //------------------------------------------------------------------
79     // Subclasses can override these functions if desired
80     //------------------------------------------------------------------
81     virtual uint32_t
82     NumSupportedHardwareBreakpoints ();
83
84     virtual uint32_t
85     SetHardwareBreakpoint (lldb::addr_t addr, size_t size);
86
87     virtual bool
88     ClearHardwareBreakpoint (uint32_t hw_idx);
89
90     virtual uint32_t
91     NumSupportedHardwareWatchpoints ();
92
93     virtual uint32_t
94     SetHardwareWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags);
95
96     virtual bool
97     ClearHardwareWatchpoint (uint32_t hw_index);
98
99     virtual Error
100     ClearAllHardwareWatchpoints ();
101
102     virtual Error
103     IsWatchpointHit(uint32_t wp_index, bool &is_hit);
104
105     virtual Error
106     GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr);
107
108     virtual Error
109     IsWatchpointVacant (uint32_t wp_index, bool &is_vacant);
110
111     virtual lldb::addr_t
112     GetWatchpointAddress (uint32_t wp_index);
113
114     // MIPS Linux kernel returns a masked address (last 3bits are masked)
115     // when a HW watchpoint is hit. However user may not have set a watchpoint
116     // on this address. This function emulates the instruction at PC and 
117     // finds the base address used in the load/store instruction. This gives the 
118     // exact address used to read/write the variable being watched.
119     // For example:
120     // 'n' is at 0x120010d00 and 'm' is 0x120010d04. When a watchpoint is set at 'm', 
121     // then watch exception is generated even when 'n' is read/written. This function
122     // returns address of 'n' so that client can check whether a watchpoint is set
123     // on this address or not.
124     virtual lldb::addr_t
125     GetWatchpointHitAddress (uint32_t wp_index);
126
127     virtual bool
128     HardwareSingleStep (bool enable);
129
130     virtual Error
131     ReadRegisterValueFromMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, size_t src_len, RegisterValue &reg_value);
132
133     virtual Error
134     WriteRegisterValueToMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, size_t dst_len, const RegisterValue &reg_value);
135
136     //------------------------------------------------------------------
137     // Subclasses should not override these
138     //------------------------------------------------------------------
139     virtual lldb::tid_t
140     GetThreadID() const;
141
142     virtual NativeThreadProtocol &
143     GetThread ()
144     {
145         return m_thread;
146     }
147
148     const RegisterInfo *
149     GetRegisterInfoByName (const char *reg_name, uint32_t start_idx = 0);
150
151     const RegisterInfo *
152     GetRegisterInfo (uint32_t reg_kind, uint32_t reg_num);
153
154     lldb::addr_t
155     GetPC (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
156
157     virtual lldb::addr_t
158     GetPCfromBreakpointLocation (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
159
160     Error
161     SetPC (lldb::addr_t pc);
162
163     lldb::addr_t
164     GetSP (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
165
166     Error
167     SetSP (lldb::addr_t sp);
168
169     lldb::addr_t
170     GetFP (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
171
172     Error
173     SetFP (lldb::addr_t fp);
174
175     const char *
176     GetRegisterName (uint32_t reg);
177
178     lldb::addr_t
179     GetReturnAddress (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS);
180
181     lldb::addr_t
182     GetFlags (lldb::addr_t fail_value = 0);
183
184     lldb::addr_t
185     ReadRegisterAsUnsigned (uint32_t reg, lldb::addr_t fail_value);
186
187     lldb::addr_t
188     ReadRegisterAsUnsigned (const RegisterInfo *reg_info, lldb::addr_t fail_value);
189
190     Error
191     WriteRegisterFromUnsigned (uint32_t reg, uint64_t uval);
192
193     Error
194     WriteRegisterFromUnsigned (const RegisterInfo *reg_info, uint64_t uval);
195
196     // uint32_t
197     // GetStopID () const
198     // {
199     //     return m_stop_id;
200     // }
201
202     // void
203     // SetStopID (uint32_t stop_id)
204     // {
205     //     m_stop_id = stop_id;
206     // }
207
208 protected:
209     //------------------------------------------------------------------
210     // Classes that inherit from RegisterContext can see and modify these
211     //------------------------------------------------------------------
212     NativeThreadProtocol &m_thread; // The thread that this register context belongs to.
213     uint32_t m_concrete_frame_idx;  // The concrete frame index for this register context
214     // uint32_t m_stop_id;             // The stop ID that any data in this context is valid for
215
216 private:
217     //------------------------------------------------------------------
218     // For RegisterContext only
219     //------------------------------------------------------------------
220     DISALLOW_COPY_AND_ASSIGN (NativeRegisterContext);
221 };
222
223 } // namespace lldb_private
224
225 #endif  // liblldb_NativeRegisterContext_h_