summaryrefslogtreecommitdiff
path: root/source/Host/common/ThreadLauncher.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:52 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:52 +0000
commit5f29bb8a675e8f96452b632e7129113f7dec850e (patch)
tree3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Host/common/ThreadLauncher.cpp
parent88c643b6fec27eec436c8d138fee6346e92337d6 (diff)
Notes
Diffstat (limited to 'source/Host/common/ThreadLauncher.cpp')
-rw-r--r--source/Host/common/ThreadLauncher.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/source/Host/common/ThreadLauncher.cpp b/source/Host/common/ThreadLauncher.cpp
index f3401016393f3..6e3c8b6a13a46 100644
--- a/source/Host/common/ThreadLauncher.cpp
+++ b/source/Host/common/ThreadLauncher.cpp
@@ -1,10 +1,8 @@
-//===-- ThreadLauncher.cpp ---------------------------------------*- C++
-//-*-===//
+//===-- ThreadLauncher.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,18 +16,14 @@
#include "lldb/Host/windows/windows.h"
#endif
+#include "llvm/Support/WindowsError.h"
+
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,8 +32,8 @@ HostThread ThreadLauncher::LaunchThread(llvm::StringRef name,
thread = (lldb::thread_t)::_beginthreadex(
0, (unsigned)min_stack_byte_size,
HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL);
- if (thread == (lldb::thread_t)(-1L))
- error.SetError(::GetLastError(), eErrorTypeWin32);
+ if (thread == LLDB_INVALID_HOST_THREAD)
+ return llvm::errorCodeToError(llvm::mapWindowsError(GetLastError()));
#else
// ASAN instrumentation adds a lot of bookkeeping overhead on stack frames.
@@ -50,7 +44,7 @@ HostThread ThreadLauncher::LaunchThread(llvm::StringRef name,
}
#endif
- pthread_attr_t *thread_attr_ptr = NULL;
+ pthread_attr_t *thread_attr_ptr = nullptr;
pthread_attr_t thread_attr;
bool destroy_attr = false;
if (min_stack_byte_size > 0) {
@@ -74,12 +68,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);
}