public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] [gdb/cli] Add command: show logging active
@ 2021-11-23 11:46 Tom de Vries
  2021-11-23 11:49 ` [PATCH] " Tom de Vries
  2021-11-23 12:49 ` [pushed] " Luis Machado
  0 siblings, 2 replies; 12+ messages in thread
From: Tom de Vries @ 2021-11-23 11:46 UTC (permalink / raw)
  To: gdb-patches

Currently, there's no gdb command that shows whether logging is enabled or
disabled.

There's the show logging command, but output is identical in both cases.
With logging disabled, we have:
...
(gdb) set logging off
(gdb) show logging
logging debugredirect:  The logging output mode is off.
logging file:  The current logfile is "gdb.txt".
logging overwrite: \
  Whether logging overwrites or appends to the log file is off.
logging redirect:  The logging output mode is off.
...
and with logging enabled we have:
...
(gdb) set logging on
Copying output to gdb.txt.
Copying debug output to gdb.txt.
(gdb) show logging
logging debugredirect:  The logging output mode is off.
logging file:  The current logfile is "gdb.txt".
logging overwrite: \
  Whether logging overwrites or appends to the log file is off.
logging redirect:  The logging output mode is off.
...

Add a "show logging active" command, such that we have:
...
(gdb) show logging
logging active:  Logging is disabled.
logging debugredirect:  The logging output mode is off.
logging file:  The current logfile is "gdb.txt".
logging overwrite: \
  Whether logging overwrites or appends to the log file is off.
logging redirect:  The logging output mode is off.
...

Mention the new command in NEWS and docs.

Tested on x86_64-linux.
---
 gdb/NEWS              |  5 +++++
 gdb/cli/cli-logging.c | 13 +++++++++++++
 gdb/doc/gdb.texinfo   |  2 ++
 3 files changed, 20 insertions(+)

diff --git a/gdb/NEWS b/gdb/NEWS
index 9e950d2f80d..253070a2a57 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -32,6 +32,11 @@ maint show internal-warning backtrace
   internal-error, or an internal-warning.  This is on by default for
   internal-error and off by default for internal-warning.
 
+show logging active
+  This command shows whether logging is enabled or disabled.  Whether logging
+  is enabled or disabled is controlled by pre-existing command
+  "set logging [on|off]".
+
 * Python API
 
   ** New function gdb.add_history(), which takes a gdb.Value object
diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c
index f0ee09180f9..081afcc4ca2 100644
--- a/gdb/cli/cli-logging.c
+++ b/gdb/cli/cli-logging.c
@@ -163,6 +163,17 @@ set_logging_off (const char *args, int from_tty)
   saved_filename = NULL;
 }
 
+/* Show the status set by set_logging_on / set_logging_off.  */
+
+static void
+show_logging_on_off (const char *args, int from_tty)
+{
+  if (saved_filename)
+    printf_unfiltered (_("Logging is enabled.\n"));
+  else
+    printf_unfiltered (_("Logging is disabled.\n"));
+}
+
 void _initialize_cli_logging ();
 void
 _initialize_cli_logging ()
@@ -211,4 +222,6 @@ The logfile is used when directing GDB's output."),
 	   _("Enable logging."), &set_logging_cmdlist);
   add_cmd ("off", class_support, set_logging_off,
 	   _("Disable logging."), &set_logging_cmdlist);
+  add_cmd ("active", class_support, show_logging_on_off,
+	   _("Show whether logging is active."), &show_logging_cmdlist);
 }
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 1b13973cdc5..4bea8f9b3dc 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1723,6 +1723,8 @@ Set @code{redirect} if you want output to go only to the log file.
 By default, @value{GDBN} debug output will go to both the terminal and the logfile.
 Set @code{debugredirect} if you want debug output to go only to the log file.
 @kindex show logging
+@item show logging [active|file|overwrite|redirect|debugredirect]
+Show the current value of the logging setting.
 @item show logging
 Show the current values of the logging settings.
 @end table

base-commit: 0c3e266dc283a45a23185be3bb49e4d33987a892
-- 
2.26.2


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

* [PATCH] [gdb/cli] Add command: show logging active
  2021-11-23 11:46 [pushed] [gdb/cli] Add command: show logging active Tom de Vries
@ 2021-11-23 11:49 ` Tom de Vries
  2021-11-23 12:30   ` Lancelot SIX
                     ` (2 more replies)
  2021-11-23 12:49 ` [pushed] " Luis Machado
  1 sibling, 3 replies; 12+ messages in thread
From: Tom de Vries @ 2021-11-23 11:49 UTC (permalink / raw)
  To: gdb-patches, Eli Zaretskii

[was: [pushed] [gdb/cli] Add command: show logging active ]

Sorry, this has not been pushed yet, correcting $subject to request review.

