teemperor created this revision.
teemperor added a reviewer: LLDB.
Herald added a subscriber: krytarowski.
teemperor requested review of this revision.

Follow up patch for D104231 <https://reviews.llvm.org/D104231> which deprecates 
this in the SB API.

This removes the threading functionality that just exists for the sake of 
implementing the SBHostOS threading framework.


https://reviews.llvm.org/D104307

Files:
  lldb/include/lldb/Host/HostNativeThreadBase.h
  lldb/include/lldb/Host/HostThread.h
  lldb/include/lldb/Host/posix/HostThreadPosix.h
  lldb/include/lldb/Host/windows/HostThreadWindows.h
  lldb/source/API/SBHostOS.cpp
  lldb/source/Host/common/HostThread.cpp
  lldb/source/Host/posix/HostThreadPosix.cpp
  lldb/source/Host/windows/HostThreadWindows.cpp

Index: lldb/source/Host/windows/HostThreadWindows.cpp
===================================================================
--- lldb/source/Host/windows/HostThreadWindows.cpp
+++ lldb/source/Host/windows/HostThreadWindows.cpp
@@ -50,14 +50,6 @@
   return error;
 }
 
-Status HostThreadWindows::Cancel() {
-  Status error;
-
-  DWORD result = ::QueueUserAPC(::ExitThreadProxy, m_thread, 0);
-  error.SetError(result, eErrorTypeWin32);
-  return error;
-}
-
 lldb::tid_t HostThreadWindows::GetThreadId() const {
   return ::GetThreadId(m_thread);
 }
Index: lldb/source/Host/posix/HostThreadPosix.cpp
===================================================================
--- lldb/source/Host/posix/HostThreadPosix.cpp
+++ lldb/source/Host/posix/HostThreadPosix.cpp
@@ -36,26 +36,3 @@
   Reset();
   return error;
 }
-
-Status HostThreadPosix::Cancel() {
-  Status error;
-  if (IsJoinable()) {
-#ifndef __FreeBSD__
-    llvm_unreachable("someone is calling HostThread::Cancel()");
-#else
-    int err = ::pthread_cancel(m_thread);
-    error.SetError(err, eErrorTypePOSIX);
-#endif
-  }
-  return error;
-}
-
-Status HostThreadPosix::Detach() {
-  Status error;
-  if (IsJoinable()) {
-    int err = ::pthread_detach(m_thread);
-    error.SetError(err, eErrorTypePOSIX);
-  }
-  Reset();
-  return error;
-}
Index: lldb/source/Host/common/HostThread.cpp
===================================================================
--- lldb/source/Host/common/HostThread.cpp
+++ lldb/source/Host/common/HostThread.cpp
@@ -21,8 +21,6 @@
   return m_native_thread->Join(result);
 }
 
-Status HostThread::Cancel() { return m_native_thread->Cancel(); }
-
 void HostThread::Reset() { return m_native_thread->Reset(); }
 
 lldb::thread_t HostThread::Release() { return m_native_thread->Release(); }
Index: lldb/source/API/SBHostOS.cpp
===================================================================
--- lldb/source/API/SBHostOS.cpp
+++ lldb/source/API/SBHostOS.cpp
@@ -104,20 +104,10 @@
 lldb::thread_t SBHostOS::ThreadCreate(const char *name,
                                       lldb::thread_func_t thread_function,
                                       void *thread_arg, SBError *error_ptr) {
-  LLDB_RECORD_DUMMY(lldb::thread_t, SBHostOS, ThreadCreate,
-                    (lldb::thread_func_t, void *, SBError *), name,
-                    thread_function, thread_arg, error_ptr);
-  llvm::Expected<HostThread> thread =
-      ThreadLauncher::LaunchThread(name, thread_function, thread_arg);
-  if (!thread) {
-    if (error_ptr)
-      error_ptr->SetError(Status(thread.takeError()));
-    else
-      llvm::consumeError(thread.takeError());
-    return LLDB_INVALID_HOST_THREAD;
-  }
 
-  return thread->Release();
+  if (error_ptr)
+    error_ptr->SetErrorString("ThreadCreate is no longer supported.");
+  return LLDB_INVALID_HOST_THREAD;
 }
 
 void SBHostOS::ThreadCreated(const char *name) {
@@ -130,13 +120,9 @@
                             (lldb::thread_t, lldb::SBError *), thread,
                             error_ptr);
 
