]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / source / Plugins / Process / gdb-remote / GDBRemoteRegisterContext.h
1 //===-- GDBRemoteRegisterContext.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_GDBRemoteRegisterContext_h_
11 #define lldb_GDBRemoteRegisterContext_h_
12
13 // C Includes
14 // C++ Includes
15 #include <vector>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/lldb-private.h"
20 #include "lldb/lldb-enumerations.h"
21 #include "lldb/Core/ConstString.h"
22 #include "lldb/Core/DataExtractor.h"
23 #include "lldb/Target/RegisterContext.h"
24 #include "Plugins/Process/Utility/DynamicRegisterInfo.h"
25
26 #include "GDBRemoteCommunicationClient.h"
27
28 class ThreadGDBRemote;
29 class ProcessGDBRemote;
30 class StringExtractor;
31
32 class GDBRemoteDynamicRegisterInfo :
33     public DynamicRegisterInfo
34 {
35 public:
36     GDBRemoteDynamicRegisterInfo () :
37         DynamicRegisterInfo()
38     {
39     }
40
41     ~GDBRemoteDynamicRegisterInfo ()
42     {
43     }
44
45     void
46     HardcodeARMRegisters(bool from_scratch);
47
48 };
49
50 class GDBRemoteRegisterContext : public lldb_private::RegisterContext
51 {
52 public:
53     //------------------------------------------------------------------
54     // Constructors and Destructors
55     //------------------------------------------------------------------
56     GDBRemoteRegisterContext (ThreadGDBRemote &thread,
57                               uint32_t concrete_frame_idx,
58                               GDBRemoteDynamicRegisterInfo &reg_info,
59                               bool read_all_at_once);
60
61     virtual
62     ~GDBRemoteRegisterContext ();
63
64     //------------------------------------------------------------------
65     // Subclasses must override these functions
66     //------------------------------------------------------------------
67     virtual void
68     InvalidateAllRegisters ();
69
70     virtual size_t
71     GetRegisterCount ();
72
73     virtual const lldb_private::RegisterInfo *
74     GetRegisterInfoAtIndex (size_t reg);
75
76     virtual size_t
77     GetRegisterSetCount ();
78
79     virtual const lldb_private::RegisterSet *
80     GetRegisterSet (size_t reg_set);
81
82     virtual bool
83     ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
84
85     virtual bool
86     WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
87     
88     virtual bool
89     ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
90
91     virtual bool
92     WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
93
94     virtual bool
95     ReadAllRegisterValues (lldb_private::RegisterCheckpoint &reg_checkpoint);
96
97     virtual bool
98     WriteAllRegisterValues (const lldb_private::RegisterCheckpoint &reg_checkpoint);
99
100     virtual uint32_t
101     ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);
102
103 protected:
104     friend class ThreadGDBRemote;
105
106     bool
107     ReadRegisterBytes (const lldb_private::RegisterInfo *reg_info,
108                        lldb_private::DataExtractor &data);
109
110     bool
111     WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info,
112                         lldb_private::DataExtractor &data, 
113                         uint32_t data_offset);
114
115     bool
116     PrivateSetRegisterValue (uint32_t reg, StringExtractor &response);
117     
118     void
119     SetAllRegisterValid (bool b);
120
121     bool
122     GetRegisterIsValid (uint32_t reg) const
123     {
124 #if defined (LLDB_CONFIGURATION_DEBUG)
125         assert (reg < m_reg_valid.size());
126 #endif
127         if (reg < m_reg_valid.size())
128             return m_reg_valid[reg];
129         return false;
130     }
131
132     void
133     SetRegisterIsValid (const lldb_private::RegisterInfo *reg_info, bool valid)
134     {
135         if (reg_info)
136             return SetRegisterIsValid (reg_info->kinds[lldb::eRegisterKindLLDB], valid);
137     }
138
139     void
140     SetRegisterIsValid (uint32_t reg, bool valid)
141     {
142 #if defined (LLDB_CONFIGURATION_DEBUG)
143         assert (reg < m_reg_valid.size());
144 #endif
145         if (reg < m_reg_valid.size())
146             m_reg_valid[reg] = valid;
147     }
148
149     void
150     SyncThreadState(lldb_private::Process *process);  // Assumes the sequence mutex has already been acquired.
151     
152     GDBRemoteDynamicRegisterInfo &m_reg_info;
153     std::vector<bool> m_reg_valid;
154     lldb_private::DataExtractor m_reg_data;
155     bool m_read_all_at_once;
156
157 private:
158     // Helper function for ReadRegisterBytes().
159     bool GetPrimordialRegister(const lldb_private::RegisterInfo *reg_info,
160                                GDBRemoteCommunicationClient &gdb_comm);
161     // Helper function for WriteRegisterBytes().
162     bool SetPrimordialRegister(const lldb_private::RegisterInfo *reg_info,
163                                GDBRemoteCommunicationClient &gdb_comm);
164
165     //------------------------------------------------------------------
166     // For GDBRemoteRegisterContext only
167     //------------------------------------------------------------------
168     DISALLOW_COPY_AND_ASSIGN (GDBRemoteRegisterContext);
169 };
170
171 #endif  // lldb_GDBRemoteRegisterContext_h_