Author: daniilavdeev Date: 2026-02-18T21:03:10+03:00 New Revision: 4c225918a9e78463c9bf9cc0a26be5ae2ed1c827
URL: https://github.com/llvm/llvm-project/commit/4c225918a9e78463c9bf9cc0a26be5ae2ed1c827 DIFF: https://github.com/llvm/llvm-project/commit/4c225918a9e78463c9bf9cc0a26be5ae2ed1c827.diff LOG: [lldb] Unify thread detaching by making HostThreadPosix override Reset() (#179470) Remove the Detach() method from HostThreadPosix and instead override the virtual Reset() function from HostNativeThreadBase, following the pattern already used by HostThreadWindows. This provides a consistent interface for platform-specific thread cleanup on all platforms. The HostThreadPosix::Reset() implementation first calls pthread_detach() before delegating to the base implementation HostNativeThreadBase::Reset(), similar to how HostThreadWindows calls CloseHandle() in its Reset() override. This is a preparatory changes for https://github.com/llvm/llvm-project/pull/177572, which addresses memory leakage in lldb-server. By unifying the logic of detaching, it would be possible to introduce the behavioral change in a more straightforward manner. Added: Modified: lldb/include/lldb/Host/posix/HostThreadPosix.h lldb/source/Host/posix/HostThreadPosix.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Host/posix/HostThreadPosix.h b/lldb/include/lldb/Host/posix/HostThreadPosix.h index 6c8e09fc11030..32be7154fa1d8 100644 --- a/lldb/include/lldb/Host/posix/HostThreadPosix.h +++ b/lldb/include/lldb/Host/posix/HostThreadPosix.h @@ -25,7 +25,7 @@ class HostThreadPosix : public HostNativeThreadBase { Status Join(lldb::thread_result_t *result) override; Status Cancel() override; - Status Detach(); + void Reset() override; }; } // namespace lldb_private diff --git a/lldb/source/Host/posix/HostThreadPosix.cpp b/lldb/source/Host/posix/HostThreadPosix.cpp index a53a8cc9d8389..92f172ecd00a5 100644 --- a/lldb/source/Host/posix/HostThreadPosix.cpp +++ b/lldb/source/Host/posix/HostThreadPosix.cpp @@ -50,12 +50,8 @@ Status HostThreadPosix::Cancel() { return error; } -Status HostThreadPosix::Detach() { - Status error; - if (IsJoinable()) { - int err = ::pthread_detach(m_thread); - error = Status(err, eErrorTypePOSIX); - } - Reset(); - return error; +void HostThreadPosix::Reset() { + if (IsJoinable()) + ::pthread_detach(m_thread); + HostNativeThreadBase::Reset(); } _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
