Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 12/16] Style addresses
Date: Wed, 28 Nov 2018 00:14:00 -0000	[thread overview]
Message-ID: <20181128001435.12703-13-tom@tromey.com> (raw)
In-Reply-To: <20181128001435.12703-1-tom@tromey.com>

This changes gdb to style addresses.

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

	* ui-out.h (enum class ui_out_style_kind) <ADDRESS>: New
	constant.
	* ui-out.c (ui_out::field_core_addr): Add styling.
	* stack.c (print_frame): Add styling.
	* printcmd.c (print_address): Add styling.
	(print_address_demangle, info_address_command): Likewise.
	* cli/cli-style.h (address_style): Declare.
	* cli/cli-style.c (address_style): New global.
	(_initialize_cli_style): Register new commands.
	* cli-out.c (cli_ui_out::do_field_string): Update.

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

	* gdb.base/style.exp: Update test to check for address styling.
---
 gdb/ChangeLog                    | 13 ++++++++++++
 gdb/cli-out.c                    |  3 +++
 gdb/cli/cli-style.c              | 11 ++++++++++
 gdb/cli/cli-style.h              |  3 +++
 gdb/printcmd.c                   | 36 +++++++++++++++++++++-----------
 gdb/stack.c                      |  3 ++-
 gdb/testsuite/ChangeLog          |  4 ++++
 gdb/testsuite/gdb.base/style.exp |  2 +-
 gdb/ui-out.c                     |  3 ++-
 gdb/ui-out.h                     |  4 +++-
 10 files changed, 66 insertions(+), 16 deletions(-)

diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index e1005e1b35..691f993bad 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -176,6 +176,9 @@ cli_ui_out::do_field_string (int fldno, int width, ui_align align,
 	case ui_out_style_kind::VARIABLE:
 	  fstyle = variable_name_style.style ();
 	  break;
+	case ui_out_style_kind::ADDRESS:
+	  fstyle = address_style.style ();
+	  break;
 	default:
 	  gdb_assert_not_reached ("missing case");
 	}
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index fd4a4fc477..74e3958eb8 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -66,6 +66,10 @@ cli_style_option variable_name_style (ui_file_style::CYAN);
 
 /* See cli-style.h.  */
 
+cli_style_option address_style (ui_file_style::BLUE);
+
+/* See cli-style.h.  */
+
 cli_style_option::cli_style_option (ui_file_style::simple_color fg)
   : m_foreground (cli_colors[fg - ui_file_style::NONE]),
     m_background (cli_colors[0]),
@@ -265,4 +269,11 @@ Variable name display styling\n\
 Configure variable name colors and display intensity"),
 					    &style_set_list,
 					    &style_show_list);
+  address_style.add_setshow_commands ("address", no_class,
+				      "style address",
+				      _("\
+Address display styling\n\
+Configure address colors and display intensity"),
+				      &style_set_list,
+				      &style_show_list);
 }
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index 3d5142e3de..b1e9e09d45 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -86,6 +86,9 @@ extern cli_style_option function_name_style;
 /* The variable name style.  */
 extern cli_style_option variable_name_style;
 
+/* The address style.  */
+extern cli_style_option address_style;
+
 /* True if styling is enabled.  */
 extern int cli_styling;
 
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index c5b6b1a75b..98f5b23ce5 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -693,7 +693,7 @@ void
 print_address (struct gdbarch *gdbarch,
 	       CORE_ADDR addr, struct ui_file *stream)
 {
-  fputs_filtered (paddress (gdbarch, addr), stream);
+  fputs_styled (paddress (gdbarch, addr), address_style.style (), stream);
   print_address_symbolic (gdbarch, addr, stream, asm_demangle, " ");
 }
 
