diff options
Diffstat (limited to 'lldb/source/Core')
-rw-r--r-- | lldb/source/Core/Communication.cpp | 17 | ||||
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 27 |
2 files changed, 37 insertions, 7 deletions
diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp index c39976d6556..a67cb925d64 100644 --- a/lldb/source/Core/Communication.cpp +++ b/lldb/source/Core/Communication.cpp @@ -204,10 +204,23 @@ bool Communication::StartReadThread(Status *error_ptr) { m_read_thread_enabled = true; m_read_thread_did_exit = false; - m_read_thread = ThreadLauncher::LaunchThread( - thread_name, Communication::ReadThread, this, error_ptr); + auto maybe_thread = ThreadLauncher::LaunchThread( + thread_name, Communication::ReadThread, this); + if (maybe_thread) { + m_read_thread = *maybe_thread; + } else { + if (error_ptr) + *error_ptr = Status(maybe_thread.takeError()); + else { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(maybe_thread.takeError())); + } + } + if (!m_read_thread.IsJoinable()) m_read_thread_enabled = false; + return m_read_thread_enabled; } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index f22fe043b8d..1a69fc582d0 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1642,8 +1642,17 @@ bool Debugger::StartEventHandlerThread() { full_name.AsCString() : "dbg.evt-handler"; // Use larger 8MB stack for this thread - m_event_handler_thread = ThreadLauncher::LaunchThread(thread_name, - EventHandlerThread, this, nullptr, g_debugger_event_thread_stack_bytes); + llvm::Expected<HostThread> event_handler_thread = + ThreadLauncher::LaunchThread(thread_name, EventHandlerThread, this, + g_debugger_event_thread_stack_bytes); + + if (event_handler_thread) { + m_event_handler_thread = *event_handler_thread; + } else { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(event_handler_thread.takeError())); + } // Make sure DefaultEventHandler() is running and listening to events // before we return from this function. We are only listening for events of @@ -1674,10 +1683,18 @@ lldb::thread_result_t Debugger::IOHandlerThread(lldb::thread_arg_t arg) { bool Debugger::HasIOHandlerThread() { return m_io_handler_thread.IsJoinable(); } bool Debugger::StartIOHandlerThread() { - if (!m_io_handler_thread.IsJoinable()) - m_io_handler_thread = ThreadLauncher::LaunchThread( - "lldb.debugger.io-handler", IOHandlerThread, this, nullptr, + if (!m_io_handler_thread.IsJoinable()) { + llvm::Expected<HostThread> io_handler_thread = ThreadLauncher::LaunchThread( + "lldb.debugger.io-handler", IOHandlerThread, this, 8 * 1024 * 1024); // Use larger 8MB stack for this thread + if (io_handler_thread) { + m_io_handler_thread = *io_handler_thread; + } else { + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST), + "failed to launch host thread: {}", + llvm::toString(io_handler_thread.takeError())); + } + } return m_io_handler_thread.IsJoinable(); } |