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 {
23 public:
24     NativeRegisterContextLinux(NativeThreadProtocol &native_thread,
25                                uint32_t concrete_frame_idx,
26                                RegisterInfoInterface *reg_info_interface_p);
27 
28     // This function is implemented in the NativeRegisterContextLinux_* subclasses to create a new
29     // instance of the host specific NativeRegisterContextLinux. The implementations can't collide
30     // as only one NativeRegisterContextLinux_* variant should be compiled into the final
31     // executable.
32     static NativeRegisterContextLinux*
33     CreateHostNativeRegisterContextLinux(const ArchSpec& target_arch,
34                                          NativeThreadProtocol &native_thread,
35                                          uint32_t concrete_frame_idx);
36 
37 protected:
38     lldb::ByteOrder
39     GetByteOrder() const;
40 
41     virtual Error
42     ReadRegisterRaw(uint32_t reg_index, RegisterValue& reg_value);
43 
44     virtual Error
45     WriteRegisterRaw(uint32_t reg_index, const RegisterValue& reg_value);
46 
47     virtual Error
48     ReadRegisterSet(void *buf, size_t buf_size, unsigned int regset);
49 
50     virtual Error
51     WriteRegisterSet(void *buf, size_t buf_size, unsigned int regset);
52 
53     virtual Error
54     ReadGPR();
55 
56     virtual Error
57     WriteGPR();
58 
59     virtual Error
60     ReadFPR();
61 
62     virtual Error
63     WriteFPR();
64 
65     virtual void*
66     GetGPRBuffer() { return nullptr; };
67 
68     virtual size_t
69     GetGPRSize() { return GetRegisterInfoInterface().GetGPRSize(); }
70 
71     virtual void*
72     GetFPRBuffer() { return nullptr; }
73 
74     virtual size_t
75     GetFPRSize() { return 0; }
76 
77     virtual NativeProcessLinux::OperationUP
78     GetReadRegisterValueOperation(uint32_t offset,
79                                   const char* reg_name,
80                                   uint32_t size,
81                                   RegisterValue &value);
82 
83     virtual NativeProcessLinux::OperationUP
84     GetWriteRegisterValueOperation(uint32_t offset,
85                                    const char* reg_name,
86                                    const RegisterValue &value);
87 
88     virtual NativeProcessLinux::OperationUP
89     GetReadGPROperation(void *buf, size_t buf_size);
90 
91     virtual NativeProcessLinux::OperationUP
92     GetWriteGPROperation(void *buf, size_t buf_size);
93 
94     virtual NativeProcessLinux::OperationUP
95     GetReadFPROperation(void *buf, size_t buf_size);
96 
97     virtual NativeProcessLinux::OperationUP
98     GetWriteFPROperation(void *buf, size_t buf_size);
99 };
100 
101 } // namespace process_linux
102 } // namespace lldb_private
103 
104 #endif // #ifndef lldb_NativeRegisterContextLinux_h
105 
106