diff options
-rw-r--r-- | lldb/include/lldb/Host/Host.h | 2 | ||||
-rw-r--r-- | lldb/include/lldb/Host/HostNativeProcessBase.h | 2 | ||||
-rw-r--r-- | lldb/include/lldb/Host/HostProcess.h | 5 | ||||
-rw-r--r-- | lldb/include/lldb/Host/posix/HostProcessPosix.h | 5 | ||||
-rw-r--r-- | lldb/source/Host/common/Host.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Host/common/HostProcess.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Host/common/MonitoringProcessLauncher.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Host/common/ProcessLaunchInfo.cpp | 5 | ||||
-rw-r--r-- | lldb/source/Host/posix/HostProcessPosix.cpp | 2 |
9 files changed, 23 insertions, 12 deletions
diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index 2cb3aafc1af..884c5cf6321 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -99,7 +99,7 @@ public: /// was spawned to monitor \a pid. /// /// \see static void Host::StopMonitoringChildProcess (uint32_t) - static HostThread + static llvm::Expected<HostThread> StartMonitoringChildProcess(const MonitorChildProcessCallback &callback, lldb::pid_t pid, bool monitor_signals); diff --git a/lldb/include/lldb/Host/HostNativeProcessBase.h b/lldb/include/lldb/Host/HostNativeProcessBase.h index e8b0683da8b..aaa517d5321 100644 --- a/lldb/include/lldb/Host/HostNativeProcessBase.h +++ b/lldb/include/lldb/Host/HostNativeProcessBase.h @@ -35,7 +35,7 @@ public: lldb::process_t GetSystemHandle() const { return m_process; } - virtual HostThread + virtual llvm::Expected<HostThread> StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals) = 0; diff --git a/lldb/include/lldb/Host/HostProcess.h b/lldb/include/lldb/Host/HostProcess.h index 56eaa465f07..d48ff1fc90e 100644 --- a/lldb/include/lldb/Host/HostProcess.h +++ b/lldb/include/lldb/Host/HostProcess.h @@ -43,8 +43,9 @@ public: lldb::pid_t GetProcessId() const; bool IsRunning() const; - HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback, - bool monitor_signals); + llvm::Expected<HostThread> + StartMonitoring(const Host::MonitorChildProcessCallback &callback, + bool monitor_signals); HostNativeProcessBase &GetNativeProcess(); const HostNativeProcessBase &GetNativeProcess() const; diff --git a/lldb/include/lldb/Host/posix/HostProcessPosix.h b/lldb/include/lldb/Host/posix/HostProcessPosix.h index ce0b8e8b176..a313358631b 100644 --- a/lldb/include/lldb/Host/posix/HostProcessPosix.h +++ b/lldb/include/lldb/Host/posix/HostProcessPosix.h @@ -32,8 +32,9 @@ public: lldb::pid_t GetProcessId() const override; bool IsRunning() const override; - HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback, - bool monitor_signals) override; + llvm::Expected<HostThread> + StartMonitoring(const Host::MonitorChildProcessCallback &callback, + bool monitor_signals) override; }; } // namespace lldb_private diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index be206406e93..3ba9ab7f21f 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -99,7 +99,7 @@ struct MonitorInfo { static thread_result_t MonitorChildProcessThreadFunction(void *arg); -HostThread Host::StartMonitoringChildProcess( +llvm::Expected<HostThread> Host::StartMonitoringChildProcess( const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid, bool monitor_signals) { MonitorInfo *info_ptr = new MonitorInfo(); @@ -112,7 +112,7 @@ HostThread Host::StartMonitoringChildProcess( ::snprintf(thread_name, sizeof(thread_name), "<lldb.host.wait4(pid=%" PRIu64 ")>", pid); return ThreadLauncher::LaunchThread( - thread_name, MonitorChildProcessThreadFunction, info_ptr, nullptr); + thread_name, MonitorChildProcessThreadFunction, info_ptr, 0); } #ifndef __linux__ diff --git a/lldb/source/Host/common/HostProcess.cpp b/lldb/source/Host/common/HostProcess.cpp index d8f71af5e65..e180687551f 100644 --- a/lldb/source/Host/common/HostProcess.cpp +++ b/lldb/source/Host/common/HostProcess.cpp @@ -32,7 +32,7 @@ lldb::pid_t HostProcess::GetProcessId() const { bool HostProcess::IsRunning() const { return m_native_process->IsRunning(); } -HostThread +llvm::Expected<HostThread> HostProcess::StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals) { return m_native_process->StartMonitoring(callback, monitor_signals); diff --git a/lldb/source/Host/common/MonitoringProcessLauncher.cpp b/lldb/source/Host/common/MonitoringProcessLauncher.cpp index 2ee69353e19..55e9f69a089 100644 --- a/lldb/source/Host/common/MonitoringProcessLauncher.cpp +++ b/lldb/source/Host/common/MonitoringProcessLauncher.cpp @@ -53,8 +53,12 @@ MonitoringProcessLauncher::LaunchProcess(const ProcessLaunchInfo &launch_info, Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); assert(launch_info.GetMonitorProcessCallback()); - process.StartMonitoring(launch_info.GetMonitorProcessCallback(), - launch_info.GetMonitorSignals()); + llvm::Expected<HostThread> maybe_thread = + process.StartMonitoring(launch_info.GetMonitorProcessCallback(), + launch_info.GetMonitorSignals()); + if (!maybe_thread) + error.SetErrorStringWithFormatv("failed to launch host thread: {}", + llvm::toString(maybe_thread.takeError())); if (log) log->PutCString("started monitoring child process."); } else { diff --git a/lldb/source/Host/common/ProcessLaunchInfo.cpp b/lldb/source/Host/common/ProcessLaunchInfo.cpp index ac8a41bf883..266b4676399 100644 --- a/lldb/source/Host/common/ProcessLaunchInfo.cpp +++ b/lldb/source/Host/common/ProcessLaunchInfo.cpp @@ -188,8 +188,13 @@ bool ProcessLaunchInfo::NoOpMonitorCallback(lldb::pid_t pid, bool exited, int si bool ProcessLaunchInfo::MonitorProcess() const { if (m_monitor_callback && ProcessIDIsValid()) { + llvm::Expected<HostThread> maybe_thread = Host::StartMonitoringChildProcess(m_monitor_callback, GetProcessID(), m_monitor_signals); + if (!maybe_thread) + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(maybe_thread.takeError())); return true; } return false; diff --git a/lldb/source/Host/posix/HostProcessPosix.cpp b/lldb/source/Host/posix/HostProcessPosix.cpp index 725f59d7512..cc187d44246 100644 --- a/lldb/source/Host/posix/HostProcessPosix.cpp +++ b/lldb/source/Host/posix/HostProcessPosix.cpp @@ -87,7 +87,7 @@ bool HostProcessPosix::IsRunning() const { return error.Success(); } -HostThread HostProcessPosix::StartMonitoring( +llvm::Expected<HostThread> HostProcessPosix::StartMonitoring( const Host::MonitorChildProcessCallback &callback, bool monitor_signals) { return Host::StartMonitoringChildProcess(callback, m_process, monitor_signals); |