[Lldb-commits] [PATCH] D53357: [Windows] Fix threads comparison on Windows
Aleksandr Urakov via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 17 01:42:44 PDT 2018
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: zturner, clayborg.
aleksandr.urakov added a project: LLDB.
Herald added a subscriber: lldb-commits.
This patch makes Windows threads to compare by a thread ID, not by a handle. It's because the same thread can have different handles on Windows (for example, `GetCurrentThread` always returns the fake handle `-2`). This leads to some incorrect behavior. For example, in `Process::GetRunLock` always `m_public_run_lock` is returned without this patch.
Repository:
rLLDB LLDB
https://reviews.llvm.org/D53357
Files:
include/lldb/Host/HostNativeThreadBase.h
include/lldb/Host/windows/HostThreadWindows.h
source/Host/common/HostNativeThreadBase.cpp
source/Host/common/HostThread.cpp
source/Host/windows/HostThreadWindows.cpp
Index: source/Host/windows/HostThreadWindows.cpp
===================================================================
--- source/Host/windows/HostThreadWindows.cpp
+++ source/Host/windows/HostThreadWindows.cpp
@@ -69,3 +69,7 @@
HostNativeThreadBase::Reset();
}
+
+bool HostThreadWindows::EqualsThread(lldb::thread_t thread) const {
+ return GetThreadId() == ::GetThreadId(thread);
+}
Index: source/Host/common/HostThread.cpp
===================================================================
--- source/Host/common/HostThread.cpp
+++ source/Host/common/HostThread.cpp
@@ -43,5 +43,5 @@
}
bool HostThread::EqualsThread(lldb::thread_t thread) const {
- return m_native_thread->GetSystemHandle() == thread;
+ return m_native_thread->EqualsThread(thread);
}
Index: source/Host/common/HostNativeThreadBase.cpp
===================================================================
--- source/Host/common/HostNativeThreadBase.cpp
+++ source/Host/common/HostNativeThreadBase.cpp
@@ -41,6 +41,10 @@
m_result = 0;
}
+bool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const {
+ return m_thread == thread;
+}
+
lldb::thread_t HostNativeThreadBase::Release() {
lldb::thread_t result = m_thread;
m_thread = LLDB_INVALID_HOST_THREAD;
Index: include/lldb/Host/windows/HostThreadWindows.h
===================================================================
--- include/lldb/Host/windows/HostThreadWindows.h
+++ include/lldb/Host/windows/HostThreadWindows.h
@@ -29,6 +29,7 @@
virtual Status Join(lldb::thread_result_t *result);
virtual Status Cancel();
virtual void Reset();
+ virtual bool EqualsThread(lldb::thread_t thread) const;
lldb::tid_t GetThreadId() const;
Index: include/lldb/Host/HostNativeThreadBase.h
===================================================================
--- include/lldb/Host/HostNativeThreadBase.h
+++ include/lldb/Host/HostNativeThreadBase.h
@@ -35,6 +35,7 @@
virtual Status Cancel() = 0;
virtual bool IsJoinable() const;
virtual void Reset();
+ virtual bool EqualsThread(lldb::thread_t thread) const;
lldb::thread_t Release();
lldb::thread_t GetSystemHandle() const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53357.169966.patch
Type: text/x-patch
Size: 2154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20181017/fe66fc7b/attachment.bin>
More information about the lldb-commits
mailing list