Thanks,
- Tom

On 11/23/21 12:46 PM, Tom de Vries via Gdb-patches wrote:
> Currently, there's no gdb command that shows whether logging is enabled or
> disabled.
> 
> There's the show logging command, but output is identical in both cases.
> With logging disabled, we have:
> ...
> (gdb) set logging off
> (gdb) show logging
> logging debugredirect:  The logging output mode is off.
> logging file:  The current logfile is "gdb.txt".
> logging overwrite: \
>   Whether logging overwrites or appends to the log file is off.
> logging redirect:  The logging output mode is off.
> ...
> and with logging enabled we have:
> ...
> (gdb) set logging on
> Copying output to gdb.txt.
> Copying debug output to gdb.txt.
> (gdb) show logging
> logging debugredirect:  The logging output mode is off.
> logging file:  The current logfile is "gdb.txt".
> logging overwrite: \
>   Whether logging overwrites or appends to the log file is off.
> logging redirect:  The logging output mode is off.
> ...
> 
> Add a "show logging active" command, such that we have:
> ...
> (gdb) show logging
> logging active:  Logging is disabled.
> logging debugredirect:  The logging output mode is off.
> logging file:  The current logfile is "gdb.txt".
> logging overwrite: \
>   Whether logging overwrites or appends to the log file is off.
> logging redirect:  The logging output mode is off.
> ...
> 
> Mention the new command in NEWS and docs.
> 
> Tested on x86_64-linux.
> ---
>  gdb/NEWS              |  5 +++++
>  gdb/cli/cli-logging.c | 13 +++++++++++++
>  gdb/doc/gdb.texinfo   |  2 ++
>  3 files changed, 20 insertions(+)
> 
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 9e950d2f80d..253070a2a57 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -32,6 +32,11 @@ maint show internal-warning backtrace
>    internal-error, or an internal-warning.  This is on by default for
>    internal-error and off by default for internal-warning.
>  
> +show logging active
> +  This command shows whether logging is enabled or disabled.  Whether logging
> +  is enabled or disabled is controlled by pre-existing command
> +  "set logging [on|off]".
> +
>  * Python API
>  
>    ** New function gdb.add_history(), which takes a gdb.Value object
> diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c
> index f0ee09180f9..081afcc4ca2 100644
> --- a/gdb/cli/cli-logging.c
> +++ b/gdb/cli/cli-logging.c
> @@ -163,6 +163,17 @@ set_logging_off (const char *args, int from_tty)
>    saved_filename = NULL;
>  }
>  
> +/* Show the status set by set_logging_on / set_logging_off.  */
> +
> +static void
> +show_logging_on_off (const char *args, int from_tty)
> +{
> +  if (saved_filename)
> +    printf_unfiltered (_("Logging is enabled.\n"));
> +  else
> +    printf_unfiltered (_("Logging is disabled.\n"));
> +}
> +
>  void _initialize_cli_logging ();
>  void
>  _initialize_cli_logging ()
> @@ -211,4 +222,6 @@ The logfile is used when directing GDB's output."),
>  	   _("Enable logging."), &set_logging_cmdlist);
>    add_cmd ("off", class_support, set_logging_off,
>  	   _("Disable logging."), &set_logging_cmdlist);
> +  add_cmd ("active", class_support, show_logging_on_off,
> +	   _("Show whether logging is active."), &show_logging_cmdlist);
>  }
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 1b13973cdc5..4bea8f9b3dc 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -1723,6 +1723,8 @@ Set @code{redirect} if you want output to go only to the log file.
>  By default, @value{GDBN} debug output will go to both the terminal and the logfile.
>  Set @code{debugredirect} if you want debug output to go only to the log file.
>  @kindex show logging
> +@item show logging [active|file|overwrite|redirect|debugredirect]
> +Show the current value of the logging setting.
>  @item show logging
>  Show the current values of the logging settings.
>  @end table
> 
> base-commit: 0c3e266dc283a45a23185be3bb49e4d33987a892
> 

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

