summaryrefslogtreecommitdiff
path: root/include/lldb/Host/common/NativeProcessProtocol.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lldb/Host/common/NativeProcessProtocol.h')
-rw-r--r--include/lldb/Host/common/NativeProcessProtocol.h123
1 files changed, 57 insertions, 66 deletions
diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h
index a97540499cd35..5f2157510c0ac 100644
--- a/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/include/lldb/Host/common/NativeProcessProtocol.h
@@ -19,6 +19,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"
#include <vector>
@@ -244,68 +245,57 @@ public:
virtual Status GetFileLoadAddress(const llvm::StringRef &file_name,
lldb::addr_t &load_addr) = 0;
- //------------------------------------------------------------------
- /// Launch a process for debugging. This method will create an concrete
- /// instance of NativeProcessProtocol, based on the host platform.
- /// (e.g. NativeProcessLinux on linux, etc.)
- ///
- /// @param[in] launch_info
- /// Information required to launch the process.
- ///
- /// @param[in] native_delegate
- /// The delegate that will receive messages regarding the
- /// inferior. Must outlive the NativeProcessProtocol
- /// instance.
- ///
- /// @param[in] mainloop
- /// The mainloop instance with which the process can register
- /// callbacks. Must outlive the NativeProcessProtocol
- /// instance.
- ///
- /// @param[out] process_sp
- /// On successful return from the method, this parameter
- /// contains the shared pointer to the
- /// NativeProcessProtocol that can be used to manipulate
- /// the native process.
- ///
- /// @return
- /// An error object indicating if the operation succeeded,
- /// and if not, what error occurred.
- //------------------------------------------------------------------
- static Status Launch(ProcessLaunchInfo &launch_info,
- NativeDelegate &native_delegate, MainLoop &mainloop,
- NativeProcessProtocolSP &process_sp);
-
- //------------------------------------------------------------------
- /// Attach to an existing process. This method will create an concrete
- /// instance of NativeProcessProtocol, based on the host platform.
- /// (e.g. NativeProcessLinux on linux, etc.)
- ///
- /// @param[in] pid
- /// pid of the process locatable
- ///
- /// @param[in] native_delegate
- /// The delegate that will receive messages regarding the
- /// inferior. Must outlive the NativeProcessProtocol
- /// instance.
- ///
- /// @param[in] mainloop
- /// The mainloop instance with which the process can register
- /// callbacks. Must outlive the NativeProcessProtocol
- /// instance.
- ///
- /// @param[out] process_sp
- /// On successful return from the method, this parameter
- /// contains the shared pointer to the
- /// NativeProcessProtocol that can be used to manipulate
- /// the native process.
- ///
- /// @return
- /// An error object indicating if the operation succeeded,
- /// and if not, what error occurred.
- //------------------------------------------------------------------
- static Status Attach(lldb::pid_t pid, NativeDelegate &native_delegate,
- MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
+ class Factory {
+ public:
+ virtual ~Factory();
+ //------------------------------------------------------------------
+ /// Launch a process for debugging.
+ ///
+ /// @param[in] launch_info
+ /// Information required to launch the process.
+ ///
+ /// @param[in] native_delegate
+ /// The delegate that will receive messages regarding the
+ /// inferior. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
+ /// @param[in] mainloop
+ /// The mainloop instance with which the process can register
+ /// callbacks. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
+ /// @return
+ /// A NativeProcessProtocol shared pointer if the operation succeeded or
+ /// an error object if it failed.
+ //------------------------------------------------------------------
+ virtual llvm::Expected<NativeProcessProtocolSP>
+ Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate,
+ MainLoop &mainloop) const = 0;
+
+ //------------------------------------------------------------------
+ /// Attach to an existing process.
+ ///
+ /// @param[in] pid
+ /// pid of the process locatable
+ ///
+ /// @param[in] native_delegate
+ /// The delegate that will receive messages regarding the
+ /// inferior. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
+ /// @param[in] mainloop
+ /// The mainloop instance with which the process can register
+ /// callbacks. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
+ /// @return
+ /// A NativeProcessProtocol shared pointer if the operation succeeded or
+ /// an error object if it failed.
+ //------------------------------------------------------------------
+ virtual llvm::Expected<NativeProcessProtocolSP>
+ Attach(lldb::pid_t pid, NativeDelegate &native_delegate,
+ MainLoop &mainloop) const = 0;
+ };
//------------------------------------------------------------------
/// StartTracing API for starting a tracing instance with the
@@ -413,10 +403,10 @@ protected:
lldb::pid_t m_pid;
std::vector<NativeThreadProtocolSP> m_threads;
- lldb::tid_t m_current_thread_id;
+ lldb::tid_t m_current_thread_id = LLDB_INVALID_THREAD_ID;
mutable std::recursive_mutex m_threads_mutex;
- lldb::StateType m_state;
+ lldb::StateType m_state = lldb::eStateInvalid;
mutable std::recursive_mutex m_state_mutex;
llvm::Optional<WaitStatus> m_exit_status;
@@ -427,7 +417,7 @@ protected:
NativeWatchpointList m_watchpoint_list;
HardwareBreakpointMap m_hw_breakpoints_map;
int m_terminal_fd;
- uint32_t m_stop_id;
+ uint32_t m_stop_id = 0;
// Set of signal numbers that LLDB directly injects back to inferior
// without stopping it.
@@ -438,7 +428,8 @@ protected:
// then the process should be attached to. When attaching to a process
// lldb_private::Host calls should be used to locate the process to attach to,
// and then this function should be called.
- NativeProcessProtocol(lldb::pid_t pid);
+ NativeProcessProtocol(lldb::pid_t pid, int terminal_fd,
+ NativeDelegate &delegate);
// -----------------------------------------------------------
// Internal interface for state handling