public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: convert 'set debug lin-lwp' to a boolean command
@ 2021-12-11 10:45 Andrew Burgess
  2021-12-12 22:10 ` John Baldwin
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2021-12-11 10:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

Convert the 'set debug lin-lwp' command to a boolean.  Adds a new
LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT macro, and makes use of it in one
place (linux_nat_target::stop).

The manual entry for 'set debug lin-lwp' is already vague about
exactly what arguments this command takes, and the description talks
about turning debug on and off, so I don't think there's any updates
required there.

I have updated the doc strings shown when the users enters 'help show
debug lin-lwp' or 'help show debug lin-lwp'.  The old title lines used
to talk about the 'GNU/Linux lwp module', but this debug flag is now
used for any native linux target debug, so we now talk about
'GNU/Linux native target'.  The body string for this setting has been
changed from 'Enables printf debugging output.' to 'When on, print
debug messages relating to the GNU/Linux native target.', the old
value looks like a cut&paste error to me.
---
 gdb/linux-nat.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 9d4b05a2167..c61b1acb23a 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -191,7 +191,12 @@ struct linux_nat_target *linux_target;
 /* Does the current host support PTRACE_GETREGSET?  */
 enum tribool have_ptrace_getregset = TRIBOOL_UNKNOWN;
 
-static unsigned int debug_linux_nat;
+/* When true, print debug messages relating to the linux native target.  */
+
+static bool debug_linux_nat;
+
+/* Implement 'show debug lin-lwp'.  */
+
 static void
 show_debug_linux_nat (struct ui_file *file, int from_tty,
 		      struct cmd_list_element *c, const char *value)
@@ -205,6 +210,11 @@ show_debug_linux_nat (struct ui_file *file, int from_tty,
 #define linux_nat_debug_printf(fmt, ...) \
   debug_prefixed_printf_cond (debug_linux_nat, "linux-nat", fmt, ##__VA_ARGS__)
 
+/* Print "linux-nat" enter/exit debug statements.  */
+
+#define LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT \
+  scoped_debug_enter_exit (debug_linux_nat, "linux-nat")
+
 struct simple_pid_list
 {
   int pid;
@@ -4316,6 +4326,7 @@ linux_nat_stop_lwp (struct lwp_info *lwp)
 void
 linux_nat_target::stop (ptid_t ptid)
 {
+  LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT;
   iterate_over_lwps (ptid, linux_nat_stop_lwp);
 }
 
@@ -4516,14 +4527,14 @@ void _initialize_linux_nat ();
 void
 _initialize_linux_nat ()
 {
-  add_setshow_zuinteger_cmd ("lin-lwp", class_maintenance,
-			     &debug_linux_nat, _("\
-Set debugging of GNU/Linux lwp module."), _("\
-Show debugging of GNU/Linux lwp module."), _("\
-Enables printf debugging output."),
-			     NULL,
-			     show_debug_linux_nat,
-			     &setdebuglist, &showdebuglist);
+  add_setshow_boolean_cmd ("lin-lwp", class_maintenance,
+			   &debug_linux_nat, _("\
+Set debugging of GNU/Linux native target."), _("	\
+Show debugging of GNU/Linux native target."), _("	\
+When on, print debug messages relating to the GNU/Linux native target."),
+			   nullptr,
+			   show_debug_linux_nat,
+			   &setdebuglist, &showdebuglist);
 
   add_setshow_boolean_cmd ("linux-namespaces", class_maintenance,
 			   &debug_linux_namespaces, _("\
-- 
2.25.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: convert 'set debug lin-lwp' to a boolean command
  2021-12-11 10:45 [PATCH] gdb: convert 'set debug lin-lwp' to a boolean command Andrew Burgess
@ 2021-12-12 22:10 ` John Baldwin
  2021-12-22 15:13   ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: John Baldwin @ 2021-12-12 22:10 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 12/11/21 2:45 AM, Andrew Burgess via Gdb-patches wrote:
> Convert the 'set debug lin-lwp' command to a boolean.  Adds a new
> LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT macro, and makes use of it in one
> place (linux_nat_target::stop).
> 
> The manual entry for 'set debug lin-lwp' is already vague about
> exactly what arguments this command takes, and the description talks
> about turning debug on and off, so I don't think there's any updates
> required there.
> 
> I have updated the doc strings shown when the users enters 'help show
> debug lin-lwp' or 'help show debug lin-lwp'.  The old title lines used
> to talk about the 'GNU/Linux lwp module', but this debug flag is now
> used for any native linux target debug, so we now talk about
> 'GNU/Linux native target'.  The body string for this setting has been
> changed from 'Enables printf debugging output.' to 'When on, print
> debug messages relating to the GNU/Linux native target.', the old
> value looks like a cut&paste error to me.

Maybe rename it to 'lin-nat' while you are at it?  (In fbsd-nat.c I have
both 'set/show debug fbsd nat' and 'set/show debug fbsd lwp' FWIW.)

-- 
John Baldwin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb: convert 'set debug lin-lwp' to a boolean command
  2021-12-12 22:10 ` John Baldwin
@ 2021-12-22 15:13   ` Andrew Burgess
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2021-12-22 15:13 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb-patches

* John Baldwin <jhb@FreeBSD.org> [2021-12-12 14:10:26 -0800]:

> On 12/11/21 2:45 AM, Andrew Burgess via Gdb-patches wrote:
> > Convert the 'set debug lin-lwp' command to a boolean.  Adds a new
> > LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT macro, and makes use of it in one
> > place (linux_nat_target::stop).
> > 
> > The manual entry for 'set debug lin-lwp' is already vague about
> > exactly what arguments this command takes, and the description talks
> > about turning debug on and off, so I don't think there's any updates
> > required there.
> > 
> > I have updated the doc strings shown when the users enters 'help show
> > debug lin-lwp' or 'help show debug lin-lwp'.  The old title lines used
> > to talk about the 'GNU/Linux lwp module', but this debug flag is now
> > used for any native linux target debug, so we now talk about
> > 'GNU/Linux native target'.  The body string for this setting has been
> > changed from 'Enables printf debugging output.' to 'When on, print
> > debug messages relating to the GNU/Linux native target.', the old
> > value looks like a cut&paste error to me.
> 
> Maybe rename it to 'lin-nat' while you are at it?  (In fbsd-nat.c I have
> both 'set/show debug fbsd nat' and 'set/show debug fbsd lwp' FWIW.)

I've pushed this patch now without renaming any of the flags.  I'll
roll a separate patch to rename things, and post that soon.

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-22 15:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-11 10:45 [PATCH] gdb: convert 'set debug lin-lwp' to a boolean command Andrew Burgess
2021-12-12 22:10 ` John Baldwin
2021-12-22 15:13   ` Andrew Burgess

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).