* Re: [PATCH] [gdb/cli] Add command: show logging active
  2021-11-23 11:49 ` [PATCH] " Tom de Vries
@ 2021-11-23 12:30   ` Lancelot SIX
  2021-11-24 10:31     ` Tom de Vries
  2021-11-23 13:00   ` Eli Zaretskii
  2021-11-23 13:30   ` Simon Marchi
  2 siblings, 1 reply; 12+ messages in thread
From: Lancelot SIX @ 2021-11-23 12:30 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches, Eli Zaretskii

> > ---
> >  gdb/NEWS              |  5 +++++
> >  gdb/cli/cli-logging.c | 13 +++++++++++++
> >  gdb/doc/gdb.texinfo   |  2 ++
> >  3 files changed, 20 insertions(+)
> > 
> > diff --git a/gdb/NEWS b/gdb/NEWS
> > index 9e950d2f80d..253070a2a57 100644
> > --- a/gdb/NEWS
> > +++ b/gdb/NEWS
> > @@ -32,6 +32,11 @@ maint show internal-warning backtrace
> >    internal-error, or an internal-warning.  This is on by default for
> >    internal-error and off by default for internal-warning.
> >  
> > +show logging active
> > +  This command shows whether logging is enabled or disabled.  Whether logging
> > +  is enabled or disabled is controlled by pre-existing command
> > +  "set logging [on|off]".
> > +
> >  * Python API
> >  
> >    ** New function gdb.add_history(), which takes a gdb.Value object
> > diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c
> > index f0ee09180f9..081afcc4ca2 100644
> > --- a/gdb/cli/cli-logging.c
> > +++ b/gdb/cli/cli-logging.c
> > @@ -163,6 +163,17 @@ set_logging_off (const char *args, int from_tty)
> >    saved_filename = NULL;
> >  }
> >  
> > +/* Show the status set by set_logging_on / set_logging_off.  */
> > +
> > +static void
> > +show_logging_on_off (const char *args, int from_tty)
> > +{
> > +  if (saved_filename)

Hi,

I just have a minor styling remark.  This should be:

  if (saved_filename != nullptr)

Shouldn't it?

Best,
Lancelot.

> > +    printf_unfiltered (_("Logging is enabled.\n"));
> > +  else
> > +    printf_unfiltered (_("Logging is disabled.\n"));
> > +}
> > +
> >  void _initialize_cli_logging ();
> >  void
> >  _initialize_cli_logging ()
> > @@ -211,4 +222,6 @@ The logfile is used when directing GDB's output."),
> >  	   _("Enable logging."), &set_logging_cmdlist);
> >    add_cmd ("off", class_support, set_logging_off,
> >  	   _("Disable logging."), &set_logging_cmdlist);
> > +  add_cmd ("active", class_support, show_logging_on_off,
> > +	   _("Show whether logging is active."), &show_logging_cmdlist);
> >  }
> > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> > index 1b13973cdc5..4bea8f9b3dc 100644
> > --- a/gdb/doc/gdb.texinfo
> > +++ b/gdb/doc/gdb.texinfo
> > @@ -1723,6 +1723,8 @@ Set @code{redirect} if you want output to go only to the log file.
> >  By default, @value{GDBN} debug output will go to both the terminal and the logfile.
> >  Set @code{debugredirect} if you want debug output to go only to the log file.
> >  @kindex show logging
> > +@item show logging [active|file|overwrite|redirect|debugredirect]
> > +Show the current value of the logging setting.
> >  @item show logging
> >  Show the current values of the logging settings.
> >  @end table
> > 
> > base-commit: 0c3e266dc283a45a23185be3bb49e4d33987a892
> > 

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

* Re: [pushed] [gdb/cli] Add command: show logging active
  2021-11-23 11:46 [pushed] [gdb/cli] Add command: show logging active Tom de Vries
  2021-11-23 11:49 ` [PATCH] " Tom de Vries
@ 2021-11-23 12:49 ` Luis Machado
  2021-11-23 12:56   ` Luis Machado
  1 sibling, 1 reply; 12+ messages in thread
From: Luis Machado @ 2021-11-23 12:49 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches, Eli Zaretskii

On 11/23/21 8:46 AM, Tom de Vries via Gdb-patches wrote:
> Currently, there's no gdb command that shows whether logging is enabled or
> disabled.
> 
> There's the show logging command, but output is identical in both cases.
> With logging disabled, we have:
> ...
> (gdb) set logging off
> (gdb) show logging
> logging debugredirect:  The logging output mode is off.
> logging file:  The current logfile is "gdb.txt".
> logging overwrite: \
>    Whether logging overwrites or appends to the log file is off.
> logging redirect:  The logging output mode is off.
> ...
> and with logging enabled we have:
> ...
> (gdb) set logging on
> Copying output to gdb.txt.
> Copying debug output to gdb.txt.
> (gdb) show logging
> logging debugredirect:  The logging output mode is off.
> logging file:  The current logfile is "gdb.txt".
> logging overwrite: \
>    Whether logging overwrites or appends to the log file is off.
> logging redirect:  The logging output mode is off.
> ...
> 
> Add a "show logging active" command, such that we have:
> ...
> (gdb) show logging
> logging active:  Logging is disabled.
> logging debugredirect:  The logging output mode is off.
> logging file:  The current logfile is "gdb.txt".
> logging overwrite: \
>    Whether logging overwrites or appends to the log file is off.
> logging redirect:  The logging output mode is off.
> ...

Sorry, I think these phrases need a revamp. The current text is very 
confusing. I've cc-ed Eli for some feedback on documentation.

