Add line-number styling

This patch adds separate styling for line numbers.  That is, whenever
gdb prints a source line number, it uses this style.

v2 includes a change to ensure that %ps works in query.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-by: Keith Seitz <keiths@redhat.com>
This commit is contained in:
Tom Tromey
2024-09-14 15:07:17 -06:00
parent 7ecf0250f7
commit 887ae0cf2b
28 changed files with 131 additions and 55 deletions

View File

@@ -65,6 +65,11 @@
* New commands * New commands
set style line-number foreground COLOR
set style line-number background COLOR
set style line-number intensity VALUE
Control the styling of line numbers printed by GDB.
maintenance info inline-frames [ADDRESS] maintenance info inline-frames [ADDRESS]
New command which displays GDB's inline-frame information for the New command which displays GDB's inline-frame information for the
current address, or for ADDRESS if specified. The output identifies current address, or for ADDRESS if specified. The output identifies

View File

@@ -6371,7 +6371,8 @@ print_breakpoint_location (const breakpoint *b, const bp_location *loc)
if (uiout->is_mi_like_p ()) if (uiout->is_mi_like_p ())
uiout->field_string ("fullname", symtab_to_fullname (loc->symtab)); uiout->field_string ("fullname", symtab_to_fullname (loc->symtab));
uiout->field_signed ("line", loc->line_number); uiout->field_signed ("line", loc->line_number,
line_number_style.style ());
} }
else if (loc) else if (loc)
{ {
@@ -11799,10 +11800,11 @@ code_breakpoint::say_where () const
{ {
const char *filename const char *filename
= symtab_to_filename_for_display (bl.symtab); = symtab_to_filename_for_display (bl.symtab);
gdb_printf (": file %ps, line %d.", gdb_printf (": file %ps, line %ps.",
styled_string (file_name_style.style (), styled_string (file_name_style.style (),
filename), filename),
bl.line_number); styled_string (line_number_style.style (),
pulongest (bl.line_number)));
} }
else else
/* This is not ideal, but each location may have a /* This is not ideal, but each location may have a
@@ -12832,7 +12834,7 @@ update_static_tracepoint (tracepoint *tp, struct symtab_and_line sal)
uiout->field_string ("fullname", fullname); uiout->field_string ("fullname", fullname);
} }
uiout->field_signed ("line", sal2.line); uiout->field_signed ("line", sal2.line, line_number_style.style ());
uiout->text ("\n"); uiout->text ("\n");
tp->first_loc ().line_number = sal2.line; tp->first_loc ().line_number = sal2.line;

View File

@@ -94,13 +94,14 @@ cli_ui_out::do_end (ui_out_type type)
void void
cli_ui_out::do_field_signed (int fldno, int width, ui_align alignment, cli_ui_out::do_field_signed (int fldno, int width, ui_align alignment,
const char *fldname, LONGEST value) const char *fldname, LONGEST value,
const ui_file_style &style)
{ {
if (m_suppress_output) if (m_suppress_output)
return; return;
do_field_string (fldno, width, alignment, fldname, plongest (value), do_field_string (fldno, width, alignment, fldname, plongest (value),
ui_file_style ()); style);
} }
/* output an unsigned field */ /* output an unsigned field */

View File

@@ -52,7 +52,8 @@ protected:
virtual void do_begin (ui_out_type type, const char *id) override; virtual void do_begin (ui_out_type type, const char *id) override;
virtual void do_end (ui_out_type type) override; virtual void do_end (ui_out_type type) override;
virtual void do_field_signed (int fldno, int width, ui_align align, virtual void do_field_signed (int fldno, int width, ui_align align,
const char *fldname, LONGEST value) override; const char *fldname, LONGEST value,
const ui_file_style &style) override;
virtual void do_field_unsigned (int fldno, int width, ui_align align, virtual void do_field_unsigned (int fldno, int width, ui_align align,
const char *fldname, ULONGEST value) const char *fldname, ULONGEST value)
override; override;

View File

@@ -2116,9 +2116,11 @@ print_sal_location (const symtab_and_line &sal)
const char *sym_name = NULL; const char *sym_name = NULL;
if (sal.symbol != NULL) if (sal.symbol != NULL)
sym_name = sal.symbol->print_name (); sym_name = sal.symbol->print_name ();
gdb_printf (_("file: \"%s\", line number: %d, symbol: \"%s\"\n"), gdb_printf (_("file: \"%s\", line number: %ps, symbol: \"%s\"\n"),
symtab_to_filename_for_display (sal.symtab), symtab_to_filename_for_display (sal.symtab),
sal.line, sym_name != NULL ? sym_name : "???"); styled_string (line_number_style.style (),
pulongest (sal.line)),
sym_name != NULL ? sym_name : "???");
} }
/* Print a list of files and line numbers which a user may choose from /* Print a list of files and line numbers which a user may choose from

View File

@@ -126,6 +126,10 @@ cli_style_option disasm_comment_style ("comment", ui_file_style::WHITE,
/* See cli-style.h. */ /* See cli-style.h. */
cli_style_option line_number_style ("line-number", ui_file_style::DIM);
/* See cli-style.h. */
cli_style_option::cli_style_option (const char *name, cli_style_option::cli_style_option (const char *name,
ui_file_style::basic_color fg, ui_file_style::basic_color fg,
ui_file_style::intensity intensity) ui_file_style::intensity intensity)
@@ -529,6 +533,14 @@ then this style has no effect."),
&style_disasm_show_list, &style_disasm_show_list,
false); false);
line_number_style.add_setshow_commands (no_class, _("\
Line number display styling.\n\
Configure colors and display intensity for line numbers\n\
The \"line-number\" style is used when GDB displays line numbers\n\
coming from your source code."),
&style_set_list, &style_show_list,
false);
/* Setup 'disassembler address' style and 'disassembler symbol' style, /* Setup 'disassembler address' style and 'disassembler symbol' style,
these are aliases for 'address' and 'function' styles respectively. */ these are aliases for 'address' and 'function' styles respectively. */
add_alias_cmd ("address", address_prefix_cmds.set, no_class, 0, add_alias_cmd ("address", address_prefix_cmds.set, no_class, 0,

View File

@@ -145,6 +145,9 @@ extern cli_style_option tui_active_border_style;
/* The style to use for the GDB version string. */ /* The style to use for the GDB version string. */
extern cli_style_option version_style; extern cli_style_option version_style;
/* The style for a line number. */
extern cli_style_option line_number_style;
/* True if source styling is enabled. */ /* True if source styling is enabled. */
extern bool source_styling; extern bool source_styling;

View File

@@ -27852,6 +27852,10 @@ if @value{GDBN} is using its builtin disassembler library for styling
(@pxref{style_disassembler_enabled,,@kbd{set style disassembler (@pxref{style_disassembler_enabled,,@kbd{set style disassembler
enabled}}). enabled}}).
@item line-number
Control the styling of line numbers. By default, this style's
intensity is dim.
@item variable @item variable
Control the styling of variable names. These are managed with the Control the styling of variable names. These are managed with the
@code{set style variable} family of commands. By default, this style's @code{set style variable} family of commands. By default, this style's

View File

@@ -1103,7 +1103,9 @@ jump_command (const char *arg, int from_tty)
find_pc_mapped_section (sal.pc)); find_pc_mapped_section (sal.pc));
if (fn != nullptr && sfn != fn) if (fn != nullptr && sfn != fn)
{ {
if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal.line, if (!query (_("Line %ps is not in `%s'. Jump anyway? "),
styled_string (line_number_style.style (),
pulongest (sal.line)),
fn->print_name ())) fn->print_name ()))
{ {
error (_("Not confirmed.")); error (_("Not confirmed."));

View File

@@ -35,8 +35,8 @@ mi_ui_out::do_table_begin (int nr_cols, int nr_rows,
const char *tblid) const char *tblid)
{ {
open (tblid, ui_out_type_tuple); open (tblid, ui_out_type_tuple);
do_field_signed (-1, -1, ui_left, "nr_rows", nr_rows); do_field_signed (-1, -1, ui_left, "nr_rows", nr_rows, ui_file_style ());
do_field_signed (-1, -1, ui_left, "nr_cols", nr_cols); do_field_signed (-1, -1, ui_left, "nr_cols", nr_cols, ui_file_style ());
open ("hdr", ui_out_type_list); open ("hdr", ui_out_type_list);
} }
@@ -67,8 +67,8 @@ mi_ui_out::do_table_header (int width, ui_align alignment,
const std::string &col_hdr) const std::string &col_hdr)
{ {
open (NULL, ui_out_type_tuple); open (NULL, ui_out_type_tuple);
do_field_signed (0, 0, ui_center, "width", width); do_field_signed (0, 0, ui_center, "width", width, ui_file_style ());
do_field_signed (0, 0, ui_center, "alignment", alignment); do_field_signed (0, 0, ui_center, "alignment", alignment, ui_file_style ());
do_field_string (0, 0, ui_center, "col_name", col_name.c_str (), do_field_string (0, 0, ui_center, "col_name", col_name.c_str (),
ui_file_style ()); ui_file_style ());
do_field_string (0, width, alignment, "colhdr", col_hdr.c_str (), do_field_string (0, width, alignment, "colhdr", col_hdr.c_str (),
@@ -96,10 +96,11 @@ mi_ui_out::do_end (ui_out_type type)
void void
mi_ui_out::do_field_signed (int fldno, int width, ui_align alignment, mi_ui_out::do_field_signed (int fldno, int width, ui_align alignment,
const char *fldname, LONGEST value) const char *fldname, LONGEST value,
const ui_file_style &style)
{ {
do_field_string (fldno, width, alignment, fldname, plongest (value), do_field_string (fldno, width, alignment, fldname, plongest (value),
ui_file_style ()); style);
} }
/* Output an unsigned field. */ /* Output an unsigned field. */

View File

@@ -62,7 +62,8 @@ protected:
virtual void do_begin (ui_out_type type, const char *id) override; virtual void do_begin (ui_out_type type, const char *id) override;
virtual void do_end (ui_out_type type) override; virtual void do_end (ui_out_type type) override;
virtual void do_field_signed (int fldno, int width, ui_align align, virtual void do_field_signed (int fldno, int width, ui_align align,
const char *fldname, LONGEST value) override; const char *fldname, LONGEST value,
const ui_file_style &style) override;
virtual void do_field_unsigned (int fldno, int width, ui_align align, virtual void do_field_unsigned (int fldno, int width, ui_align align,
const char *fldname, ULONGEST value) const char *fldname, ULONGEST value)
override; override;

View File

@@ -1007,7 +1007,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
out->text (":"); out->text (":");
annotate_frame_source_line (); annotate_frame_source_line ();
out->field_signed ("line", line); out->field_signed ("line", line, line_number_style.style ());
} }
} }
if (out->is_mi_like_p ()) if (out->is_mi_like_p ())

