[v2,8/8] Add maint set/show enable-threads

Message ID 20190518210010.27697-9-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey May 18, 2019, 9 p.m. UTC
  This adds maint commands to control whether gdb is able to use
threads.

gdb/ChangeLog
2019-05-18  Tom Tromey  <tom@tromey.com>

	* NEWS: Add entry.
	* maint.c (_initialize_maint_cmds): Add "enable-threads" maint
	commands.

gdb/doc/ChangeLog
2019-05-18  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Maintenance Commands): Document new maint
	commands.
---
 gdb/ChangeLog       |  6 ++++++
 gdb/NEWS            |  4 ++++
 gdb/doc/ChangeLog   |  5 +++++
 gdb/doc/gdb.texinfo | 11 +++++++++++
 gdb/maint.c         | 10 ++++++++++
 5 files changed, 36 insertions(+)
  

Comments

Eli Zaretskii May 22, 2019, 5:01 a.m. UTC | #1
> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>
> Date: Sat, 18 May 2019 15:00:10 -0600
> 
> This adds maint commands to control whether gdb is able to use
> threads.
> 
> gdb/ChangeLog
> 2019-05-18  Tom Tromey  <tom@tromey.com>
> 
> 	* NEWS: Add entry.
> 	* maint.c (_initialize_maint_cmds): Add "enable-threads" maint
> 	commands.
> 
> gdb/doc/ChangeLog
> 2019-05-18  Tom Tromey  <tom@tromey.com>
> 
> 	* gdb.texinfo (Maintenance Commands): Document new maint
> 	commands.

Thanks.

> +maint set enable-threads
> +maint show enable-threads
> +  Control whether GDB can use threads.  The default is "on".

I'd suggest to say what will threads be used for.

> +  add_setshow_boolean_cmd ("enable-threads", class_maintenance,
> +			   &gdb::enable_threads, _("\
> +Set whether gdb can use multiple threads."), _("\
> +Show whether gdb can use multiple threads."), _("\
> +If enabled, gdb will use multiple threads when possible."),

maybe also here.

The documentation parts are OK with this nit fixed.
  
Tom Tromey May 26, 2019, 8:46 p.m. UTC | #2
>> +maint set enable-threads
>> +maint show enable-threads
>> +  Control whether GDB can use threads.  The default is "on".

Eli> I'd suggest to say what will threads be used for.

In NEWS I guess it's ok, but elsewhere I'd prefer to be a bit vague
about the precise use of threads.  That way the documentation won't go
stale if we add more uses.

Tom
  
Eli Zaretskii May 27, 2019, 2:32 a.m. UTC | #3
> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
> Date: Sun, 26 May 2019 14:46:12 -0600
> 
> >> +maint set enable-threads
> >> +maint show enable-threads
> >> +  Control whether GDB can use threads.  The default is "on".
> 
> Eli> I'd suggest to say what will threads be used for.
> 
> In NEWS I guess it's ok, but elsewhere I'd prefer to be a bit vague
> about the precise use of threads.  That way the documentation won't go
> stale if we add more uses.

That's okay, we can be vague.  How about saying that "threads are used
for some CPU-extensive processing, such as ..." and give one example?

My point is that leaving it entirely unsaid is way too vague,
especially for readers who might be debugging programs that themselves
use threads.
  

Patch

diff --git a/gdb/NEWS b/gdb/NEWS
index 1e92a2b52c2..dc278b5ee68 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -46,6 +46,10 @@  show print max-depth
   The default max-depth is 20, but this can be set to unlimited to get
   the old behavior back.
 
+maint set enable-threads
+maint show enable-threads
+  Control whether GDB can use threads.  The default is "on".
+
 * New MI commands
 
 -complete
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 37e2f14ad0f..7e34cd3179c 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -36925,6 +36925,17 @@  with the DWARF frame unwinders enabled.
 
 If DWARF frame unwinders are not supported for a particular target
 architecture, then enabling this flag does not cause them to be used.
+
+@kindex maint set enable-threads
+@kindex maint show enable-threads
+@item maint set enable-threads
+@item maint show enable-threads
+Control whether @value{GDBN} uses threads.  On capable hosts,
+@value{GDBN} will use multiple threads to speed up certain operations.
+However, when debugging @value{GDBN} itself, it is sometimes
+convenient to disable this feature.  That can be done using this
+command.  The default is @samp{on}.
+
 @kindex maint set profile
 @kindex maint show profile
 @cindex profiling GDB
diff --git a/gdb/maint.c b/gdb/maint.c
index 328d6026a34..0368eff338b 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -39,6 +39,7 @@ 
 #include "top.h"
 #include "maint.h"
 #include "common/selftest.h"
+#include "common/parallel-for.h"
 
 #include "cli/cli-decode.h"
 #include "cli/cli-utils.h"
@@ -1143,4 +1144,13 @@  When enabled GDB is profiled."),
 			   show_maintenance_profile_p,
 			   &maintenance_set_cmdlist,
 			   &maintenance_show_cmdlist);
+
+  add_setshow_boolean_cmd ("enable-threads", class_maintenance,
+			   &gdb::enable_threads, _("\
+Set whether gdb can use multiple threads."), _("\
+Show whether gdb can use multiple threads."), _("\
+If enabled, gdb will use multiple threads when possible."),
+			   NULL, NULL,
+			   &maintenance_set_cmdlist,
+			   &maintenance_show_cmdlist);
 }