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