Index: include/lldb/Host/freebsd/HostThreadFreeBSD.h =================================================================== --- include/lldb/Host/freebsd/HostThreadFreeBSD.h +++ include/lldb/Host/freebsd/HostThreadFreeBSD.h @@ -21,8 +21,6 @@ public: HostThreadFreeBSD(); HostThreadFreeBSD(lldb::thread_t thread); - - static void GetName(lldb::tid_t tid, llvm::SmallVectorImpl &name); }; } Index: include/lldb/Host/linux/HostThreadLinux.h =================================================================== --- include/lldb/Host/linux/HostThreadLinux.h +++ include/lldb/Host/linux/HostThreadLinux.h @@ -21,9 +21,6 @@ public: HostThreadLinux(); HostThreadLinux(lldb::thread_t thread); - - static void SetName(lldb::thread_t thread, llvm::StringRef name); - static void GetName(lldb::thread_t thread, llvm::SmallVectorImpl &name); }; } Index: source/Host/freebsd/HostThreadFreeBSD.cpp =================================================================== --- source/Host/freebsd/HostThreadFreeBSD.cpp +++ source/Host/freebsd/HostThreadFreeBSD.cpp @@ -11,19 +11,6 @@ #include "lldb/Host/freebsd/HostThreadFreeBSD.h" #include "lldb/Host/Host.h" -// C includes -#include -#include -#if defined(__FreeBSD__) -#include -#endif -#include -#include -#include - -// C++ includes -#include - using namespace lldb_private; HostThreadFreeBSD::HostThreadFreeBSD() {} @@ -30,41 +17,3 @@ HostThreadFreeBSD::HostThreadFreeBSD(lldb::thread_t thread) : HostThreadPosix(thread) {} - -void HostThreadFreeBSD::GetName(lldb::tid_t tid, - llvm::SmallVectorImpl &name) { - name.clear(); - int pid = Host::GetCurrentProcessID(); - - struct kinfo_proc *kp = nullptr, *nkp; - size_t len = 0; - int error; - int ctl[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD, - (int)pid}; - - while (1) { - error = sysctl(ctl, 4, kp, &len, nullptr, 0); - if (kp == nullptr || (error != 0 && errno == ENOMEM)) { - // Add extra space in case threads are added before next call. - len += sizeof(*kp) + len / 10; - nkp = (struct kinfo_proc *)realloc(kp, len); - if (nkp == nullptr) { - free(kp); - return; - } - kp = nkp; - continue; - } - if (error != 0) - len = 0; - break; - } - - for (size_t i = 0; i < len / sizeof(*kp); i++) { - if (kp[i].ki_tid == (lwpid_t)tid) { - name.append(kp[i].ki_tdname, kp[i].ki_tdname + strlen(kp[i].ki_tdname)); - break; - } - } - free(kp); -} Index: source/Host/linux/HostThreadLinux.cpp =================================================================== --- source/Host/linux/HostThreadLinux.cpp +++ source/Host/linux/HostThreadLinux.cpp @@ -8,13 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/Host/linux/HostThreadLinux.h" -#include "Plugins/Process/Linux/ProcFileReader.h" -#include "lldb/Utility/DataBuffer.h" -#include "llvm/ADT/SmallVector.h" - -#include - using namespace lldb_private; HostThreadLinux::HostThreadLinux() : HostThreadPosix() {} @@ -21,25 +15,3 @@ HostThreadLinux::HostThreadLinux(lldb::thread_t thread) : HostThreadPosix(thread) {} - -void HostThreadLinux::SetName(lldb::thread_t thread, llvm::StringRef name) { -#if (defined(__GLIBC__) && defined(_GNU_SOURCE)) || defined(__ANDROID__) - ::pthread_setname_np(thread, name.data()); -#else - (void)thread; - (void)name; -#endif -} - -void HostThreadLinux::GetName(lldb::thread_t thread, - llvm::SmallVectorImpl &name) { - // Read /proc/$TID/comm file. - lldb::DataBufferSP buf_sp = - process_linux::ProcFileReader::ReadIntoDataBuffer(thread, "comm"); - const char *comm_str = (const char *)buf_sp->GetBytes(); - const char *cr_str = ::strchr(comm_str, '\n'); - size_t length = cr_str ? (cr_str - comm_str) : strlen(comm_str); - - name.clear(); - name.append(comm_str, comm_str + length); -} Index: source/Plugins/Process/Linux/NativeThreadLinux.cpp =================================================================== --- source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -97,7 +97,7 @@ // const NativeProcessLinux *const process = // reinterpret_cast (process_sp->get ()); llvm::SmallString<32> thread_name; - HostNativeThread::GetName(GetID(), thread_name); + llvm::get_thread_name(thread_name); return thread_name.c_str(); }