1 //===-- NativeRegisterContextLinux.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_NativeRegisterContextLinux_h
11 #define lldb_NativeRegisterContextLinux_h
12 
13 #include "lldb/Host/common/NativeRegisterContextRegisterInfo.h"
14 #include "lldb/Host/common/NativeThreadProtocol.h"
15 
16 #include "Plugins/Process/Linux/NativeProcessLinux.h"
17 
18 namespace lldb_private {
19 namespace process_linux {
20 
21 class NativeRegisterContextLinux : public NativeRegisterContextRegisterInfo {
22 public:
23   NativeRegisterContextLinux(NativeThreadProtocol &native_thread,
24                              uint32_t concrete_frame_idx,
25                              RegisterInfoInterface *reg_info_interface_p);
26 
27   // This function is implemented in the NativeRegisterContextLinux_* subclasses
28   // to create a new
29   // instance of the host specific NativeRegisterContextLinux. The
30   // implementations can't collide
31   // as only one NativeRegisterContextLinux_* variant should be compiled into
32   // the final
33   // executable.
34   static NativeRegisterContextLinux *
35   CreateHostNativeRegisterContextLinux(const ArchSpec &target_arch,
36                                        NativeThreadProtocol &native_thread,
37                                        uint32_t concrete_frame_idx);
38 
39 protected:
40   lldb::ByteOrder GetByteOrder() const;
41 
42   virtual Error ReadRegisterRaw(uint32_t reg_index, RegisterValue &reg_value);
43 
44   virtual Error WriteRegisterRaw(uint32_t reg_index,
45                                  const RegisterValue &reg_value);
46 
47   virtual Error ReadRegisterSet(void *buf, size_t buf_size,
48                                 unsigned int regset);
49 
50   virtual Error WriteRegisterSet(void *buf, size_t buf_size,
51                                  unsigned int regset);
52 
53   virtual Error ReadGPR();
54 
55   virtual Error WriteGPR();
56 
57   virtual Error ReadFPR();
58 
59   virtual Error WriteFPR();
60 
61   virtual void *GetGPRBuffer() { return nullptr; }
62 
63   virtual size_t GetGPRSize() {
64     return GetRegisterInfoInterface().GetGPRSize();
65   }
66 
67   virtual void *GetFPRBuffer() { return nullptr; }
68 
69   virtual size_t GetFPRSize() { return 0; }
70 
71   // The Do*** functions are executed on the privileged thread and can perform
72   // ptrace
73   // operations directly.
74   virtual Error DoReadRegisterValue(uint32_t offset, const char *reg_name,
75                                     uint32_t size, RegisterValue &value);
76 
77   virtual Error DoWriteRegisterValue(uint32_t offset, const char *reg_name,
78                                      const RegisterValue &value);
79 
80   virtual Error DoReadGPR(void *buf, size_t buf_size);
81 
82   virtual Error DoWriteGPR(void *buf, size_t buf_size);
83 
84   virtual Error DoReadFPR(void *buf, size_t buf_size);
85 
86   virtual Error DoWriteFPR(void *buf, size_t buf_size);
87 };
88 
89 } // namespace process_linux
90 } // namespace lldb_private
91 
92 #endif // #ifndef lldb_NativeRegisterContextLinux_h
93