"logging active:  Logging is disabled." reads very funny. Is logging 
active? Or is it disabled? Why can't it say "Logging is active" or 
"Logging is not active"?

I think the same goes to some of the other lines.

* "logging debugredirect:  The logging output mode is off."

Why not say "Debug is not being redirected." or "Debug is being 
redirected."?

* "logging overwrite: Whether logging overwrites or appends to the log 
file is off."

Why not say "Logging overwrites contents of the log file" or "Logging 
appends to the log file".

* "logging redirect:  The logging output mode is off."

I find the above cryptic as well. Why not "Log redirects <something>".

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

* Re: [pushed] [gdb/cli] Add command: show logging active
  2021-11-23 12:49 ` [pushed] " Luis Machado
@ 2021-11-23 12:56   ` Luis Machado
  2021-11-24 10:32     ` Tom de Vries
  0 siblings, 1 reply; 12+ messages in thread
From: Luis Machado @ 2021-11-23 12:56 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches, Eli Zaretskii

On 11/23/21 9:49 AM, Luis Machado wrote:
> On 11/23/21 8:46 AM, Tom de Vries via Gdb-patches wrote:
>> Currently, there's no gdb command that shows whether logging is 
>> enabled or
>> disabled.
>>
>> There's the show logging command, but output is identical in both cases.
>> With logging disabled, we have:
>> ...
>> (gdb) set logging off
>> (gdb) show logging
>> logging debugredirect:  The logging output mode is off.
>> logging file:  The current logfile is "gdb.txt".
>> logging overwrite: \
>>    Whether logging overwrites or appends to the log file is off.
>> logging redirect:  The logging output mode is off.
>> ...
>> and with logging enabled we have:
>> ...
>> (gdb) set logging on
>> Copying output to gdb.txt.
>> Copying debug output to gdb.txt.
>> (gdb) show logging
>> logging debugredirect:  The logging output mode is off.
>> logging file:  The current logfile is "gdb.txt".
>> logging overwrite: \
>>    Whether logging overwrites or appends to the log file is off.
>> logging redirect:  The logging output mode is off.
>> ...
>>
>> Add a "show logging active" command, such that we have:
>> ...
>> (gdb) show logging
>> logging active:  Logging is disabled.
>> logging debugredirect:  The logging output mode is off.
>> logging file:  The current logfile is "gdb.txt".
>> logging overwrite: \
>>    Whether logging overwrites or appends to the log file is off.
>> logging redirect:  The logging output mode is off.
>> ...
> 
> Sorry, I think these phrases need a revamp. The current text is very 
> confusing. I've cc-ed Eli for some feedback on documentation.
> 
> "logging active:  Logging is disabled." reads very funny. Is logging 
> active? Or is it disabled? Why can't it say "Logging is active" or 
> "Logging is not active"?
> 
> I think the same goes to some of the other lines.
> 
> * "logging debugredirect:  The logging output mode is off."
> 
> Why not say "Debug is not being redirected." or "Debug is being 
> redirected."?
> 
> * "logging overwrite: Whether logging overwrites or appends to the log 
> file is off."
> 
> Why not say "Logging overwrites contents of the log file" or "Logging 
> appends to the log file".
> 
> * "logging redirect:  The logging output mode is off."
> 
> I find the above cryptic as well. Why not "Log redirects <something>".

I just noticed these messages changed relatively recently. An older GDB 
would show the following:

Future logs will be written to gdb.txt.
Logs will be appended to the log file.
Output will be logged and displayed.
Debug output will be logged and displayed.

The above is much clearer in my opinion. The newer ones seem very 
cryptic. It almost looks like a documentation regression, though I can 
understand that the code is probably simpler.

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

* Re: [PATCH] [gdb/cli] Add command: show logging active
  2021-11-23 11:49 ` [PATCH] " Tom de Vries
  2021-11-23 12:30   ` Lancelot SIX
@ 2021-11-23 13:00   ` Eli Zaretskii
  2021-11-24 10:41     ` Tom de Vries
  2021-11-23 13:30   ` Simon Marchi
  2 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2021-11-23 13:00 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

