+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.
/* 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
# 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
+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.
/* 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
# 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
# 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"
#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
{
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 ();
}
}