[binutils-gdb] gdb: more styling for skip command output

Andrew Burgess aburgess@sourceware.org
Wed Feb 25 11:30:36 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0af201692065dde1e28cbd25f2de108a66d98c2f

commit 0af201692065dde1e28cbd25f2de108a66d98c2f
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Wed Feb 11 13:02:11 2026 +0000

    gdb: more styling for skip command output
    
    Add function and file styling to output of the 'skip', 'skip file',
    and 'skip function' commands.
    
    I did worry a little about this case:
    
      (gdb) skip -gfile *.c
      File(s) *.c will be skipped when stepping.
    
    After this change the '*.c' will be given file_name_style, even though
    it's not an actual filename, but a filename glob.
    
    However, if you do this:
    
      (gdb) info skip
      Num   Enb Glob File                 RE Function
      1     y      y *.c                   n <none>
    
    Then the '*.c' is already (even before this patch) given
    file_name_style, so if nothing else, my change makes things
    consistent.  And personally, I think it's OK to style the '*.c'.
    
    There's a similar issue with 'skip -rfunction PATTERN' where the
    PATTERN will be styled in the output with function_name_style even
    though it's not an actual function name.  As with the filename case
    PATTERN is already styled in the 'info skip' table, so I think the
    change in this commit is consistent if nothing else.
    
    There should be no functional change after this commit; just improved
    styling.
    
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/skip.c                       | 28 +++++++++++++++++++---------
 gdb/testsuite/gdb.base/style.exp | 16 ++++++++++++++++
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/gdb/skip.c b/gdb/skip.c
index 5c8d409cb8c..ad191ef7a70 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -236,7 +236,8 @@ skip_file_command (const char *arg, int from_tty)
   skiplist_entry::add_entry (false, std::string (filename),
 			     false, std::string ());
 
-  gdb_printf (_("File %s will be skipped when stepping.\n"), filename);
+  gdb_printf (_("File %ps will be skipped when stepping.\n"),
+	      styled_string (file_name_style.style (), filename));
 }
 
 /* Create a skiplist entry for the given function NAME and add it to the
@@ -247,7 +248,8 @@ skip_function (const char *name)
 {
   skiplist_entry::add_entry (false, std::string (), false, std::string (name));
 
-  gdb_printf (_("Function %s will be skipped when stepping.\n"), name);
+  gdb_printf (_("Function %ps will be skipped when stepping.\n"),
+	      styled_string (function_name_style.style (), name));
 }
 
 static void
@@ -432,20 +434,28 @@ skip_command (const char *arg, int from_tty)
 
     if (function_to_print.empty ())
       {
-	gdb_printf (_("%s %s will be skipped when stepping.\n"),
-		    file_text, file_to_print.c_str ());
+	gdb_printf (_("%s %ps will be skipped when stepping.\n"),
+		    file_text,
+		    styled_string (file_name_style.style (),
+				   file_to_print.c_str ()));
       }
     else if (file_to_print.empty ())
       {
-	gdb_printf (_("%s %s will be skipped when stepping.\n"),
-		    function_text, function_to_print.c_str ());
+	gdb_printf (_("%s %ps will be skipped when stepping.\n"),
+		    function_text,
+		    styled_string (function_name_style.style (),
+				   function_to_print.c_str ()));
       }
     else
       {
-	gdb_printf (_("%s %s in %s %s will be skipped"
+	gdb_printf (_("%s %ps in %s %ps will be skipped"
 		      " when stepping.\n"),
-		    function_text, function_to_print.c_str (),
-		    lower_file_text, file_to_print.c_str ());
+		    function_text,
+		    styled_string (function_name_style.style (),
+				   function_to_print.c_str ()),
+		    lower_file_text,
+		    styled_string (file_name_style.style (),
+				   file_to_print.c_str ()));
       }
   }
 }
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 74d4b231d31..040e399e72d 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -343,6 +343,22 @@ proc run_style_tests { } {
 	gdb_test "maint translate-address" \
 	    "abcd:requires argument.*" \
 	    "error prefix"
+
+	# Check styling in the 'skip' related commands.
+	gdb_test "skip -file xxxx.c" \
+	    "File [limited_style xxxx\\.c file] will be skipped when stepping\\."
+	gdb_test "skip -gfile zz*.c" \
+	    "File\\(s\\) [limited_style zz\\*\\.c file] will be skipped when stepping\\."
+	gdb_test "skip -function xxxx" \
+	    "Function [limited_style xxxx function] will be skipped when stepping\\."
+	gdb_test "skip -rfunction zzz.*" \
+	    "Function\\(s\\) [limited_style zzz\\.\\* function] will be skipped when stepping\\."
+	gdb_test "skip function qqq" \
+	    "Function [limited_style qqq function] will be skipped when stepping\\."
+	gdb_test "skip file blah.c" \
+	    "File [limited_style blah\\.c file] will be skipped when stepping\\."
+	gdb_test "skip ttt" \
+	    "Function [limited_style ttt function] will be skipped when stepping\\."
     }
 }


More information about the Gdb-cvs mailing list