@@ -726,7 +726,7 @@ print_address_demangle (const struct value_print_options *opts,
 {
   if (opts->addressprint)
     {
-      fputs_filtered (paddress (gdbarch, addr), stream);
+      fputs_styled (paddress (gdbarch, addr), address_style.style (), stream);
       print_address_symbolic (gdbarch, addr, stream, do_demangle, " ");
     }
   else
@@ -1404,14 +1404,17 @@ info_address_command (const char *exp, int from_tty)
 	  fprintf_symbol_filtered (gdb_stdout, exp,
 				   current_language->la_language, DMGL_ANSI);
 	  printf_filtered ("\" is at ");
-	  fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
+	  fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
+			gdb_stdout);
 	  printf_filtered (" in a file compiled without debugging");
 	  section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym);
 	  if (section_is_overlay (section))
 	    {
 	      load_addr = overlay_unmapped_address (load_addr, section);
 	      printf_filtered (",\n -- loaded at ");
-	      fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
+	      fputs_styled (paddress (gdbarch, load_addr),
+			    address_style.style (),
+			    gdb_stdout);
 	      printf_filtered (" in overlay section %s",
 			       section->the_bfd_section->name);
 	    }
@@ -1451,12 +1454,14 @@ info_address_command (const char *exp, int from_tty)
     case LOC_LABEL:
       printf_filtered ("a label at address ");
       load_addr = SYMBOL_VALUE_ADDRESS (sym);
-      fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
+      fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
+		    gdb_stdout);
       if (section_is_overlay (section))
 	{
 	  load_addr = overlay_unmapped_address (load_addr, section);
 	  printf_filtered (",\n -- loaded at ");
-	  fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
+	  fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
+			gdb_stdout);
 	  printf_filtered (" in overlay section %s",
 			   section->the_bfd_section->name);
 	}
@@ -1485,12 +1490,14 @@ info_address_command (const char *exp, int from_tty)
     case LOC_STATIC:
       printf_filtered (_("static storage at address "));
       load_addr = SYMBOL_VALUE_ADDRESS (sym);
-      fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
+      fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
+		    gdb_stdout);
       if (section_is_overlay (section))
 	{
 	  load_addr = overlay_unmapped_address (load_addr, section);
 	  printf_filtered (_(",\n -- loaded at "));
-	  fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
+	  fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
+			gdb_stdout);
 	  printf_filtered (_(" in overlay section %s"),
 			   section->the_bfd_section->name);
 	}
@@ -1522,12 +1529,14 @@ info_address_command (const char *exp, int from_tty)
     case LOC_BLOCK:
       printf_filtered (_("a function at address "));
       load_addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));
-      fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
+      fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
+		    gdb_stdout);
       if (section_is_overlay (section))
 	{
 	  load_addr = overlay_unmapped_address (load_addr, section);
 	  printf_filtered (_(",\n -- loaded at "));
-	  fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
+	  fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
+			gdb_stdout);
 	  printf_filtered (_(" in overlay section %s"),
 			   section->the_bfd_section->name);
 	}