View File

@@ -86,7 +86,8 @@ py_ui_out::do_end (ui_out_type type)
void void
py_ui_out::do_field_signed (int fldno, int width, ui_align align, py_ui_out::do_field_signed (int fldno, int width, ui_align align,
const char *fldname, LONGEST value) const char *fldname, LONGEST value,
const ui_file_style &style)
{ {
if (m_error.has_value ()) if (m_error.has_value ())
return; return;

View File

@@ -86,7 +86,8 @@ protected:
void do_end (ui_out_type type) override; void do_end (ui_out_type type) override;
void do_field_signed (int fldno, int width, ui_align align, void do_field_signed (int fldno, int width, ui_align align,
const char *fldname, LONGEST value) override; const char *fldname, LONGEST value,
const ui_file_style &style) override;
void do_field_unsigned (int fldno, int width, ui_align align, void do_field_unsigned (int fldno, int width, ui_align align,
const char *fldname, ULONGEST value) override; const char *fldname, ULONGEST value) override;

View File

@@ -1345,7 +1345,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
fields. ui_source_list is set only for CLI, not for fields. ui_source_list is set only for CLI, not for
TUI. */ TUI. */
uiout->field_signed ("line", line); uiout->field_signed ("line", line, line_number_style.style ());
uiout->text ("\tin "); uiout->text ("\tin ");
uiout->field_string ("file", symtab_to_filename_for_display (s), uiout->field_string ("file", symtab_to_filename_for_display (s),
@@ -1389,8 +1389,10 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
uiout->text (symtab_to_filename_for_display (s)); uiout->text (symtab_to_filename_for_display (s));
uiout->text (":"); uiout->text (":");
} }
xsnprintf (buf, sizeof (buf), "%d\t", new_lineno++);
uiout->text (buf); uiout->message ("%ps\t", styled_string (line_number_style.style (),
pulongest (new_lineno)));
++new_lineno;
while (*iter != '\0') while (*iter != '\0')
{ {
@@ -1551,8 +1553,9 @@ info_line_command (const char *arg, int from_tty)
if (start_pc == end_pc) if (start_pc == end_pc)
{ {
gdb_printf ("Line %d of \"%s\"", gdb_printf ("Line %ps of \"%s\"",
sal.line, styled_string (line_number_style.style (),
pulongest (sal.line)),
symtab_to_filename_for_display (sal.symtab)); symtab_to_filename_for_display (sal.symtab));
gdb_stdout->wrap_here (2); gdb_stdout->wrap_here (2);
gdb_printf (" is at address "); gdb_printf (" is at address ");
@@ -1562,8 +1565,9 @@ info_line_command (const char *arg, int from_tty)
} }
else else
{ {
gdb_printf ("Line %d of \"%s\"", gdb_printf ("Line %ps of \"%s\"",
sal.line, styled_string (line_number_style.style (),
pulongest (sal.line)),
symtab_to_filename_for_display (sal.symtab)); symtab_to_filename_for_display (sal.symtab));
gdb_stdout->wrap_here (2); gdb_stdout->wrap_here (2);
gdb_printf (" starts at address "); gdb_printf (" starts at address ");
@@ -1589,8 +1593,10 @@ info_line_command (const char *arg, int from_tty)
/* Is there any case in which we get here, and have an address /* Is there any case in which we get here, and have an address
which the user would want to see? If we have debugging symbols which the user would want to see? If we have debugging symbols
and no line numbers? */ and no line numbers? */
gdb_printf (_("Line number %d is out of range for \"%s\".\n"), gdb_printf (_("Line number %ps is out of range for \"%s\".\n"),
sal.line, symtab_to_filename_for_display (sal.symtab)); styled_string (line_number_style.style (),
pulongest (sal.line)),
symtab_to_filename_for_display (sal.symtab));
} }
} }

View File

@@ -1417,7 +1417,7 @@ print_frame (struct ui_out *uiout,
annotate_frame_source_file_end (); annotate_frame_source_file_end ();
uiout->text (":"); uiout->text (":");
annotate_frame_source_line (); annotate_frame_source_line ();
uiout->field_signed ("line", sal.line); uiout->field_signed ("line", sal.line, line_number_style.style ());
annotate_frame_source_end (); annotate_frame_source_end ();
} }

View File

@@ -999,7 +999,8 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
ui_out_emit_tuple tuple_emitter (uiout, nullptr); ui_out_emit_tuple tuple_emitter (uiout, nullptr);
uiout->field_signed ("index", i); uiout->field_signed ("index", i);
if (item->line > 0) if (item->line > 0)
uiout->field_signed ("line", item->line); uiout->field_signed ("line", item->line,
line_number_style.style ());
else else
uiout->field_string ("line", _("END")); uiout->field_string ("line", _("END"));
uiout->field_core_addr ("rel-address", objfile->arch (), uiout->field_core_addr ("rel-address", objfile->arch (),

View File

@@ -41,7 +41,8 @@ with_ansi_styling_terminal {
set main_expr [style main function] set main_expr [style main function]
set base_file_expr [style ".*style\\.c" file] set base_file_expr [style ".*style\\.c" file]
set file_expr "$base_file_expr:\[0-9\]" set line_expr [style $decimal line-number]
set file_expr "$base_file_expr:$line_expr"
set arg_expr [style "arg." variable] set arg_expr [style "arg." variable]
gdb_test "frame" \ gdb_test "frame" \
"$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*" "$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*"

View File

@@ -99,7 +99,8 @@ proc run_style_tests { } {
set main_expr [limited_style main function] set main_expr [limited_style main function]
set base_file_expr [limited_style ".*style\\.c" file] set base_file_expr [limited_style ".*style\\.c" file]
set file_expr "$base_file_expr:\[0-9\]+" set line_expr [limited_style $decimal line-number]
set file_expr "$base_file_expr:$line_expr"
set arg_expr [limited_style "arg." variable] set arg_expr [limited_style "arg." variable]
# On some embedded targets that don't fully support argc/argv, # On some embedded targets that don't fully support argc/argv,
@@ -109,12 +110,12 @@ proc run_style_tests { } {
gdb_test "frame" \ gdb_test "frame" \
[multi_line \ [multi_line \
"#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex.*\\)\\s+at\\s+$file_expr" \ "#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex.*\\)\\s+at\\s+$file_expr" \
"\[0-9\]+\\s+.*return.* break here .*"] "$line_expr\\s+.*return.* break here .*"]
gdb_test "info breakpoints" "$main_expr at $file_expr.*" gdb_test "info breakpoints" "$main_expr at $file_expr.*"
gdb_test_no_output "set style sources off" gdb_test_no_output "set style sources off"
gdb_test "frame" \ gdb_test "frame" \
"\r\n\[^\033\]*break here.*" \ "\r\n$line_expr\[^\033\]*break here.*" \
"frame without sources styling" "frame without sources styling"
gdb_test_no_output "set style sources on" gdb_test_no_output "set style sources on"
@@ -139,18 +140,18 @@ proc run_style_tests { } {
[multi_line \ [multi_line \
"#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex\\)" \ "#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex\\)" \
"\\s+at\\s+$file_expr" \ "\\s+at\\s+$file_expr" \
"\[0-9\]+\\s+.*return.* break here .*"] "$line_expr\\s+.*return.* break here .*"]
set re1_styled \ set re1_styled \
[multi_line \ [multi_line \
"#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+" \ "#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+" \
"\\s+$arg_expr=$hex.*\\)" \ "\\s+$arg_expr=$hex.*\\)" \
"\\s+at\\s+$file_expr" \ "\\s+at\\s+$file_expr" \
"\[0-9\]+\\s+.*return.* break here .*"] "$line_expr\\s+.*return.* break here .*"]
set re2_styled \ set re2_styled \
[multi_line \ [multi_line \
"#0\\s+$main_expr\\s+\\($arg_expr=.*" \ "#0\\s+$main_expr\\s+\\($arg_expr=.*" \
"\\s+$arg_expr=$hex.*\\)\\s+at\\s+$file_expr" \ "\\s+$arg_expr=$hex.*\\)\\s+at\\s+$file_expr" \
"\[0-9\]+\\s+.*return.* break here .*"] "$line_expr\\s+.*return.* break here .*"]
# The length of the line containing argv containing: # The length of the line containing argv containing:
# - 4 leading spaces # - 4 leading spaces

View File

@@ -64,7 +64,7 @@ proc string_list_to_regexp { args } {
# STYLE can either be the payload part of an ANSI terminal sequence, # STYLE can either be the payload part of an ANSI terminal sequence,
# or a shorthand for one of the gdb standard styles: "file", # or a shorthand for one of the gdb standard styles: "file",
# "function", "variable", or "address". # "function", "variable", "address", etc.
proc style {str style} { proc style {str style} {
switch -exact -- $style { switch -exact -- $style {
@@ -76,6 +76,7 @@ proc style {str style} {
address { set style 34 } address { set style 34 }
metadata { set style 2 } metadata { set style 2 }
version { set style "35;1" } version { set style "35;1" }
line-number { set style 2 }
none { return $str } none { return $str }
} }
return "\033\\\[${style}m${str}\033\\\[m" return "\033\\\[${style}m${str}\033\\\[m"

View File

@@ -791,7 +791,7 @@ proc runto { linespec args } {
# the "at foo.c:36" output we get with -g. # the "at foo.c:36" output we get with -g.
# the "in func" output we get without -g. # the "in func" output we get without -g.
gdb_expect { gdb_expect {
-re "(?:Break|Temporary break).* at .*:$decimal.*$gdb_prompt $" { -re "(?:Break|Temporary break).* at .*:.*$decimal.*$gdb_prompt $" {
if { $print_pass } { if { $print_pass } {
pass $test_name pass $test_name
} }

View File

@@ -2351,8 +2351,9 @@ tfind_line_command (const char *args, int from_tty)
{ {
if (start_pc == end_pc) if (start_pc == end_pc)
{ {
gdb_printf ("Line %d of \"%s\"", gdb_printf ("Line %ps of \"%s\"",
sal.line, styled_string (line_number_style.style (),
pulongest (sal.line)),
symtab_to_filename_for_display (sal.symtab)); symtab_to_filename_for_display (sal.symtab));
gdb_stdout->wrap_here (2); gdb_stdout->wrap_here (2);
gdb_printf (" is at address "); gdb_printf (" is at address ");
@@ -2363,8 +2364,9 @@ tfind_line_command (const char *args, int from_tty)
if (sal.line > 0 if (sal.line > 0
&& find_line_pc_range (sal, &start_pc, &end_pc) && find_line_pc_range (sal, &start_pc, &end_pc)
&& start_pc != end_pc) && start_pc != end_pc)
gdb_printf ("Attempting to find line %d instead.\n", gdb_printf ("Attempting to find line %ps instead.\n",
sal.line); styled_string (line_number_style.style (),
pulongest (sal.line)));
else else
error (_("Cannot find a good line.")); error (_("Cannot find a good line."));
} }
@@ -3644,7 +3646,7 @@ print_one_static_tracepoint_marker (int count,
else else
uiout->field_skip ("fullname"); uiout->field_skip ("fullname");
uiout->field_signed ("line", sal.line); uiout->field_signed ("line", sal.line, line_number_style.style ());
} }
else else
{ {

View File

@@ -32,6 +32,20 @@
#include "tui/tui-winsource.h" #include "tui/tui-winsource.h"
#include "tui/tui-source.h" #include "tui/tui-source.h"
#include "tui/tui-location.h" #include "tui/tui-location.h"
#include "tui/tui-io.h"
#include "cli/cli-style.h"
tui_source_window::tui_source_window ()
{
line_number_style.changed.attach
(std::bind (&tui_source_window::style_changed, this),
m_src_observable, "tui-source");
}
tui_source_window::~tui_source_window ()
{
line_number_style.changed.detach (m_src_observable);
}
/* Function to display source in the source window. */ /* Function to display source in the source window. */
bool bool
@@ -247,5 +261,7 @@ tui_source_window::show_line_number (int offset) const
tui_left_margin_verbose ? "%0*d%c" : "%*d%c", m_digits - 1, tui_left_margin_verbose ? "%0*d%c" : "%*d%c", m_digits - 1,
lineno, space); lineno, space);
} }
tui_apply_style (handle.get (), line_number_style.style ());
display_string (text); display_string (text);
tui_apply_style (handle.get (), ui_file_style ());
} }

View File

@@ -30,7 +30,8 @@
struct tui_source_window : public tui_source_window_base struct tui_source_window : public tui_source_window_base
{ {
tui_source_window () = default; tui_source_window ();
~tui_source_window ();
DISABLE_COPY_AND_ASSIGN (tui_source_window); DISABLE_COPY_AND_ASSIGN (tui_source_window);
@@ -81,6 +82,9 @@ private:
/* It is the resolved form as returned by symtab_to_fullname. */ /* It is the resolved form as returned by symtab_to_fullname. */
gdb::unique_xmalloc_ptr<char> m_fullname; gdb::unique_xmalloc_ptr<char> m_fullname;
/* A token used to register and unregister an observer. */
gdb::observers::token m_src_observable;
}; };
/* Return the instance of the source window. */ /* Return the instance of the source window. */

View File

@@ -189,6 +189,11 @@ public:
update_source_windows_with_addr. */ update_source_windows_with_addr. */
void update_source_window_with_addr (struct gdbarch *, CORE_ADDR); void update_source_window_with_addr (struct gdbarch *, CORE_ADDR);
protected:
/* Called when a user style setting is changed. */
void style_changed ();
private: private:
/* Used for horizontal scroll. */ /* Used for horizontal scroll. */
@@ -236,9 +241,6 @@ private:
the initial escape that sets the color will still be applied. */ the initial escape that sets the color will still be applied. */
void puts_to_pad_with_skip (const char *string, int skip); void puts_to_pad_with_skip (const char *string, int skip);
/* Called when the user "set style enabled" setting is changed. */
void style_changed ();
/* A token used to register and unregister an observer. */ /* A token used to register and unregister an observer. */
gdb::observers::token m_observable; gdb::observers::token m_observable;

View File

@@ -433,7 +433,8 @@ ui_out::end (ui_out_type type)
} }
void void
ui_out::field_signed (const char *fldname, LONGEST value) ui_out::field_signed (const char *fldname, LONGEST value,
const ui_file_style &style)
{ {
int fldno; int fldno;
int width; int width;
@@ -441,7 +442,7 @@ ui_out::field_signed (const char *fldname, LONGEST value)
verify_field (&fldno, &width, &align); verify_field (&fldno, &width, &align);
do_field_signed (fldno, width, align, fldname, value); do_field_signed (fldno, width, align, fldname, value, style);
} }
void void
@@ -454,7 +455,8 @@ ui_out::field_fmt_signed (int input_width, ui_align input_align,
verify_field (&fldno, &width, &align); verify_field (&fldno, &width, &align);
do_field_signed (fldno, input_width, input_align, fldname, value); do_field_signed (fldno, input_width, input_align, fldname, value,
ui_file_style ());
} }
/* See ui-out.h. */ /* See ui-out.h. */

View File

@@ -182,7 +182,8 @@ class ui_out
void begin (ui_out_type type, const char *id); void begin (ui_out_type type, const char *id);
void end (ui_out_type type); void end (ui_out_type type);
void field_signed (const char *fldname, LONGEST value); void field_signed (const char *fldname, LONGEST value,
const ui_file_style &style = ui_file_style ());
void field_fmt_signed (int width, ui_align align, const char *fldname, void field_fmt_signed (int width, ui_align align, const char *fldname,
LONGEST value); LONGEST value);
/* Like field_signed, but print an unsigned value. */ /* Like field_signed, but print an unsigned value. */
@@ -346,7 +347,8 @@ protected:
virtual void do_begin (ui_out_type type, const char *id) = 0; virtual void do_begin (ui_out_type type, const char *id) = 0;
virtual void do_end (ui_out_type type) = 0; virtual void do_end (ui_out_type type) = 0;
virtual void do_field_signed (int fldno, int width, ui_align align, virtual void do_field_signed (int fldno, int width, ui_align align,
const char *fldname, LONGEST value) = 0; const char *fldname, LONGEST value,
const ui_file_style &style) = 0;
virtual void do_field_unsigned (int fldno, int width, ui_align align, virtual void do_field_unsigned (int fldno, int width, ui_align align,
const char *fldname, ULONGEST value) = 0; const char *fldname, ULONGEST value) = 0;
virtual void do_field_skip (int fldno, int width, ui_align align, virtual void do_field_skip (int fldno, int width, ui_align align,

View File

@@ -819,7 +819,9 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
} }
/* Format the question outside of the loop, to avoid reusing args. */ /* Format the question outside of the loop, to avoid reusing args. */
std::string question = string_vprintf (ctlstr, args); string_file tem (gdb_stdout->can_emit_style_escape ());
gdb_vprintf (&tem, ctlstr, args);
std::string question = tem.release ();
std::string prompt std::string prompt
= string_printf (_("%s%s(%s or %s) %s"), = string_printf (_("%s%s(%s or %s) %s"),
annotation_level > 1 ? "\n\032\032pre-query\n" : "", annotation_level > 1 ? "\n\032\032pre-query\n" : "",