LLDB mainline
HostThreadWindows.cpp
Go to the documentation of this file.
1//===-- HostThreadWindows.cpp ---------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
13
14#include "llvm/ADT/STLExtras.h"
15
16using namespace lldb;
17using namespace lldb_private;
18
19static void __stdcall ExitThreadProxy(ULONG_PTR dwExitCode) {
20 ::ExitThread(dwExitCode);
21}
22
24 : HostNativeThreadBase(), m_owns_handle(true) {}
25
27 : HostNativeThreadBase(thread), m_owns_handle(true) {}
28
30
32
35 if (IsJoinable()) {
36 DWORD wait_result = ::WaitForSingleObject(m_thread, INFINITE);
37 if (WAIT_OBJECT_0 == wait_result && result) {
38 DWORD exit_code = 0;
39 if (!::GetExitCodeThread(m_thread, &exit_code))
40 *result = 0;
41 *result = exit_code;
42 } else if (WAIT_OBJECT_0 != wait_result)
43 error.SetError(::GetLastError(), eErrorTypeWin32);
44 } else
45 error.SetError(ERROR_INVALID_HANDLE, eErrorTypeWin32);
46
47 Reset();
48 return error;
49}
50
53
54 DWORD result = ::QueueUserAPC(::ExitThreadProxy, m_thread, 0);
55 error.SetError(result, eErrorTypeWin32);
56 return error;
57}
58
60 return ::GetThreadId(m_thread);
61}
62
65 ::CloseHandle(m_thread);
66
68}
69
71 return GetThreadId() == ::GetThreadId(thread);
72}
static llvm::raw_ostream & error(Stream &strm)
static void __stdcall ExitThreadProxy(ULONG_PTR dwExitCode)
Status Join(lldb::thread_result_t *result) override
bool EqualsThread(lldb::thread_t thread) const override
An error handling class.
Definition: Status.h:44
#define LLDB_INVALID_HOST_THREAD
Definition: lldb-types.h:69
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
void * thread_result_t
Definition: lldb-types.h:62
@ eErrorTypeWin32
Standard Win32 error codes.
pthread_t thread_t
Definition: lldb-types.h:58
uint64_t tid_t
Definition: lldb-types.h:82