> From: Tom de Vries <tdevries@suse.de>
> Date: Tue, 23 Nov 2021 12:49:34 +0100
> 
> > Currently, there's no gdb command that shows whether logging is enabled or
> > disabled.
> > 
> > There's the show logging command, but output is identical in both cases.
> > With logging disabled, we have:
> > ...
> > (gdb) set logging off
> > (gdb) show logging
> > logging debugredirect:  The logging output mode is off.
> > logging file:  The current logfile is "gdb.txt".
> > logging overwrite: \
> >   Whether logging overwrites or appends to the log file is off.
> > logging redirect:  The logging output mode is off.
> > ...
> > and with logging enabled we have:
> > ...
> > (gdb) set logging on
> > Copying output to gdb.txt.
> > Copying debug output to gdb.txt.
> > (gdb) show logging
> > logging debugredirect:  The logging output mode is off.
> > logging file:  The current logfile is "gdb.txt".
> > logging overwrite: \
> >   Whether logging overwrites or appends to the log file is off.
> > logging redirect:  The logging output mode is off.
> > ...
> > 
> > Add a "show logging active" command, such that we have:
> > ...
> > (gdb) show logging
> > logging active:  Logging is disabled.
> > logging debugredirect:  The logging output mode is off.
> > logging file:  The current logfile is "gdb.txt".
> > logging overwrite: \
> >   Whether logging overwrites or appends to the log file is off.
> > logging redirect:  The logging output mode is off.
> > ...

Isn't the current behavior a bug that should be fixed, instead of
introducing a new command?  Or what am I missing?

The documentation part is OK, assuming that we do want a new
sub-command.

Thanks.

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

* Re: [PATCH] [gdb/cli] Add command: show logging active
  2021-11-23 11:49 ` [PATCH] " Tom de Vries
  2021-11-23 12:30   ` Lancelot SIX
  2021-11-23 13:00   ` Eli Zaretskii
@ 2021-11-23 13:30   ` Simon Marchi
  2021-11-24 11:06     ` Tom de Vries
  2 siblings, 1 reply; 12+ messages in thread
From: Simon Marchi @ 2021-11-23 13:30 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches, Eli Zaretskii

On 2021-11-23 06:49, Tom de Vries via Gdb-patches wrote:
> [was: [pushed] [gdb/cli] Add command: show logging active ]
> 
> Sorry, this has not been pushed yet, correcting $subject to request review.
> 
> Thanks,
> - Tom
> 
> On 11/23/21 12:46 PM, Tom de Vries via Gdb-patches wrote:
>> Currently, there's no gdb command that shows whether logging is enabled or
>> disabled.
>>
>> There's the show logging command, but output is identical in both cases.
>> With logging disabled, we have:
>> ...
>> (gdb) set logging off
>> (gdb) show logging
>> logging debugredirect:  The logging output mode is off.
>> logging file:  The current logfile is "gdb.txt".
>> logging overwrite: \
>>   Whether logging overwrites or appends to the log file is off.
>> logging redirect:  The logging output mode is off.
>> ...
>> and with logging enabled we have:
>> ...
>> (gdb) set logging on
>> Copying output to gdb.txt.
>> Copying debug output to gdb.txt.
>> (gdb) show logging
>> logging debugredirect:  The logging output mode is off.
>> logging file:  The current logfile is "gdb.txt".
>> logging overwrite: \
>>   Whether logging overwrites or appends to the log file is off.
>> logging redirect:  The logging output mode is off.
>> ...
>>
>> Add a "show logging active" command, such that we have:
>> ...
>> (gdb) show logging
>> logging active:  Logging is disabled.
>> logging debugredirect:  The logging output mode is off.
>> logging file:  The current logfile is "gdb.txt".
>> logging overwrite: \
>>   Whether logging overwrites or appends to the log file is off.
>> logging redirect:  The logging output mode is off.
>> ...
>>
>> Mention the new command in NEWS and docs.
>>
>> Tested on x86_64-linux.

This looks a whole lot like what we discussed for "set debuginfod"  and
"set index-cache" recently.  See:

https://sourceware.org/pipermail/gdb-patches/2021-October/182937.html

We then made the following changes.  Add the "set index-cache enabled
on/off" setting, and make "set index-cache on/off" deprecated aliases of
that:

https://gitlab.com/gnutools/binutils-gdb/-/commit/7bc5c369fae6dda3657467aee14e352a66b4270f

Change "set debuginfod on/off" to "set debuginfod enabled on/off",
without aliases because it was never released:

https://gitlab.com/gnutools/binutils-gdb/-/commit/333f35b6315f6ed71db4fb76bfc1ebb7ec347d43

So, I would suggest doing the same as I did with index-cache, make "set
logging on/off" deprecated aliases of a new "set logging enabled on/off"
setting.

Simon

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

* Re: [PATCH] [gdb/cli] Add command: show logging active
  2021-11-23 12:30   ` Lancelot SIX