-  Status error;
-  HostThread host_thread(thread);
-  error = host_thread.Cancel();
   if (error_ptr)
-    error_ptr->SetError(error);
-  host_thread.Release();
-  return error.Success();
+    error_ptr->SetErrorString("ThreadCancel is no longer supported.");
+  return false;
 }
 
 bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) {
@@ -144,18 +130,9 @@
                             (lldb::thread_t, lldb::SBError *), thread,
                             error_ptr);
 
-  Status error;
-#if defined(_WIN32)
-  if (error_ptr)
-    error_ptr->SetErrorString("ThreadDetach is not supported on this platform");
-#else
-  HostThread host_thread(thread);
-  error = host_thread.GetNativeThread().Detach();
   if (error_ptr)
-    error_ptr->SetError(error);
-  host_thread.Release();
-#endif
-  return error.Success();
+    error_ptr->SetErrorString("ThreadDetach is no longer supported.");
+  return false;
 }
 
 bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result,
@@ -164,14 +141,9 @@
       bool, SBHostOS, ThreadJoin,
       (lldb::thread_t, lldb::thread_result_t *, lldb::SBError *), thread,
       result, error_ptr);
-
-  Status error;
-  HostThread host_thread(thread);
-  error = host_thread.Join(result);
   if (error_ptr)
-    error_ptr->SetError(error);
-  host_thread.Release();
-  return error.Success();
+    error_ptr->SetErrorString("ThreadJoin is no longer supported.");
+  return false;
 }
 
 namespace lldb_private {
Index: lldb/include/lldb/Host/windows/HostThreadWindows.h
===================================================================
--- lldb/include/lldb/Host/windows/HostThreadWindows.h
+++ lldb/include/lldb/Host/windows/HostThreadWindows.h
@@ -27,7 +27,6 @@
   void SetOwnsHandle(bool owns);
 
   Status Join(lldb::thread_result_t *result) override;
-  Status Cancel() override;
   void Reset() override;
   bool EqualsThread(lldb::thread_t thread) const override;
 
Index: lldb/include/lldb/Host/posix/HostThreadPosix.h
===================================================================
--- lldb/include/lldb/Host/posix/HostThreadPosix.h
+++ lldb/include/lldb/Host/posix/HostThreadPosix.h
@@ -23,9 +23,6 @@
   ~HostThreadPosix() override;
 
   Status Join(lldb::thread_result_t *result) override;
-  Status Cancel() override;
-
-  Status Detach();
 };
 
 } // namespace lldb_private
Index: lldb/include/lldb/Host/HostThread.h
===================================================================
--- lldb/include/lldb/Host/HostThread.h
+++ lldb/include/lldb/Host/HostThread.h
@@ -32,7 +32,6 @@
   HostThread(lldb::thread_t thread);
 
   Status Join(lldb::thread_result_t *result);
-  Status Cancel();
   void Reset();
   lldb::thread_t Release();
 
Index: lldb/include/lldb/Host/HostNativeThreadBase.h
===================================================================
--- lldb/include/lldb/Host/HostNativeThreadBase.h
+++ lldb/include/lldb/Host/HostNativeThreadBase.h
@@ -32,7 +32,6 @@
   virtual ~HostNativeThreadBase() {}
 
   virtual Status Join(lldb::thread_result_t *result) = 0;
-  virtual Status Cancel() = 0;
   virtual bool IsJoinable() const;
   virtual void Reset();
   virtual bool EqualsThread(lldb::thread_t thread) const;
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to