aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbsupport
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbsupport')
-rw-r--r--gdb/gdbsupport/common.m42
-rw-r--r--gdb/gdbsupport/thread-pool.c16
2 files changed, 17 insertions, 1 deletions
diff --git a/gdb/gdbsupport/common.m4 b/gdb/gdbsupport/common.m4
index e993b20..4f2bb52 100644
--- a/gdb/gdbsupport/common.m4
+++ b/gdb/gdbsupport/common.m4
@@ -57,7 +57,7 @@ AC_DEFUN([GDB_AC_COMMON], [
# This check must be here, while LIBS includes any necessary
# threading library.
- AC_CHECK_FUNCS([pthread_sigmask])
+ AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np])
LIBS="$save_LIBS"
CXXFLAGS="$save_CXXFLAGS"
diff --git a/gdb/gdbsupport/thread-pool.c b/gdb/gdbsupport/thread-pool.c
index 8282ea3..d19ae02 100644
--- a/gdb/gdbsupport/thread-pool.c
+++ b/gdb/gdbsupport/thread-pool.c
@@ -26,6 +26,19 @@
#include "gdbsupport/block-signals.h"
#include <algorithm>
+/* On the off chance that we have the pthread library on a Windows
+ host, but std::thread is not using it, avoid calling
+ pthread_setname_np on Windows. */
+#ifndef _WIN32
+#ifdef HAVE_PTHREAD_SETNAME_NP
+#define USE_PTHREAD_SETNAME_NP
+#endif
+#endif
+
+#ifdef USE_PTHREAD_SETNAME_NP
+#include <pthread.h>
+#endif
+
namespace gdb
{
@@ -62,6 +75,9 @@ thread_pool::set_thread_count (size_t num_threads)
for (size_t i = m_thread_count; i < num_threads; ++i)
{
std::thread thread (&thread_pool::thread_function, this);
+#ifdef USE_PTHREAD_SETNAME_NP
+ pthread_setname_np (thread.native_handle (), "gdb worker");
+#endif
thread.detach ();
}
}