diff options
author | Tamas Berghammer <tberghammer@google.com> | 2015-05-26 11:58:52 +0000 |
---|---|---|
committer | Tamas Berghammer <tberghammer@google.com> | 2015-05-26 11:58:52 +0000 |
commit | 068f8a7e2d7ece12cc00726bb2e6df180b217848 (patch) | |
tree | 3ac16e6c32a2a44799ad79fa0f141f30c990c66a /lldb/source/Plugins/Process/Linux/NativeProcessLinux.h | |
parent | b2b901c607ae3149b6d3a0c53a45f22e3542fb04 (diff) | |
download | bcm5719-llvm-068f8a7e2d7ece12cc00726bb2e6df180b217848.tar.gz bcm5719-llvm-068f8a7e2d7ece12cc00726bb2e6df180b217848.zip |
Move register reading form NativeProcessLinux to NativeRegisterContextLinux*
This change reorganize the register read/write code inside lldb-server on Linux
with moving the architecture independent code into a new class called
NativeRegisterContextLinux and all of the architecture dependent code into the
appropriate NativeRegisterContextLinux_* class. As part of it the compilation of
the architecture specific register contexts are only compiled on the specific
architecture because they can't be used in other cases.
The purpose of this change is to remove a lot of duplicated code from the different
register contexts and to remove the architecture dependent codes from the global
NativeProcessLinux class.
Differential revision: http://reviews.llvm.org/D9935
llvm-svn: 238196
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/NativeProcessLinux.h')
-rw-r--r-- | lldb/source/Plugins/Process/Linux/NativeProcessLinux.h | 89 |
1 files changed, 38 insertions, 51 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h index 57c598ff770..8e9c28da338 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.h @@ -60,6 +60,37 @@ namespace process_linux { NativeProcessProtocol::NativeDelegate &native_delegate, NativeProcessProtocolSP &native_process_sp); + //------------------------------------------------------------------------------ + /// @class Operation + /// @brief Represents a NativeProcessLinux operation. + /// + /// Under Linux, it is not possible to ptrace() from any other thread but the + /// one that spawned or attached to the process from the start. Therefore, when + /// a NativeProcessLinux is asked to deliver or change the state of an inferior + /// process the operation must be "funneled" to a specific thread to perform the + /// task. The Operation class provides an abstract base for all services the + /// NativeProcessLinux must perform via the single virtual function Execute, thus + /// encapsulating the code that needs to run in the privileged context. + class Operation + { + public: + Operation () : m_error() { } + + virtual + ~Operation() {} + + virtual void + Execute (NativeProcessLinux *process) = 0; + + const Error & + GetError () const { return m_error; } + + protected: + Error m_error; + }; + + typedef std::unique_ptr<Operation> OperationUP; + // --------------------------------------------------------------------- // NativeProcessProtocol Interface // --------------------------------------------------------------------- @@ -123,64 +154,20 @@ namespace process_linux { void Terminate () override; + Error + GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) override; + // --------------------------------------------------------------------- // Interface used by NativeRegisterContext-derived classes. // --------------------------------------------------------------------- - - /// Reads the contents from the register identified by the given (architecture - /// dependent) offset. - /// - /// This method is provided for use by RegisterContextLinux derivatives. - Error - ReadRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, - unsigned size, RegisterValue &value); - - /// Writes the given value to the register identified by the given - /// (architecture dependent) offset. - /// - /// This method is provided for use by RegisterContextLinux derivatives. Error - WriteRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, - const RegisterValue &value); + DoOperation(Operation* op); - /// Reads all general purpose registers into the specified buffer. Error - ReadGPR(lldb::tid_t tid, void *buf, size_t buf_size); + DoOperation(OperationUP op) { return DoOperation(op.get()); } - /// Reads generic floating point registers into the specified buffer. - Error - ReadFPR(lldb::tid_t tid, void *buf, size_t buf_size); - - /// Reads hardware breakpoints and watchpoints capability information. - Error - ReadHardwareDebugInfo (lldb::tid_t tid, unsigned int &watch_count , - unsigned int &break_count); - - /// Write hardware breakpoint/watchpoint control and address registers. - Error - WriteHardwareDebugRegs (lldb::tid_t tid, lldb::addr_t *addr_buf, - uint32_t *cntrl_buf, int type, int count); - - /// Reads the specified register set into the specified buffer. - /// For instance, the extended floating-point register set. - Error - ReadRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); - - /// Writes all general purpose registers into the specified buffer. - Error - WriteGPR(lldb::tid_t tid, void *buf, size_t buf_size); - - /// Writes generic floating point registers into the specified buffer. - Error - WriteFPR(lldb::tid_t tid, void *buf, size_t buf_size); - - /// Writes the specified register set into the specified buffer. - /// For instance, the extended floating-point register set. - Error - WriteRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); - - Error - GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) override; + static long + PtraceWrapper(int req, lldb::pid_t pid, void *addr, void *data, size_t data_size, Error& error); protected: // --------------------------------------------------------------------- |