public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] Set names of worker threads
Date: Wed, 27 Nov 2019 13:55:00 -0000	[thread overview]
Message-ID: <4da8c3a8a5d1962d24fb374122c473f930eba386@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 4da8c3a8a5d1962d24fb374122c473f930eba386 ***

commit 4da8c3a8a5d1962d24fb374122c473f930eba386
Author:     Tom Tromey <tom@tromey.com>
AuthorDate: Sat Oct 12 13:06:18 2019 -0600
Commit:     Tom Tromey <tom@tromey.com>
CommitDate: Tue Nov 26 14:02:58 2019 -0700

    Set names of worker threads
    
    This adds some configury so that gdb can set the names of worker
    threads.  This makes them show up more nicely when debugging gdb
    itself.
    
    2019-11-26  Tom Tromey  <tom@tromey.com>
    
            * gdbsupport/thread-pool.c (thread_pool::set_thread_count): Set
            name of worker thread.
            * gdbsupport/common.m4 (GDB_AC_COMMON): Check for
            pthread_setname_np.
            * configure, config.in: Rebuild.
    
    gdb/gdbserver/ChangeLog
    2019-11-26  Tom Tromey  <tom@tromey.com>
    
            * configure, config.in: Rebuild.
    
    Change-Id: I60473d65ae9ae14d8c56ddde39684240c16aaf35

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0c5aab26d3..94a8bdc8dc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2019-11-26  Tom Tromey  <tom@tromey.com>
+
+	* gdbsupport/thread-pool.c (thread_pool::set_thread_count): Set
+	name of worker thread.
+	* gdbsupport/common.m4 (GDB_AC_COMMON): Check for
+	pthread_setname_np.
+	* configure, config.in: Rebuild.
+
 2019-11-26  Tom Tromey  <tom@tromey.com>
 
 	* python/python.c (class gdbpy_gil): New.
diff --git a/gdb/config.in b/gdb/config.in
index 61e63e2330..1caf76481b 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -342,6 +342,9 @@
 /* Have PTHREAD_PRIO_INHERIT. */
 #undef HAVE_PTHREAD_PRIO_INHERIT
 
+/* Define to 1 if you have the `pthread_setname_np' function. */
+#undef HAVE_PTHREAD_SETNAME_NP
+
 /* Define to 1 if you have the `pthread_sigmask' function. */
 #undef HAVE_PTHREAD_SIGMASK
 
diff --git a/gdb/configure b/gdb/configure
index dd936d247e..6b64619df7 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -14333,12 +14333,13 @@ $as_echo "$gdb_cv_cxx_std_thread" >&6; }
 
     # This check must be here, while LIBS includes any necessary
     # threading library.
-    for ac_func in pthread_sigmask
+    for ac_func in pthread_sigmask pthread_setname_np
 do :
-  ac_fn_cxx_check_func "$LINENO" "pthread_sigmask" "ac_cv_func_pthread_sigmask"
-if test "x$ac_cv_func_pthread_sigmask" = xyes; then :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_PTHREAD_SIGMASK 1
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
 fi
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 00b0a0df02..de6c311e07 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,7 @@
+2019-11-26  Tom Tromey  <tom@tromey.com>
+
+	* configure, config.in: Rebuild.
+
 2019-11-26  Tom Tromey  <tom@tromey.com>
 
 	* remote-utils.c (block_unblock_async_io): Use gdb_sigmask.
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 3027ffa1b1..14cf7099e3 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -195,6 +195,9 @@
 /* Have PTHREAD_PRIO_INHERIT. */
 #undef HAVE_PTHREAD_PRIO_INHERIT
 
+/* Define to 1 if you have the `pthread_setname_np' function. */
+#undef HAVE_PTHREAD_SETNAME_NP
+
 /* Define to 1 if you have the `pthread_sigmask' function. */
 #undef HAVE_PTHREAD_SIGMASK
 
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 8d34a6c305..da17f8cb2c 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -7725,12 +7725,13 @@ $as_echo "$gdb_cv_cxx_std_thread" >&6; }
 
     # This check must be here, while LIBS includes any necessary
     # threading library.
-    for ac_func in pthread_sigmask
+    for ac_func in pthread_sigmask pthread_setname_np
 do :
-  ac_fn_cxx_check_func "$LINENO" "pthread_sigmask" "ac_cv_func_pthread_sigmask"
-if test "x$ac_cv_func_pthread_sigmask" = xyes; then :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_PTHREAD_SIGMASK 1
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
 fi
diff --git a/gdb/gdbsupport/common.m4 b/gdb/gdbsupport/common.m4
index e993b20248..4f2bb5218d 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 8282ea374b..d19ae02e3e 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 ();
 	}
     }


             reply	other threads:[~2019-11-27 13:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27 13:55 gdb-buildbot [this message]
2019-11-27 13:55 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot
2019-11-27 14:09 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2019-11-30  7:51 ` Failures on Fedora-i686, " gdb-buildbot
2019-11-30  8:03 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2019-11-30  8:11 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2019-11-30  8:30 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2019-11-30  8:33 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-w64-mingw32, branch master *** BREAKAGE *** gdb-buildbot
2019-11-30  8:47 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, branch master gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4da8c3a8a5d1962d24fb374122c473f930eba386@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).