aboutsummaryrefslogtreecommitdiff
path: root/gdb/maint.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-16 14:36:57 -0600
committerTom Tromey <tom@tromey.com>2019-11-26 14:02:58 -0700
commit22138db609721897c213e5a08ccaca206c0fb1f6 (patch)
tree5aa92270cde9c547bb91d0d5a1a16f69cec09d58 /gdb/maint.c
parentd55c9a68473d4378e484a870d3ca4222a68078ca (diff)
downloadgdb-22138db609721897c213e5a08ccaca206c0fb1f6.zip
gdb-22138db609721897c213e5a08ccaca206c0fb1f6.tar.gz
gdb-22138db609721897c213e5a08ccaca206c0fb1f6.tar.bz2
Add maint set/show worker-threads
This adds maint commands to control the number of worker threads that gdb can use. 2019-11-26 Tom Tromey <tom@tromey.com> * NEWS: Add entry. * maint.c (_initialize_maint_cmds): Add "worker-threads" maint commands. Call update_thread_pool_size. (update_thread_pool_size, maintenance_set_worker_threads): New functions. (n_worker_threads): New global. gdb/doc/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdb.texinfo (Maintenance Commands): Document new maint commands. Change-Id: I4fb514faa05879d8afe62c77036a4469d57dca2a
Diffstat (limited to 'gdb/maint.c')
-rw-r--r--gdb/maint.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gdb/maint.c b/gdb/maint.c
index ce59ef6..7ab3fdb 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -46,6 +46,10 @@
#include "cli/cli-setshow.h"
#include "cli/cli-cmds.h"
+#if CXX_STD_THREAD
+#include "gdbsupport/thread-pool.h"
+#endif
+
static void maintenance_do_deprecate (const char *, int);
/* Access the maintenance subcommands. */
@@ -840,6 +844,30 @@ maintenance_set_profile_cmd (const char *args, int from_tty,
error (_("Profiling support is not available on this system."));
}
#endif
+
+static int n_worker_threads = -1;
+
+/* Update the thread pool for the desired number of threads. */
+static void
+update_thread_pool_size ()
+{
+#if CXX_STD_THREAD
+ int n_threads = n_worker_threads;
+
+ if (n_threads < 0)
+ n_threads = std::thread::hardware_concurrency ();
+
+ gdb::thread_pool::g_thread_pool->set_thread_count (n_threads);
+#endif
+}
+
+static void
+maintenance_set_worker_threads (const char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ update_thread_pool_size ();
+}
+
/* If true, display time usage both at startup and for each command. */
@@ -1313,4 +1341,17 @@ When enabled GDB is profiled."),
show_maintenance_profile_p,
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+
+ add_setshow_zuinteger_unlimited_cmd ("worker-threads",
+ class_maintenance,
+ &n_worker_threads, _("\
+Set the number of worker threads GDB can use."), _("\
+Show the number of worker threads GDB can use."), _("\
+GDB may use multiple threads to speed up certain CPU-intensive operations,\n\
+such as demangling symbol names."),
+ maintenance_set_worker_threads, NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
+
+ update_thread_pool_size ();
}