@ 2021-11-24 10:31     ` Tom de Vries
  0 siblings, 0 replies; 12+ messages in thread
From: Tom de Vries @ 2021-11-24 10:31 UTC (permalink / raw)
  To: Lancelot SIX; +Cc: gdb-patches, Eli Zaretskii

On 11/23/21 1:30 PM, Lancelot SIX wrote:
>>> ---
>>>  gdb/NEWS              |  5 +++++
>>>  gdb/cli/cli-logging.c | 13 +++++++++++++
>>>  gdb/doc/gdb.texinfo   |  2 ++
>>>  3 files changed, 20 insertions(+)
>>>
>>> diff --git a/gdb/NEWS b/gdb/NEWS
>>> index 9e950d2f80d..253070a2a57 100644
>>> --- a/gdb/NEWS
>>> +++ b/gdb/NEWS
>>> @@ -32,6 +32,11 @@ maint show internal-warning backtrace
>>>    internal-error, or an internal-warning.  This is on by default for
>>>    internal-error and off by default for internal-warning.
>>>  
>>> +show logging active
>>> +  This command shows whether logging is enabled or disabled.  Whether logging
>>> +  is enabled or disabled is controlled by pre-existing command
>>> +  "set logging [on|off]".
>>> +
>>>  * Python API
>>>  
>>>    ** New function gdb.add_history(), which takes a gdb.Value object
>>> diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c
>>> index f0ee09180f9..081afcc4ca2 100644
>>> --- a/gdb/cli/cli-logging.c
>>> +++ b/gdb/cli/cli-logging.c
>>> @@ -163,6 +163,17 @@ set_logging_off (const char *args, int from_tty)
>>>    saved_filename = NULL;
>>>  }
>>>  
>>> +/* Show the status set by set_logging_on / set_logging_off.  */
>>> +
>>> +static void
>>> +show_logging_on_off (const char *args, int from_tty)
>>> +{
>>> +  if (saved_filename)
> 
> Hi,
> 
> I just have a minor styling remark.  This should be:
> 
>   if (saved_filename != nullptr)
> 
> Shouldn't it?
> 

It should, thanks for noticing.  Anyway, in the new submission (
https://sourceware.org/pipermail/gdb-patches/2021-November/183749.html )
this test no longer occurs.

Thanks,
- Tom

> Best,
> Lancelot.
> 
>>> +    printf_unfiltered (_("Logging is enabled.\n"));
>>> +  else
>>> +    printf_unfiltered (_("Logging is disabled.\n"));
>>> +}
>>> +
>>>  void _initialize_cli_logging ();
>>>  void
>>>  _initialize_cli_logging ()
>>> @@ -211,4 +222,6 @@ The logfile is used when directing GDB's output."),
>>>  	   _("Enable logging."), &set_logging_cmdlist);
>>>    add_cmd ("off", class_support, set_logging_off,
>>>  	   _("Disable logging."), &set_logging_cmdlist);
>>> +  add_cmd ("active", class_support, show_logging_on_off,
>>> +	   _("Show whether logging is active."), &show_logging_cmdlist);
>>>  }
>>> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
>>> index 1b13973cdc5..4bea8f9b3dc 100644
>>> --- a/gdb/doc/gdb.texinfo
>>> +++ b/gdb/doc/gdb.texinfo
>>> @@ -1723,6 +1723,8 @@ Set @code{redirect} if you want output to go only to the log file.
>>>  By default, @value{GDBN} debug output will go to both the terminal and the logfile.
>>>  Set @code{debugredirect} if you want debug output to go only to the log file.
>>>  @kindex show logging
>>> +@item show logging [active|file|overwrite|redirect|debugredirect]
>>> +Show the current value of the logging setting.
>>>  @item show logging
>>>  Show the current values of the logging settings.
>>>  @end table
>>>
>>> base-commit: 0c3e266dc283a45a23185be3bb49e4d33987a892
>>>

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

* Re: [pushed] [gdb/cli] Add command: show logging active
  2021-11-23 12:56   ` Luis Machado
