diff options
-rw-r--r-- | lldb/include/lldb/API/SBListener.h | 3 | ||||
-rw-r--r-- | lldb/include/lldb/API/SBTarget.h | 111 | ||||
-rw-r--r-- | lldb/source/API/SBListener.cpp | 5 | ||||
-rw-r--r-- | lldb/source/API/SBTarget.cpp | 21 |
4 files changed, 133 insertions, 7 deletions
diff --git a/lldb/include/lldb/API/SBListener.h b/lldb/include/lldb/API/SBListener.h index 7e12253de15..0c7ebe5d7fd 100644 --- a/lldb/include/lldb/API/SBListener.h +++ b/lldb/include/lldb/API/SBListener.h @@ -109,6 +109,9 @@ private: get() const; lldb_private::Listener & + ref() const; + + lldb_private::Listener & operator *(); const lldb_private::Listener & diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index b4a2fae1691..2ea5865077e 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -54,8 +54,60 @@ public: lldb::SBProcess GetProcess (); + //------------------------------------------------------------------ + /// Launch a new process. + /// + /// Launch a new process by spawning a new process using the + /// target object's executable module's file as the file to launch. + /// Arguments are given in \a argv, and the environment variables + /// are in \a envp. Standard input and output files can be + /// optionally re-directed to \a stdin_path, \a stdout_path, and + /// \a stderr_path. + /// + /// @param[in] listener + /// An optional listener that will receive all process events. + /// If \a listener is valid then \a listener will listen to all + /// process events. If not valid, then this target's debugger + /// (SBTarget::GetDebugger()) will listen to all process events. + /// + /// @param[in] argv + /// The argument array. + /// + /// @param[in] envp + /// The environment array. + /// + /// @param[in] launch_flags + /// Flags to modify the launch (@see lldb::LaunchFlags) + /// + /// @param[in] stdin_path + /// The path to use when re-directing the STDIN of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] stdout_path + /// The path to use when re-directing the STDOUT of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] stderr_path + /// The path to use when re-directing the STDERR of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] working_directory + /// The working directory to have the child process run in + /// + /// @param[in] launch_flags + /// Some launch options specified by logical OR'ing + /// lldb::LaunchFlags enumeration values together. + /// + /// @return + /// An error object. Call GetID() to get the process ID if + /// the error object is success. + //------------------------------------------------------------------ lldb::SBProcess - Launch (char const **argv, + Launch (SBListener &listener, + char const **argv, char const **envp, const char *stdin_path, const char *stdout_path, @@ -65,12 +117,65 @@ public: bool stop_at_entry, lldb::SBError& error); + //------------------------------------------------------------------ + /// Launch a new process. + /// + /// Launch a new process by spawning a new process using the + /// target object's executable module's file as the file to launch. + /// Arguments are given in \a argv, and the environment variables + /// are in \a envp. Standard input and output files can be + /// optionally re-directed to \a stdin_path, \a stdout_path, and + /// \a stderr_path. + /// + /// @param[in] listener + /// An optional listener that will receive all process events. + /// If NULL, then the this target's debugger (SBTarget::GetDebugger()) + /// will listen to all process events. If non-NULL, \a listener + /// will listen to all process events. + /// + /// @param[in] argv + /// The argument array. + /// + /// @param[in] envp + /// The environment array. + /// + /// @param[in] launch_flags + /// Flags to modify the launch (@see lldb::LaunchFlags) + /// + /// @param[in] stdin_path + /// The path to use when re-directing the STDIN of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] stdout_path + /// The path to use when re-directing the STDOUT of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] stderr_path + /// The path to use when re-directing the STDERR of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] working_directory + /// The working directory to have the child process run in + /// + /// @param[in] launch_flags + /// Some launch options specified by logical OR'ing + /// lldb::LaunchFlags enumeration values together. + /// + /// @return + /// An error object. Call GetID() to get the process ID if + /// the error object is success. + //------------------------------------------------------------------ lldb::SBProcess - AttachToProcessWithID (lldb::pid_t pid, // The process ID to attach to + AttachToProcessWithID (SBListener &listener, + lldb::pid_t pid, // The process ID to attach to lldb::SBError& error); // An error explaining what went wrong if attach fails lldb::SBProcess - AttachToProcessWithName (const char *name, // basename of process to attach to + AttachToProcessWithName (SBListener &listener, + const char *name, // basename of process to attach to bool wait_for, // if true wait for a new instance of "name" to be launched lldb::SBError& error); // An error explaining what went wrong if attach fails diff --git a/lldb/source/API/SBListener.cpp b/lldb/source/API/SBListener.cpp index eb8a651a2e2..f9816347d11 100644 --- a/lldb/source/API/SBListener.cpp +++ b/lldb/source/API/SBListener.cpp @@ -386,6 +386,11 @@ SBListener::reset(Listener *listener, bool owns) m_opaque_ptr = listener; } +Listener & +SBListener::ref() const +{ + return *m_opaque_ptr; +} Listener & SBListener::operator *() diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 74bf423c1db..371d84f8061 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -121,6 +121,7 @@ SBTarget::GetDebugger () const SBProcess SBTarget::Launch ( + SBListener &listener, char const **argv, char const **envp, const char *stdin_path, @@ -218,7 +219,7 @@ SBTarget::Launch if (pid != LLDB_INVALID_PROCESS_ID) { - sb_process = AttachToProcessWithID(pid, error); + sb_process = AttachToProcessWithID(listener, pid, error); } else { @@ -237,7 +238,10 @@ SBTarget::Launch } else { - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + if (listener.IsValid()) + sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref())); + else + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); if (sb_process.IsValid()) { @@ -294,6 +298,7 @@ SBTarget::Launch lldb::SBProcess SBTarget::AttachToProcessWithID ( + SBListener &listener, lldb::pid_t pid,// The process ID to attach to SBError& error // An error explaining what went wrong if attach fails ) @@ -302,7 +307,11 @@ SBTarget::AttachToProcessWithID if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + if (listener.IsValid()) + sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref())); + else + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + if (sb_process.IsValid()) { @@ -324,6 +333,7 @@ SBTarget::AttachToProcessWithID lldb::SBProcess SBTarget::AttachToProcessWithName ( + SBListener &listener, const char *name, // basename of process to attach to bool wait_for, // if true wait for a new instance of "name" to be launched SBError& error // An error explaining what went wrong if attach fails @@ -334,7 +344,10 @@ SBTarget::AttachToProcessWithName { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + if (listener.IsValid()) + sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref())); + else + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); if (sb_process.IsValid()) { |