[08/16] Style locations when setting a breakpoint

Message ID 20181128001435.12703-9-tom@tromey.com
State New
Headers show
Series
  • Add styling to the gdb CLI and TUI
Related show

Commit Message

Tom Tromey Nov. 28, 2018, 12:14 a.m.
say_where does not use ui-out, so function and file names printed by
it were not styled.  This patch changes say_where to use the low-level
style code directly.

gdb/ChangeLog
2018-11-27  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (say_where): Style file name.

gdb/testsuite/ChangeLog
2018-11-27  Tom Tromey  <tom@tromey.com>

	* gdb.base/style.exp: Add test for breakpoint setting.
---
 gdb/ChangeLog                    |  4 ++++
 gdb/breakpoint.c                 | 12 +++++++++---
 gdb/testsuite/ChangeLog          |  4 ++++
 gdb/testsuite/gdb.base/style.exp |  5 ++++-
 4 files changed, 21 insertions(+), 4 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 53763e0254..b99b0fb27c 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -68,6 +68,7 @@ 
 #include "format.h"
 #include "thread-fsm.h"
 #include "tid-parse.h"
+#include "cli/cli-style.h"
 
 /* readline include files */
 #include "readline/readline.h"
@@ -12195,9 +12196,14 @@  say_where (struct breakpoint *b)
 	  /* If there is a single location, we can print the location
 	     more nicely.  */
 	  if (b->loc->next == NULL)
-	    printf_filtered (": file %s, line %d.",
-			     symtab_to_filename_for_display (b->loc->symtab),
-			     b->loc->line_number);
+	    {
+	      puts_filtered (": file ");
+	      fputs_styled (symtab_to_filename_for_display (b->loc->symtab),
+			    file_name_style.style (),
+			    gdb_stdout);
+	      printf_filtered (", line %d.",
+			       b->loc->line_number);
+	    }
 	  else
 	    /* This is not ideal, but each location may have a
 	       different file name, and this at least reflects the
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 1ab9d68431..df73e25a16 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -33,10 +33,13 @@  save_vars { env(TERM) } {
     gdb_test_no_output "set style enabled on"
     
     set main_expr "\033\\\[33mmain\033\\\[m"
-    set file_expr "\033\\\[32m.*style\\.c\033\\\[m:\[0-9\]"
+    set base_file_expr "\033\\\[32m.*style\\.c\033\\\[m"
+    set file_expr "$base_file_expr:\[0-9\]"
     set arg_expr "\033\\\[36marg.\033\\\[m"
 
     gdb_test "frame" \
 	"$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*"
     gdb_test "info breakpoints" "$main_expr at $file_expr.*"
+
+    gdb_test "break main" "file $base_file_expr.*"
 }