@ 2021-11-24 10:32     ` Tom de Vries
  0 siblings, 0 replies; 12+ messages in thread
From: Tom de Vries @ 2021-11-24 10:32 UTC (permalink / raw)
  To: Luis Machado, gdb-patches, Eli Zaretskii

On 11/23/21 1:56 PM, Luis Machado wrote:
> On 11/23/21 9:49 AM, Luis Machado wrote:
>> On 11/23/21 8:46 AM, Tom de Vries via Gdb-patches wrote:
>>> Currently, there's no gdb command that shows whether logging is
>>> enabled or
>>> disabled.
>>>
>>> There's the show logging command, but output is identical in both cases.
>>> With logging disabled, we have:
>>> ...
>>> (gdb) set logging off
>>> (gdb) show logging
>>> logging debugredirect:  The logging output mode is off.
>>> logging file:  The current logfile is "gdb.txt".
>>> logging overwrite: \
>>>    Whether logging overwrites or appends to the log file is off.
>>> logging redirect:  The logging output mode is off.
>>> ...
>>> and with logging enabled we have:
>>> ...
>>> (gdb) set logging on
>>> Copying output to gdb.txt.
>>> Copying debug output to gdb.txt.
>>> (gdb) show logging
>>> logging debugredirect:  The logging output mode is off.
>>> logging file:  The current logfile is "gdb.txt".
>>> logging overwrite: \
>>>    Whether logging overwrites or appends to the log file is off.
>>> logging redirect:  The logging output mode is off.
>>> ...
>>>
>>> Add a "show logging active" command, such that we have:
>>> ...
>>> (gdb) show logging
>>> logging active:  Logging is disabled.
>>> logging debugredirect:  The logging output mode is off.
>>> logging file:  The current logfile is "gdb.txt".
>>> logging overwrite: \
>>>    Whether logging overwrites or appends to the log file is off.
>>> logging redirect:  The logging output mode is off.
>>> ...
>>
>> Sorry, I think these phrases need a revamp. The current text is very
>> confusing. I've cc-ed Eli for some feedback on documentation.
>>
>> "logging active:  Logging is disabled." reads very funny. Is logging
>> active? Or is it disabled? Why can't it say "Logging is active" or
>> "Logging is not active"?
>>
>> I think the same goes to some of the other lines.
>>
>> * "logging debugredirect:  The logging output mode is off."
>>
>> Why not say "Debug is not being redirected." or "Debug is being
>> redirected."?
>>
>> * "logging overwrite: Whether logging overwrites or appends to the log
>> file is off."
>>
>> Why not say "Logging overwrites contents of the log file" or "Logging
>> appends to the log file".
>>
>> * "logging redirect:  The logging output mode is off."
>>
>> I find the above cryptic as well. Why not "Log redirects <something>".
> 
> I just noticed these messages changed relatively recently. An older GDB
> would show the following:
> 
> Future logs will be written to gdb.txt.
> Logs will be appended to the log file.
> Output will be logged and displayed.
> Debug output will be logged and displayed.
> 
> The above is much clearer in my opinion. The newer ones seem very
> cryptic. It almost looks like a documentation regression, though I can
> understand that the code is probably simpler.

I've tried to address these issues here (
https://sourceware.org/pipermail/gdb-patches/2021-November/183750.html ).

Thanks,
- Tom

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

* Re: [PATCH] [gdb/cli] Add command: show logging active
  2021-11-23 13:00   ` Eli Zaretskii
@ 2021-11-24 10:41     ` Tom de Vries
  2021-11-24 13:03       ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Tom de Vries @ 2021-11-24 10:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On 11/23/21 2:00 PM, Eli Zaretskii wrote:
>> From: Tom de Vries <tdevries@suse.de>
>> Date: Tue, 23 Nov 2021 12:49:34 +0100
>>
>>> Currently, there's no gdb command that shows whether logging is enabled or
>>> disabled.
>>>
>>> There's the show logging command, but output is identical in both cases.
>>> With logging disabled, we have:
>>> ...
>>> (gdb) set logging off
>>> (gdb) show logging
>>> logging debugredirect:  The logging output mode is off.
>>> logging file:  The current logfile is "gdb.txt".
>>> logging overwrite: \
>>>   Whether logging overwrites or appends to the log file is off.
>>> logging redirect:  The logging output mode is off.
>>> ...
>>> and with logging enabled we have:
>>> ...
>>> (gdb) set logging on
>>> Copying output to gdb.txt.
>>> Copying debug output to gdb.txt.
>>> (gdb) show logging
>>> logging debugredirect:  The logging output mode is off.
>>> logging file:  The current logfile is "gdb.txt".
>>> logging overwrite: \
>>>   Whether logging overwrites or appends to the log file is off.
>>> logging redirect:  The logging output mode is off.
>>> ...
>>>
>>> Add a "show logging active" command, such that we have:
>>> ...
>>> (gdb) show logging
>>> logging active:  Logging is disabled.
>>> logging debugredirect:  The logging output mode is off.
>>> logging file:  The current logfile is "gdb.txt".
>>> logging overwrite: \
>>>   Whether logging overwrites or appends to the log file is off.
>>> logging redirect:  The logging output mode is off.
>>> ...
> 
> Isn't the current behavior a bug that should be fixed, instead of
> introducing a new command?  Or what am I missing?
> 

Well, AFAIU the bug is that we can't see whether logging is enabled or
not, and adding the new command fixes that bug.

Normally, a command "set logging on/off" would have a counterpart "show
logging" that shows the effects of the command, but in this case "show
logging" shows the status of the subcommands only.

In the latest version, this is fixed by deprecating "set logging on/off"
and replacing it with "set logging enabled on/off", which does have a
direct show counterpart.

I hope this answers you question.

> The documentation part is OK, assuming that we do want a new
> sub-command.

Thanks for the review.  Could you also review the new version here (
https://sourceware.org/pipermail/gdb-patches/2021-November/183749.html ) ?

Thanks,
- Tom

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

* Re: [PATCH] [gdb/cli] Add command: show logging active
  2021-11-23 13:30   ` Simon Marchi
