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