]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Style filenames in cli-logging.c
authorTom Tromey <tom@tromey.com>
Fri, 16 Jan 2026 16:21:25 +0000 (09:21 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 9 Feb 2026 15:16:06 +0000 (08:16 -0700)
Andrew pointed out that some code in cli-logging.c should use the
filename style.  This patch fixes these spots.

Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/cli/cli-logging.c
gdb/testsuite/gdb.base/style.exp

index 836c24445bcd0ab35e52fe460c7c400a2bde0300..38c16fbf18fd62d2481be7002127bcf0a087da90 100644 (file)
@@ -30,8 +30,10 @@ static void
 maybe_warn_already_logging ()
 {
   if (!saved_filename.empty ())
-    warning (_("Currently logging to %s.  Turn the logging off and on to "
-              "make the new setting effective."), saved_filename.c_str ());
+    warning (_("Currently logging to %ps.  Turn the logging off and on to "
+              "make the new setting effective."),
+            styled_string (file_name_style.style (),
+                           saved_filename.c_str ()));
 }
 
 static std::string logging_filename = "gdb.txt";
@@ -227,8 +229,9 @@ handle_redirections (int from_tty)
 {
   if (!saved_filename.empty ())
     {
-      gdb_printf ("Already logging to %s.\n",
-                 saved_filename.c_str ());
+      gdb_printf ("Already logging to %ps.\n",
+                 styled_string (file_name_style.style (),
+                                saved_filename.c_str ()));
       return;
     }
 
@@ -240,18 +243,22 @@ handle_redirections (int from_tty)
   if (from_tty)
     {
       if (!logging_redirect)
-       gdb_printf ("Copying output to %s.\n",
-                   logging_filename.c_str ());
+       gdb_printf ("Copying output to %ps.\n",
+                   styled_string (file_name_style.style (),
+                                  logging_filename.c_str ()));
       else
-       gdb_printf ("Redirecting output to %s.\n",
-                   logging_filename.c_str ());
+       gdb_printf ("Redirecting output to %ps.\n",
+                   styled_string (file_name_style.style (),
+                                  logging_filename.c_str ()));
 
       if (!debug_redirect)
-       gdb_printf ("Copying debug output to %s.\n",
-                   logging_filename.c_str ());
+       gdb_printf ("Copying debug output to %ps.\n",
+                   styled_string (file_name_style.style (),
+                                  logging_filename.c_str ()));
       else
-       gdb_printf ("Redirecting debug output to %s.\n",
-                   logging_filename.c_str ());
+       gdb_printf ("Redirecting debug output to %ps.\n",
+                   styled_string (file_name_style.style (),
+                                  logging_filename.c_str ()));
     }
 
   saved_filename = logging_filename;
@@ -279,8 +286,10 @@ set_logging_off (const char *args, int from_tty)
 
   log_file.reset ();
   if (from_tty)
-    gdb_printf ("Done logging to %s.\n",
-               saved_filename.c_str ());
+    gdb_printf ("Done logging to %ps.\n",
+               styled_string (file_name_style.style (),
+                              saved_filename.c_str ()));
+
   saved_filename.clear ();
 }
 
index 2bffe8cf437228431a215237340f1fc54ddbae57..74d4b231d3162951c10f4f306b9f1cc5b37aba2e 100644 (file)
@@ -1047,6 +1047,25 @@ proc test_finish_styling {} {
     gdb_test "finish" "Value returned is [style ${::valnum_re} variable] = 0"
 }
 
+# Test some logging styling.
+proc test_logging_styling {} {
+    with_ansi_styling_terminal {
+       clean_restart
+    }
+
+    set filename [standard_output_file logging.txt]
+    gdb_test_no_output "set logging file $filename" \
+       "set logging file"
+    gdb_test "set logging enabled on" \
+       [multi_line \
+            "Copying output to [style $filename file]\\." \
+            "Copying debug output to [style $filename file]\\."] \
+       "logging filenames are styled"
+    gdb_test "set logging enabled off" \
+       "Done logging to [style $filename file]\\." \
+       "filename styled when logging disabled"
+}
+
 # Check to see if the Python styling of disassembler output is
 # expected or not, this styling requires Python support in GDB, and
 # the Python pygments module to be available.
@@ -1093,3 +1112,4 @@ test_pagination_cmd_after_quit_styling
 test_pagination_prompt_styling
 test_pagination_continue_styling
 test_finish_styling
+test_logging_styling