@ 2021-11-24 11:06     ` Tom de Vries
  0 siblings, 0 replies; 12+ messages in thread
From: Tom de Vries @ 2021-11-24 11:06 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches, Eli Zaretskii

On 11/23/21 2:30 PM, Simon Marchi wrote:
> On 2021-11-23 06:49, Tom de Vries via Gdb-patches wrote:
>> [was: [pushed] [gdb/cli] Add command: show logging active ]
>>
>> Sorry, this has not been pushed yet, correcting $subject to request review.
>>
>> Thanks,
>> - Tom
>>
>> On 11/23/21 12:46 PM, Tom de Vries via Gdb-patches wrote:
>>> Currently, there's no gdb command that shows whether logging is enabled or
>>> disabled.
>>>
>>> There's the show logging command, but output is identical in both cases.
>>> With logging disabled, we have:
>>> ...
>>> (gdb) set logging off
>>> (gdb) show logging
>>> logging debugredirect:  The logging output mode is off.
>>> logging file:  The current logfile is "gdb.txt".
>>> logging overwrite: \
>>>   Whether logging overwrites or appends to the log file is off.
>>> logging redirect:  The logging output mode is off.
>>> ...
>>> and with logging enabled we have:
>>> ...
>>> (gdb) set logging on
>>> Copying output to gdb.txt.
>>> Copying debug output to gdb.txt.
>>> (gdb) show logging
>>> logging debugredirect:  The logging output mode is off.
>>> logging file:  The current logfile is "gdb.txt".
>>> logging overwrite: \
>>>   Whether logging overwrites or appends to the log file is off.
>>> logging redirect:  The logging output mode is off.
>>> ...
>>>
>>> Add a "show logging active" command, such that we have:
>>> ...
>>> (gdb) show logging
>>> logging active:  Logging is disabled.
>>> logging debugredirect:  The logging output mode is off.
>>> logging file:  The current logfile is "gdb.txt".
>>> logging overwrite: \
>>>   Whether logging overwrites or appends to the log file is off.
>>> logging redirect:  The logging output mode is off.
>>> ...
>>>
>>> Mention the new command in NEWS and docs.
>>>
>>> Tested on x86_64-linux.
> 
> This looks a whole lot like what we discussed for "set debuginfod"  and
> "set index-cache" recently.  See:
> 
> https://sourceware.org/pipermail/gdb-patches/2021-October/182937.html
> 
> We then made the following changes.  Add the "set index-cache enabled
> on/off" setting, and make "set index-cache on/off" deprecated aliases of
> that:
> 
> https://gitlab.com/gnutools/binutils-gdb/-/commit/7bc5c369fae6dda3657467aee14e352a66b4270f
> 
> Change "set debuginfod on/off" to "set debuginfod enabled on/off",
> without aliases because it was never released:
> 
> https://gitlab.com/gnutools/binutils-gdb/-/commit/333f35b6315f6ed71db4fb76bfc1ebb7ec347d43
> 
> So, I would suggest doing the same as I did with index-cache, make "set
> logging on/off" deprecated aliases of a new "set logging enabled on/off"
> setting.

Done (
https://sourceware.org/pipermail/gdb-patches/2021-November/183749.html
), though I see now that I've copied the "help doc" ;) .

Proposed a fixup here (
https://sourceware.org/pipermail/gdb-patches/2021-November/183759.html ).

Thanks,
- Tom


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

* Re: [PATCH] [gdb/cli] Add command: show logging active
  2021-11-24 10:41     ` Tom de Vries
@ 2021-11-24 13:03       ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2021-11-24 13:03 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

> Cc: gdb-patches@sourceware.org
> From: Tom de Vries <tdevries@suse.de>
> Date: Wed, 24 Nov 2021 11:41:41 +0100
> 
> Thanks for the review.  Could you also review the new version here (
> https://sourceware.org/pipermail/gdb-patches/2021-November/183749.html ) ?

It's okay.

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

end of thread, other threads:[~2021-11-24 13:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 11:46 [pushed] [gdb/cli] Add command: show logging active Tom de Vries
2021-11-23 11:49 ` [PATCH] " Tom de Vries
2021-11-23 12:30   ` Lancelot SIX
2021-11-24 10:31     ` Tom de Vries
2021-11-23 13:00   ` Eli Zaretskii
2021-11-24 10:41     ` Tom de Vries
2021-11-24 13:03       ` Eli Zaretskii
2021-11-23 13:30   ` Simon Marchi
2021-11-24 11:06     ` Tom de Vries
2021-11-23 12:49 ` [pushed] " Luis Machado
2021-11-23 12:56   ` Luis Machado
2021-11-24 10:32     ` Tom de Vries

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