1 //===-- GDBRemoteRegisterContext.h ------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_GDBRemoteRegisterContext_h_
11 #define lldb_GDBRemoteRegisterContext_h_
17 // Other libraries and framework 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"
26 #include "GDBRemoteCommunicationClient.h"
28 class ThreadGDBRemote;
29 class ProcessGDBRemote;
30 class StringExtractor;
32 class GDBRemoteDynamicRegisterInfo :
33 public DynamicRegisterInfo
36 GDBRemoteDynamicRegisterInfo () :
41 ~GDBRemoteDynamicRegisterInfo ()
46 HardcodeARMRegisters(bool from_scratch);
50 class GDBRemoteRegisterContext : public lldb_private::RegisterContext
53 //------------------------------------------------------------------
54 // Constructors and Destructors
55 //------------------------------------------------------------------
56 GDBRemoteRegisterContext (ThreadGDBRemote &thread,
57 uint32_t concrete_frame_idx,
58 GDBRemoteDynamicRegisterInfo ®_info,
59 bool read_all_at_once);
62 ~GDBRemoteRegisterContext ();
64 //------------------------------------------------------------------
65 // Subclasses must override these functions
66 //------------------------------------------------------------------
68 InvalidateAllRegisters ();
73 virtual const lldb_private::RegisterInfo *
74 GetRegisterInfoAtIndex (size_t reg);
77 GetRegisterSetCount ();
79 virtual const lldb_private::RegisterSet *
80 GetRegisterSet (size_t reg_set);
83 ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
86 WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
89 ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
92 WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
95 ReadAllRegisterValues (lldb_private::RegisterCheckpoint ®_checkpoint);
98 WriteAllRegisterValues (const lldb_private::RegisterCheckpoint ®_checkpoint);
101 ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);
104 friend class ThreadGDBRemote;
107 ReadRegisterBytes (const lldb_private::RegisterInfo *reg_info,
108 lldb_private::DataExtractor &data);
111 WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info,
112 lldb_private::DataExtractor &data,
113 uint32_t data_offset);
116 PrivateSetRegisterValue (uint32_t reg, StringExtractor &response);
119 SetAllRegisterValid (bool b);
122 GetRegisterIsValid (uint32_t reg) const
124 #if defined (LLDB_CONFIGURATION_DEBUG)
125 assert (reg < m_reg_valid.size());
127 if (reg < m_reg_valid.size())
128 return m_reg_valid[reg];
133 SetRegisterIsValid (const lldb_private::RegisterInfo *reg_info, bool valid)
136 return SetRegisterIsValid (reg_info->kinds[lldb::eRegisterKindLLDB], valid);
140 SetRegisterIsValid (uint32_t reg, bool valid)
142 #if defined (LLDB_CONFIGURATION_DEBUG)
143 assert (reg < m_reg_valid.size());
145 if (reg < m_reg_valid.size())
146 m_reg_valid[reg] = valid;
150 SyncThreadState(lldb_private::Process *process); // Assumes the sequence mutex has already been acquired.
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;
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);
165 //------------------------------------------------------------------
166 // For GDBRemoteRegisterContext only
167 //------------------------------------------------------------------
168 DISALLOW_COPY_AND_ASSIGN (GDBRemoteRegisterContext);
171 #endif // lldb_GDBRemoteRegisterContext_h_