Use filename style in "show" commands

Message ID 20250113212120.341372-1-tom@tromey.com
State New
Headers
Series Use filename style in "show" commands |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom Tromey Jan. 13, 2025, 9:21 p.m. UTC
  I found a few filename-related "show" commands that do not use the
filename style when displaying the file.  This patch fixes the
oversight.
---
 gdb/cli/cli-setshow.c     | 9 +++++++--
 gdb/target-descriptions.c | 5 +++--
 2 files changed, 10 insertions(+), 4 deletions(-)
  

Comments

Andrew Burgess Jan. 14, 2025, 6:06 p.m. UTC | #1
Tom Tromey <tom@tromey.com> writes:

> I found a few filename-related "show" commands that do not use the
> filename style when displaying the file.  This patch fixes the
> oversight.

LGTM.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

> ---
>  gdb/cli/cli-setshow.c     | 9 +++++++--
>  gdb/target-descriptions.c | 5 +++--
>  2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
> index a8f22c9bde6..73b52253f5a 100644
> --- a/gdb/cli/cli-setshow.c
> +++ b/gdb/cli/cli-setshow.c
> @@ -27,6 +27,7 @@
>  #include "cli/cli-decode.h"
>  #include "cli/cli-cmds.h"
>  #include "cli/cli-setshow.h"
> +#include "cli/cli-style.h"
>  #include "cli/cli-utils.h"
>  
>  /* Return true if the change of command parameter should be notified.  */
> @@ -137,12 +138,16 @@ deprecated_show_value_hack (struct ui_file *ignore_file,
>      {
>      case var_string:
>      case var_string_noescape:
> -    case var_optional_filename:
> -    case var_filename:
>      case var_enum:
>        gdb_printf ((" is \"%s\".\n"), value);
>        break;
>  
> +    case var_optional_filename:
> +    case var_filename:
> +      gdb_printf ((" is \"%ps\".\n"),
> +		  styled_string (file_name_style.style (), value));
> +      break;
> +
>      default:
>        gdb_printf ((" is %s.\n"), value);
>        break;
> diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
> index 3ee8a751f3b..1d35e4d4ac9 100644
> --- a/gdb/target-descriptions.c
> +++ b/gdb/target-descriptions.c
> @@ -35,6 +35,7 @@
>  #include <algorithm>
>  #include "completer.h"
>  #include "readline/tilde.h"
> +#include "cli/cli-style.h"
>  
>  /* Types.  */
>  
> @@ -1230,8 +1231,8 @@ show_tdesc_filename_cmd (struct ui_file *file, int from_tty,
>  
>    if (value != NULL && *value != '\0')
>      gdb_printf (file,
> -		_("The target description will be read from \"%s\".\n"),
> -		value);
> +		_("The target description will be read from \"%ps\".\n"),
> +		styled_string (file_name_style.style (), value));
>    else
>      gdb_printf (file,
>  		_("The target description will be "
> -- 
> 2.46.1
  

Patch

diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index a8f22c9bde6..73b52253f5a 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -27,6 +27,7 @@ 
 #include "cli/cli-decode.h"
 #include "cli/cli-cmds.h"
 #include "cli/cli-setshow.h"
+#include "cli/cli-style.h"
 #include "cli/cli-utils.h"
 
 /* Return true if the change of command parameter should be notified.  */
@@ -137,12 +138,16 @@  deprecated_show_value_hack (struct ui_file *ignore_file,
     {
     case var_string:
     case var_string_noescape:
-    case var_optional_filename:
-    case var_filename:
     case var_enum:
       gdb_printf ((" is \"%s\".\n"), value);
       break;
 
+    case var_optional_filename:
+    case var_filename:
+      gdb_printf ((" is \"%ps\".\n"),
+		  styled_string (file_name_style.style (), value));
+      break;
+
     default:
       gdb_printf ((" is %s.\n"), value);
       break;
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 3ee8a751f3b..1d35e4d4ac9 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -35,6 +35,7 @@ 
 #include <algorithm>
 #include "completer.h"
 #include "readline/tilde.h"
+#include "cli/cli-style.h"
 
 /* Types.  */
 
@@ -1230,8 +1231,8 @@  show_tdesc_filename_cmd (struct ui_file *file, int from_tty,
 
   if (value != NULL && *value != '\0')
     gdb_printf (file,
-		_("The target description will be read from \"%s\".\n"),
-		value);
+		_("The target description will be read from \"%ps\".\n"),
+		styled_string (file_name_style.style (), value));
   else
     gdb_printf (file,
 		_("The target description will be "