@@ -1557,12 +1566,15 @@ info_address_command (const char *exp, int from_tty)
 	      {
 		load_addr = BMSYMBOL_VALUE_ADDRESS (msym);
 		printf_filtered (_("static storage at address "));
-		fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
+		fputs_styled (paddress (gdbarch, load_addr),
+			      address_style.style (), gdb_stdout);
 		if (section_is_overlay (section))
 		  {
 		    load_addr = overlay_unmapped_address (load_addr, section);
 		    printf_filtered (_(",\n -- loaded at "));
-		    fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
+		    fputs_styled (paddress (gdbarch, load_addr),
+				  address_style.style (),
+				  gdb_stdout);
 		    printf_filtered (_(" in overlay section %s"),
 				     section->the_bfd_section->name);
 		  }
diff --git a/gdb/stack.c b/gdb/stack.c
index 930d7d0b1e..819bb616f0 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1176,7 +1176,8 @@ print_frame (struct frame_info *frame, int print_level,
 	  if (pc_p)
 	    uiout->field_core_addr ("addr", gdbarch, pc);
 	  else
-	    uiout->field_string ("addr", "<unavailable>");
+	    uiout->field_string ("addr", "<unavailable>",
+				 ui_out_style_kind::ADDRESS);
 	  annotate_frame_address_end ();
 	  uiout->text (" in ");
 	}
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index a44d78f236..b633340afe 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -43,7 +43,7 @@ save_vars { env(TERM) } {
 
     gdb_test "break main" "file $base_file_expr.*"
 
-    gdb_test "print &main" " = .* <$main_expr>"
+    gdb_test "print &main" " = .* \033\\\[34m$hex\033\\\[m <$main_expr>"
 
     gdb_exit
     gdb_spawn
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 761d6c0745..49f04dd936 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -469,7 +469,8 @@ void
 ui_out::field_core_addr (const char *fldname, struct gdbarch *gdbarch,
 			 CORE_ADDR address)
 {
-  field_string (fldname, print_core_address (gdbarch, address));
+  field_string (fldname, print_core_address (gdbarch, address),
+		ui_out_style_kind::ADDRESS);
 }
 
 void
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 93be9a91b2..96466d8023 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -77,7 +77,9 @@ enum class ui_out_style_kind
   /* Function name.  */
   FUNCTION,
   /* Variable name.  */
-  VARIABLE
+  VARIABLE,
+  /* Address.  */
+  ADDRESS
 };
 
 class ui_out
-- 
2.17.2


  parent reply	other threads:[~2018-11-28  0:14 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28  0:16 [PATCH 00/16] Add styling to the gdb CLI and TUI Tom Tromey
2018-11-28  0:14 ` [PATCH 14/16] Use wclrtoeol in tui_show_source_line Tom Tromey
2018-12-24  8:03   ` Joel Brobecker
2018-11-28  0:14 ` [PATCH 06/16] Reset terminal styles Tom Tromey
2018-12-24  4:16   ` Joel Brobecker
2018-12-28 19:01     ` Tom Tromey
2018-11-28  0:14 ` [PATCH 10/16] Style the gdb welcome message Tom Tromey
2018-11-28  0:14 ` [PATCH 03/16] Introduce ui_file_style Tom Tromey
2018-12-24  3:40   ` Joel Brobecker
2018-12-28 18:54     ` Tom Tromey
2018-11-28  0:14 ` [PATCH 02/16] Add a "context" argument to add_setshow_enum_cmd Tom Tromey
2018-11-28  0:14 ` Tom Tromey [this message]
2018-11-28  0:14 ` [PATCH 05/16] Add output styles to gdb Tom Tromey
2018-12-24  4:08   ` Joel Brobecker
2018-12-28 18:55     ` Tom Tromey
2018-11-28  0:14 ` [PATCH 09/16] Style print_address_symbolic Tom Tromey
2018-11-28  0:16 ` [PATCH 15/16] Highlight source code using GNU Source Highlight Tom Tromey
2019-11-16  0:58   ` Andrew Pinski
2019-11-16  8:19     ` Eli Zaretskii
2019-11-24 17:41     ` Tom Tromey
2019-11-24 18:13       ` Christian Biesinger via gdb-patches
2019-11-24 19:53         ` Tom Tromey
2018-11-28  0:16 ` [PATCH 08/16] Style locations when setting a breakpoint Tom Tromey
2018-11-28  0:16 ` [PATCH 13/16] Make ANSI terminal escape sequences work in TUI Tom Tromey
2018-12-24  8:02   ` Joel Brobecker
2018-12-28 19:42   ` Tom Tromey
2018-11-28  0:16 ` [PATCH 04/16] Change gdb test suite's TERM setting Tom Tromey
2018-11-28  0:16 ` [PATCH 07/16] Style variable names Tom Tromey
2018-11-28  0:16 ` [PATCH 16/16] Document the "set style" commands Tom Tromey
2018-11-28  6:51   ` Eli Zaretskii
2018-12-28 19:19     ` Tom Tromey
2018-11-28  0:16 ` [PATCH 11/16] Style the "Reading symbols" message Tom Tromey
2018-11-28  0:19 ` [PATCH 01/16] Change wrap buffering to use a std::string Tom Tromey
2018-12-23 15:26   ` Joel Brobecker
2018-12-28 18:47     ` Tom Tromey
2018-11-28  7:02 ` [PATCH 00/16] Add styling to the gdb CLI and TUI Eli Zaretskii
2018-11-29 22:44   ` Tom Tromey
2018-11-30  7:02     ` Eli Zaretskii
2018-11-30 16:17       ` Tom Tromey
2018-12-23 10:49         ` Joel Brobecker
2019-03-01 13:10         ` Pedro Alves
2019-03-01 13:56           ` Eli Zaretskii
2019-03-01 14:10             ` Pedro Alves
2019-03-01 14:50               ` Eli Zaretskii
2019-03-01  7:47     ` Eli Zaretskii
2019-03-01 18:42       ` Tom Tromey
2019-03-01 19:40         ` Eli Zaretskii
2019-03-01 21:04           ` Tom Tromey
2019-03-02  7:15             ` Eli Zaretskii
2019-03-03 15:42             ` Eli Zaretskii
2019-03-04 15:08               ` Tom Tromey
2019-03-04 15:57                 ` Eli Zaretskii
2019-03-04 16:16                   ` Tom Tromey
2019-03-05 15:38                     ` Eli Zaretskii
2019-03-08 14:55                       ` Eli Zaretskii
2019-03-08 16:14                         ` Hannes Domani via gdb-patches
2019-03-08 21:08                           ` Tom Tromey
2019-03-08 21:11                         ` Tom Tromey
2019-03-09  6:49                           ` Eli Zaretskii
2019-03-03 15:53             ` Eli Zaretskii
2019-03-03 16:16               ` Matt Rice
2019-03-03 17:13                 ` Eli Zaretskii
2019-03-03 18:04                   ` Matt Rice
2019-03-04 15:01               ` Tom Tromey
2019-03-04 17:37                 ` Eli Zaretskii
2019-03-04 17:40                   ` Tom Tromey
2019-03-06 16:02                     ` Eli Zaretskii
2019-03-20 19:35                       ` GDB version as convenience variable Eli Zaretskii
2019-03-25 17:31                         ` Eli Zaretskii
2019-03-25 17:58                           ` Simon Marchi
2019-03-25 18:10                             ` Eli Zaretskii
2019-03-25 18:33                               ` Simon Marchi
2019-03-25 18:37                                 ` Simon Marchi
2019-03-25 18:43                                 ` Eli Zaretskii
2019-03-25 18:51                                   ` Simon Marchi
2019-03-25 19:19                                     ` Eli Zaretskii
2019-03-26 14:47                                       ` Simon Marchi
2019-03-26 20:57                                         ` Joel Brobecker
2019-03-27  3:34                                           ` Eli Zaretskii
2019-03-27 12:56                                             ` Joel Brobecker
2019-03-30 17:25                                               ` Simon Marchi
2019-03-30 10:01                                         ` Eli Zaretskii
2019-03-21  1:55                       ` [PATCH 00/16] Add styling to the gdb CLI and TUI Simon Marchi
2019-03-21 14:38                         ` Eli Zaretskii
2019-03-21 15:02                           ` Simon Marchi
2019-03-21 16:01                             ` Eli Zaretskii
2019-03-21 16:06                               ` Simon Marchi
2019-03-21 16:12                                 ` Pedro Alves
2019-03-21 16:54                                   ` John Baldwin
2019-03-21 17:02                                   ` Eli Zaretskii
2019-03-21 18:08                                     ` Simon Marchi
2019-03-21 18:19                                       ` Pedro Alves
2019-03-21 18:38                                         ` Eli Zaretskii
2019-03-07  6:02                   ` Joel Brobecker
2019-03-07 14:53                     ` Eli Zaretskii
2019-03-08  5:40                       ` Joel Brobecker
2019-03-04 16:04       ` Eli Zaretskii
2018-12-24  9:27 ` Joel Brobecker
2018-12-28 20:57   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181128001435.12703-13-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox