GNU Binutils with patches for OS216
Revisão | 4a7dabea39556979cbf6bcbdd98a9413ce129fd0 (tree) |
---|---|
Hora | 2019-11-11 02:44:50 |
Autor | Tom Tromey <tom@trom...> |
Commiter | Tom Tromey |
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-10-19 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-10-19 Tom Tromey <tom@tromey.com>
* configure, config.in: Rebuild.
Change-Id: I60473d65ae9ae14d8c56ddde39684240c16aaf35
@@ -1,5 +1,13 @@ | ||
1 | 1 | 2019-10-19 Tom Tromey <tom@tromey.com> |
2 | 2 | |
3 | + * gdbsupport/thread-pool.c (thread_pool::set_thread_count): Set | |
4 | + name of worker thread. | |
5 | + * gdbsupport/common.m4 (GDB_AC_COMMON): Check for | |
6 | + pthread_setname_np. | |
7 | + * configure, config.in: Rebuild. | |
8 | + | |
9 | +2019-10-19 Tom Tromey <tom@tromey.com> | |
10 | + | |
3 | 11 | * python/python.c (class gdbpy_gil): New. |
4 | 12 | (struct gdbpy_event): Add constructor, destructor, operator(). |
5 | 13 | (gdbpy_post_event): Use run_on_main_thread. |
@@ -342,6 +342,9 @@ | ||
342 | 342 | /* Have PTHREAD_PRIO_INHERIT. */ |
343 | 343 | #undef HAVE_PTHREAD_PRIO_INHERIT |
344 | 344 | |
345 | +/* Define to 1 if you have the `pthread_setname_np' function. */ | |
346 | +#undef HAVE_PTHREAD_SETNAME_NP | |
347 | + | |
345 | 348 | /* Define to 1 if you have the `pthread_sigmask' function. */ |
346 | 349 | #undef HAVE_PTHREAD_SIGMASK |
347 | 350 |
@@ -14337,12 +14337,13 @@ $as_echo "$gdb_cv_cxx_std_thread" >&6; } | ||
14337 | 14337 | |
14338 | 14338 | # This check must be here, while LIBS includes any necessary |
14339 | 14339 | # threading library. |
14340 | - for ac_func in pthread_sigmask | |
14340 | + for ac_func in pthread_sigmask pthread_setname_np | |
14341 | 14341 | do : |
14342 | - ac_fn_cxx_check_func "$LINENO" "pthread_sigmask" "ac_cv_func_pthread_sigmask" | |
14343 | -if test "x$ac_cv_func_pthread_sigmask" = xyes; then : | |
14342 | + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` | |
14343 | +ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" | |
14344 | +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : | |
14344 | 14345 | cat >>confdefs.h <<_ACEOF |
14345 | -#define HAVE_PTHREAD_SIGMASK 1 | |
14346 | +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 | |
14346 | 14347 | _ACEOF |
14347 | 14348 | |
14348 | 14349 | fi |
@@ -1,5 +1,9 @@ | ||
1 | 1 | 2019-10-19 Tom Tromey <tom@tromey.com> |
2 | 2 | |
3 | + * configure, config.in: Rebuild. | |
4 | + | |
5 | +2019-10-19 Tom Tromey <tom@tromey.com> | |
6 | + | |
3 | 7 | * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. |
4 | 8 | * linux-low.c (linux_wait_for_event_filtered, linux_async): Use |
5 | 9 | gdb_sigmask. |
@@ -195,6 +195,9 @@ | ||
195 | 195 | /* Have PTHREAD_PRIO_INHERIT. */ |
196 | 196 | #undef HAVE_PTHREAD_PRIO_INHERIT |
197 | 197 | |
198 | +/* Define to 1 if you have the `pthread_setname_np' function. */ | |
199 | +#undef HAVE_PTHREAD_SETNAME_NP | |
200 | + | |
198 | 201 | /* Define to 1 if you have the `pthread_sigmask' function. */ |
199 | 202 | #undef HAVE_PTHREAD_SIGMASK |
200 | 203 |
@@ -7725,12 +7725,13 @@ $as_echo "$gdb_cv_cxx_std_thread" >&6; } | ||
7725 | 7725 | |
7726 | 7726 | # This check must be here, while LIBS includes any necessary |
7727 | 7727 | # threading library. |
7728 | - for ac_func in pthread_sigmask | |
7728 | + for ac_func in pthread_sigmask pthread_setname_np | |
7729 | 7729 | do : |
7730 | - ac_fn_cxx_check_func "$LINENO" "pthread_sigmask" "ac_cv_func_pthread_sigmask" | |
7731 | -if test "x$ac_cv_func_pthread_sigmask" = xyes; then : | |
7730 | + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` | |
7731 | +ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" | |
7732 | +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : | |
7732 | 7733 | cat >>confdefs.h <<_ACEOF |
7733 | -#define HAVE_PTHREAD_SIGMASK 1 | |
7734 | +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 | |
7734 | 7735 | _ACEOF |
7735 | 7736 | |
7736 | 7737 | fi |
@@ -57,7 +57,7 @@ AC_DEFUN([GDB_AC_COMMON], [ | ||
57 | 57 | |
58 | 58 | # This check must be here, while LIBS includes any necessary |
59 | 59 | # threading library. |
60 | - AC_CHECK_FUNCS([pthread_sigmask]) | |
60 | + AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np]) | |
61 | 61 | |
62 | 62 | LIBS="$save_LIBS" |
63 | 63 | CXXFLAGS="$save_CXXFLAGS" |
@@ -23,6 +23,15 @@ | ||
23 | 23 | #include "gdbsupport/block-signals.h" |
24 | 24 | #include <algorithm> |
25 | 25 | |
26 | +/* On the off chance that we have the pthread library on a Windows | |
27 | + host, but std::thread is not using it, avoid calling | |
28 | + pthread_setname_np on Windows. */ | |
29 | +#ifndef _WIN32 | |
30 | +#ifdef HAVE_PTHREAD_SETNAME_NP | |
31 | +#include <pthread.h> | |
32 | +#endif | |
33 | +#endif | |
34 | + | |
26 | 35 | namespace gdb |
27 | 36 | { |
28 | 37 |
@@ -59,6 +68,11 @@ thread_pool::set_thread_count (size_t num_threads) | ||
59 | 68 | for (size_t i = m_count; i < num_threads; ++i) |
60 | 69 | { |
61 | 70 | std::thread thread (&thread_pool::thread_function, this); |
71 | +#ifndef _WIN32 /* See the comment at the top of the file. */ | |
72 | +#ifdef HAVE_PTHREAD_SETNAME_NP | |
73 | + pthread_setname_np (thread.native_handle (), "gdb worker"); | |
74 | +#endif | |
75 | +#endif | |
62 | 76 | thread.detach (); |
63 | 77 | } |
64 | 78 | } |