[Lldb-commits] [PATCH] D13019: Do not use pthread_{get, set}name_np() if we don't have GLIBC.

Vasileios Kalintiris via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 21 06:30:28 PDT 2015


vkalintiris created this revision.
vkalintiris added reviewers: clayborg, ovyalov.
vkalintiris added a subscriber: lldb-commits.

pthread_{get,set}name_np() are nonstandard GNU extensions which are
included only when _GNU_SOURCE is defined under GLIBC.

http://reviews.llvm.org/D13019

Files:
  source/Host/linux/HostThreadLinux.cpp

Index: source/Host/linux/HostThreadLinux.cpp
===================================================================
--- source/Host/linux/HostThreadLinux.cpp
+++ source/Host/linux/HostThreadLinux.cpp
@@ -30,18 +30,28 @@
 void
 HostThreadLinux::SetName(lldb::thread_t thread, llvm::StringRef name)
 {
+#if defined(__GLIBC__) && defined(_GNU_SOURCE)
     ::pthread_setname_np(thread, name.data());
+#else
+    (void) thread;
+    (void) name;
+#endif
 }
 
 void
 HostThreadLinux::GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name)
 {
+#if defined(__GLIBC__) && defined(_GNU_SOURCE)
     // 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);
+#else
+    (void) thread;
+    (void) name;
+#endif
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13019.35248.patch
Type: text/x-patch
Size: 1035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150921/7d43816f/attachment.bin>


More information about the lldb-commits mailing list