Style addresses
This changes gdb to style addresses. gdb/ChangeLog 2018-12-28 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-12-28 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Update test to check for address styling.
This commit is contained in:
parent
47fd17cdc1
commit
35fb8261b9
10 changed files with 66 additions and 16 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2018-12-28 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.
|
||||||
|
|
||||||
2018-12-28 Tom Tromey <tom@tromey.com>
|
2018-12-28 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* symfile.c (symbol_file_add_with_addrs): Style file name.
|
* symfile.c (symbol_file_add_with_addrs): Style file name.
|
||||||
|
|
|
@ -176,6 +176,9 @@ cli_ui_out::do_field_string (int fldno, int width, ui_align align,
|
||||||
case ui_out_style_kind::VARIABLE:
|
case ui_out_style_kind::VARIABLE:
|
||||||
fstyle = variable_name_style.style ();
|
fstyle = variable_name_style.style ();
|
||||||
break;
|
break;
|
||||||
|
case ui_out_style_kind::ADDRESS:
|
||||||
|
fstyle = address_style.style ();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
gdb_assert_not_reached ("missing case");
|
gdb_assert_not_reached ("missing case");
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,10 @@ cli_style_option variable_name_style (ui_file_style::CYAN);
|
||||||
|
|
||||||
/* See cli-style.h. */
|
/* 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::basic_color fg)
|
cli_style_option::cli_style_option (ui_file_style::basic_color fg)
|
||||||
: m_foreground (cli_colors[fg - ui_file_style::NONE]),
|
: m_foreground (cli_colors[fg - ui_file_style::NONE]),
|
||||||
m_background (cli_colors[0]),
|
m_background (cli_colors[0]),
|
||||||
|
@ -265,4 +269,11 @@ Variable name display styling\n\
|
||||||
Configure variable name colors and display intensity"),
|
Configure variable name colors and display intensity"),
|
||||||
&style_set_list,
|
&style_set_list,
|
||||||
&style_show_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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,9 @@ extern cli_style_option function_name_style;
|
||||||
/* The variable name style. */
|
/* The variable name style. */
|
||||||
extern cli_style_option variable_name_style;
|
extern cli_style_option variable_name_style;
|
||||||
|
|
||||||
|
/* The address style. */
|
||||||
|
extern cli_style_option address_style;
|
||||||
|
|
||||||
/* True if styling is enabled. */
|
/* True if styling is enabled. */
|
||||||
extern int cli_styling;
|
extern int cli_styling;
|
||||||
|
|
||||||
|
|
|
@ -693,7 +693,7 @@ void
|
||||||
print_address (struct gdbarch *gdbarch,
|
print_address (struct gdbarch *gdbarch,
|
||||||
CORE_ADDR addr, struct ui_file *stream)
|
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, " ");
|
print_address_symbolic (gdbarch, addr, stream, asm_demangle, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -726,7 +726,7 @@ print_address_demangle (const struct value_print_options *opts,
|
||||||
{
|
{
|
||||||
if (opts->addressprint)
|
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, " ");
|
print_address_symbolic (gdbarch, addr, stream, do_demangle, " ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1404,14 +1404,17 @@ info_address_command (const char *exp, int from_tty)
|
||||||
fprintf_symbol_filtered (gdb_stdout, exp,
|
fprintf_symbol_filtered (gdb_stdout, exp,
|
||||||
current_language->la_language, DMGL_ANSI);
|
current_language->la_language, DMGL_ANSI);
|
||||||
printf_filtered ("\" is at ");
|
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");
|
printf_filtered (" in a file compiled without debugging");
|
||||||
section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym);
|
section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym);
|
||||||
if (section_is_overlay (section))
|
if (section_is_overlay (section))
|
||||||
{
|
{
|
||||||
load_addr = overlay_unmapped_address (load_addr, section);
|
load_addr = overlay_unmapped_address (load_addr, section);
|
||||||
printf_filtered (",\n -- loaded at ");
|
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",
|
printf_filtered (" in overlay section %s",
|
||||||
section->the_bfd_section->name);
|
section->the_bfd_section->name);
|
||||||
}
|
}
|
||||||
|
@ -1451,12 +1454,14 @@ info_address_command (const char *exp, int from_tty)
|
||||||
case LOC_LABEL:
|
case LOC_LABEL:
|
||||||
printf_filtered ("a label at address ");
|
printf_filtered ("a label at address ");
|
||||||
load_addr = SYMBOL_VALUE_ADDRESS (sym);
|
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))
|
if (section_is_overlay (section))
|
||||||
{
|
{
|
||||||
load_addr = overlay_unmapped_address (load_addr, section);
|
load_addr = overlay_unmapped_address (load_addr, section);
|
||||||
printf_filtered (",\n -- loaded at ");
|
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",
|
printf_filtered (" in overlay section %s",
|
||||||
section->the_bfd_section->name);
|
section->the_bfd_section->name);
|
||||||
}
|
}
|
||||||
|
@ -1485,12 +1490,14 @@ info_address_command (const char *exp, int from_tty)
|
||||||
case LOC_STATIC:
|
case LOC_STATIC:
|
||||||
printf_filtered (_("static storage at address "));
|
printf_filtered (_("static storage at address "));
|
||||||
load_addr = SYMBOL_VALUE_ADDRESS (sym);
|
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))
|
if (section_is_overlay (section))
|
||||||
{
|
{
|
||||||
load_addr = overlay_unmapped_address (load_addr, section);
|
load_addr = overlay_unmapped_address (load_addr, section);
|
||||||
printf_filtered (_(",\n -- loaded at "));
|
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"),
|
printf_filtered (_(" in overlay section %s"),
|
||||||
section->the_bfd_section->name);
|
section->the_bfd_section->name);
|
||||||
}
|
}
|
||||||
|
@ -1522,12 +1529,14 @@ info_address_command (const char *exp, int from_tty)
|
||||||
case LOC_BLOCK:
|
case LOC_BLOCK:
|
||||||
printf_filtered (_("a function at address "));
|
printf_filtered (_("a function at address "));
|
||||||
load_addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));
|
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))
|
if (section_is_overlay (section))
|
||||||
{
|
{
|
||||||
load_addr = overlay_unmapped_address (load_addr, section);
|
load_addr = overlay_unmapped_address (load_addr, section);
|
||||||
printf_filtered (_(",\n -- loaded at "));
|
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"),
|
printf_filtered (_(" in overlay section %s"),
|
||||||
section->the_bfd_section->name);
|
section->the_bfd_section->name);
|
||||||
}
|
}
|
||||||
|
@ -1557,12 +1566,15 @@ info_address_command (const char *exp, int from_tty)
|
||||||
{
|
{
|
||||||
load_addr = BMSYMBOL_VALUE_ADDRESS (msym);
|
load_addr = BMSYMBOL_VALUE_ADDRESS (msym);
|
||||||
printf_filtered (_("static storage at address "));
|
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))
|
if (section_is_overlay (section))
|
||||||
{
|
{
|
||||||
load_addr = overlay_unmapped_address (load_addr, section);
|
load_addr = overlay_unmapped_address (load_addr, section);
|
||||||
printf_filtered (_(",\n -- loaded at "));
|
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"),
|
printf_filtered (_(" in overlay section %s"),
|
||||||
section->the_bfd_section->name);
|
section->the_bfd_section->name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1176,7 +1176,8 @@ print_frame (struct frame_info *frame, int print_level,
|
||||||
if (pc_p)
|
if (pc_p)
|
||||||
uiout->field_core_addr ("addr", gdbarch, pc);
|
uiout->field_core_addr ("addr", gdbarch, pc);
|
||||||
else
|
else
|
||||||
uiout->field_string ("addr", "<unavailable>");
|
uiout->field_string ("addr", "<unavailable>",
|
||||||
|
ui_out_style_kind::ADDRESS);
|
||||||
annotate_frame_address_end ();
|
annotate_frame_address_end ();
|
||||||
uiout->text (" in ");
|
uiout->text (" in ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2018-12-28 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* gdb.base/style.exp: Update test to check for address styling.
|
||||||
|
|
||||||
2018-12-28 Tom Tromey <tom@tromey.com>
|
2018-12-28 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* gdb.base/style.exp: Add test for styling of "Reading symbols"
|
* gdb.base/style.exp: Add test for styling of "Reading symbols"
|
||||||
|
|
|
@ -43,7 +43,7 @@ save_vars { env(TERM) } {
|
||||||
|
|
||||||
gdb_test "break main" "file $base_file_expr.*"
|
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_exit
|
||||||
gdb_spawn
|
gdb_spawn
|
||||||
|
|
|
@ -469,7 +469,8 @@ void
|
||||||
ui_out::field_core_addr (const char *fldname, struct gdbarch *gdbarch,
|
ui_out::field_core_addr (const char *fldname, struct gdbarch *gdbarch,
|
||||||
CORE_ADDR address)
|
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
|
void
|
||||||
|
|
|
@ -77,7 +77,9 @@ enum class ui_out_style_kind
|
||||||
/* Function name. */
|
/* Function name. */
|
||||||
FUNCTION,
|
FUNCTION,
|
||||||
/* Variable name. */
|
/* Variable name. */
|
||||||
VARIABLE
|
VARIABLE,
|
||||||
|
/* Address. */
|
||||||
|
ADDRESS
|
||||||
};
|
};
|
||||||
|
|
||||||
class ui_out
|
class ui_out
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue