summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Host')
-rw-r--r--lldb/source/Host/common/TaskPool.cpp14
-rw-r--r--lldb/source/Host/common/ThreadLauncher.cpp22
-rw-r--r--lldb/source/Host/macosx/objcxx/Host.mm9
3 files changed, 24 insertions, 21 deletions
diff --git a/lldb/source/Host/common/TaskPool.cpp b/lldb/source/Host/common/TaskPool.cpp
index dcc4363078d..73f761b5cf6 100644
--- a/lldb/source/Host/common/TaskPool.cpp
+++ b/lldb/source/Host/common/TaskPool.cpp
@@ -8,6 +8,7 @@
#include "lldb/Host/TaskPool.h"
#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Utility/Log.h"
#include <cstdint>
#include <queue>
@@ -65,9 +66,16 @@ void TaskPoolImpl::AddTask(std::function<void()> &&task_fn) {
// Note that this detach call needs to happen with the m_tasks_mutex held.
// This prevents the thread from exiting prematurely and triggering a linux
// libc bug (https://sourceware.org/bugzilla/show_bug.cgi?id=19951).
- lldb_private::ThreadLauncher::LaunchThread("task-pool.worker", WorkerPtr,
- this, nullptr, min_stack_size)
- .Release();
+ llvm::Expected<HostThread> host_thread =
+ lldb_private::ThreadLauncher::LaunchThread(
+ "task-pool.worker", WorkerPtr, this, min_stack_size);
+ if (host_thread) {
+ host_thread->Release();
+ } else {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "failed to launch host thread: {}",
+ llvm::toString(host_thread.takeError()));
+ }
}
}
diff --git a/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp
index 2eff981bfa8..912ce3688f2 100644
--- a/lldb/source/Host/common/ThreadLauncher.cpp
+++ b/lldb/source/Host/common/ThreadLauncher.cpp
@@ -20,15 +20,9 @@
using namespace lldb;
using namespace lldb_private;
-HostThread ThreadLauncher::LaunchThread(llvm::StringRef name,
- lldb::thread_func_t thread_function,
- lldb::thread_arg_t thread_arg,
- Status *error_ptr,
- size_t min_stack_byte_size) {
- Status error;
- if (error_ptr)
- error_ptr->Clear();
-
+llvm::Expected<HostThread> ThreadLauncher::LaunchThread(
+ llvm::StringRef name, lldb::thread_func_t thread_function,
+ lldb::thread_arg_t thread_arg, size_t min_stack_byte_size) {
// Host::ThreadCreateTrampoline will delete this pointer for us.
HostThreadCreateInfo *info_ptr =
new HostThreadCreateInfo(name.data(), thread_function, thread_arg);
@@ -38,7 +32,7 @@ HostThread ThreadLauncher::LaunchThread(llvm::StringRef name,
0, (unsigned)min_stack_byte_size,
HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL);
if (thread == (lldb::thread_t)(-1L))
- error.SetError(::GetLastError(), eErrorTypeWin32);
+ return llvm::errorCodeToError(::GetLastError());
#else
// ASAN instrumentation adds a lot of bookkeeping overhead on stack frames.
@@ -73,12 +67,10 @@ HostThread ThreadLauncher::LaunchThread(llvm::StringRef name,
if (destroy_attr)
::pthread_attr_destroy(&thread_attr);
- error.SetError(err, eErrorTypePOSIX);
+ if (err)
+ return llvm::errorCodeToError(
+ std::error_code(err, std::generic_category()));
#endif
- if (error_ptr)
- *error_ptr = error;
- if (!error.Success())
- thread = LLDB_INVALID_HOST_THREAD;
return HostThread(thread);
}
diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm
index 99b5601a9b3..da1ea666a0a 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -313,13 +313,16 @@ LaunchInNewTerminalWithAppleScript(const char *exe_path,
// in a shell and the shell will fork/exec a couple of times before we get
// to the process that we wanted to launch. So when our process actually
// gets launched, we will handshake with it and get the process ID for it.
- HostThread accept_thread = ThreadLauncher::LaunchThread(
- unix_socket_name, AcceptPIDFromInferior, connect_url, &lldb_error);
+ llvm::Expected<HostThread> accept_thread = ThreadLauncher::LaunchThread(
+ unix_socket_name, AcceptPIDFromInferior, connect_url);
+
+ if (!accept_thread)
+ return Status(accept_thread.takeError());
[applescript executeAndReturnError:nil];
thread_result_t accept_thread_result = NULL;
- lldb_error = accept_thread.Join(&accept_thread_result);
+ lldb_error = accept_thread->Join(&accept_thread_result);
if (lldb_error.Success() && accept_thread_result) {
pid = (intptr_t)accept_thread_result;
OpenPOWER on IntegriCloud