From 7f6aba03b929d3d893378760eeeca431005fc5cd Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 2 Apr 2019 20:00:18 -0600 Subject: [PATCH] Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) : New overload. : Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) : Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) : Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) : Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test. --- gdb/ChangeLog | 68 ++++++++++++++++++++++++++++++++ gdb/ada-lang.c | 5 ++- gdb/ada-tasks.c | 14 +++++-- gdb/ada-typeprint.c | 15 ++++--- gdb/ada-valprint.c | 18 ++++++--- gdb/break-catch-sig.c | 4 +- gdb/break-catch-syscall.c | 3 +- gdb/breakpoint.c | 8 ++-- gdb/c-typeprint.c | 32 +++++++++------ gdb/cli-out.c | 7 ++-- gdb/cli-out.h | 6 +-- gdb/cli/cli-style.c | 11 ++++++ gdb/cli/cli-style.h | 5 +++ gdb/cp-valprint.c | 19 +++++---- gdb/expprint.c | 6 ++- gdb/f-typeprint.c | 3 +- gdb/f-valprint.c | 6 ++- gdb/gnu-v3-abi.c | 4 +- gdb/infcmd.c | 4 +- gdb/m2-typeprint.c | 3 +- gdb/m2-valprint.c | 10 +++-- gdb/mi/mi-out.c | 4 +- gdb/mi/mi-out.h | 5 ++- gdb/p-lang.c | 5 ++- gdb/p-typeprint.c | 8 ++-- gdb/p-valprint.c | 16 +++++--- gdb/printcmd.c | 13 +++--- gdb/python/py-framefilter.c | 2 +- gdb/python/py-prettyprint.c | 8 ++-- gdb/rust-lang.c | 5 ++- gdb/skip.c | 8 +++- gdb/stack.c | 24 ++++++----- gdb/testsuite/ChangeLog | 5 +++ gdb/testsuite/gdb.base/style.exp | 4 ++ gdb/testsuite/lib/gdb-utils.exp | 1 + gdb/tracepoint.c | 17 +++++--- gdb/tui/tui-out.c | 6 +-- gdb/tui/tui-out.h | 5 ++- gdb/typeprint.c | 8 ++-- gdb/ui-out.c | 20 +++++++++- gdb/ui-out.h | 9 +++-- gdb/valprint.c | 30 ++++++++------ gdb/value.c | 4 +- 43 files changed, 331 insertions(+), 127 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 514a8bd99a..9494dc4adc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,71 @@ +2019-10-01 Tom Tromey + + * p-lang.c (pascal_printstr): Use metadata style. + * value.c (show_convenience): Use metadata style. + * valprint.c (valprint_check_validity, val_print_optimized_out) + (val_print_not_saved, val_print_unavailable) + (val_print_invalid_address, generic_val_print, val_print) + (value_check_printable, val_print_array_elements): Use metadata + style. + * ui-out.h (class ui_out) : New overload. + : Add style parameter. + * ui-out.c (ui_out::field_fmt): New overload. + * typeprint.c (type_print_unknown_return_type) + (val_print_not_allocated, val_print_not_associated): Use metadata + style. + * tui/tui-out.h (class tui_ui_out) : Add style + parameter. + * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. + * tracepoint.c (tvariables_info_1): Use metadata style. + * stack.c (print_frame_arg, print_frame_info, print_frame) + (info_frame_command_core): Use metadata style. + * skip.c (info_skip_command): Use metadata style. + * rust-lang.c (rust_print_enum): Use metadata style. + * python/py-prettyprint.c (print_stack_unless_memory_error): Use + metadata style. + * python/py-framefilter.c (py_print_single_arg): Use metadata + style. + * printcmd.c (do_one_display, print_variable_and_value): Use + metadata style. + * p-valprint.c (pascal_val_print) + (pascal_object_print_value_fields): Use metadata style. + * p-typeprint.c (pascal_type_print_base): Use metadata style. + * mi/mi-out.h (class mi_ui_out) : Add style + parameter. + * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. + * m2-valprint.c (m2_print_long_set): Use metadata style. + * m2-typeprint.c (m2_print_type): Use metadata style. + * infcmd.c (print_return_value_1): Use metadata style. + * gnu-v3-abi.c (print_one_vtable): Use metadata style. + * f-valprint.c (info_common_command_for_block): Use metadata + style. + * f-typeprint.c (f_type_print_base): Use metadata style. + * expprint.c (print_subexp_standard): Use metadata style. + * cp-valprint.c (cp_print_value_fields): Use metadata style. + * cli/cli-style.h (class cli_style_option): Add constructor. + (metadata_style): Declare. + * cli/cli-style.c (metadata_style): New global. + (_initialize_cli_style): Register metadata style. + * cli-out.h (class cli_ui_out) : Add style + parameter. + * cli-out.c (cli_ui_out::do_field_fmt): Update. + * c-typeprint.c (c_type_print_base_struct_union) + (c_type_print_base_1): Use metadata style. + * breakpoint.c (watchpoint_value_print) + (print_one_breakpoint_location): Use metadata style. + * break-catch-syscall.c (print_one_catch_syscall): Use metadata + style. + * break-catch-sig.c (signal_catchpoint_print_one): Use metadata + style. + * ada-valprint.c (val_print_packed_array_elements, printstr) + (print_field_values, ada_val_print_ref, ada_val_print): Use + metadata style. + * ada-typeprint.c (print_array_type, ada_print_type): Use metadata + style. + * ada-tasks.c (print_ada_task_info, info_task): Use metadata + style. + * ada-lang.c (user_select_syms): Use metadata style. + 2019-10-01 Tom Tromey * cli/cli-cmds.c (pwd_command): Style output. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 063b98bde5..846c9b4dec 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -54,6 +54,7 @@ #include "gdbsupport/gdb_vecs.h" #include "typeprint.h" #include "namespace.h" +#include "cli/cli-style.h" #include "psymtab.h" #include "value.h" @@ -3877,8 +3878,8 @@ See set/show multiple-symbol.")); ada_print_symbol_signature (gdb_stdout, syms[i].symbol, &type_print_raw_options); if (sal.symtab == NULL) - printf_filtered (_(" at :%d\n"), - sal.line); + printf_filtered (_(" at %p[%p]:%d\n"), + metadata_style.style ().ptr (), nullptr, sal.line); else printf_filtered (_(" at %s:%d\n"), symtab_to_filename_for_display (sal.symtab), diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 24ceab1fca..e4a52976dc 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -25,6 +25,7 @@ #include "gdbthread.h" #include "progspace.h" #include "objfiles.h" +#include "cli/cli-style.h" static int ada_build_task_list (); @@ -1163,9 +1164,14 @@ print_ada_task_info (struct ui_out *uiout, /* Finally, print the task name, without quotes around it, as mi like is not expecting quotes, and in non mi-like no need for quotes as there is a specific column for the name. */ - uiout->field_string ("name", - task_info->name[0] != '\0' ? task_info->name - : _("")); + uiout->field_fmt ("name", + (task_info->name[0] != '\0' + ? ui_file_style () + : metadata_style.style ()), + "%s", + (task_info->name[0] != '\0' + ? task_info->name + : _(""))); uiout->text ("\n"); } @@ -1201,7 +1207,7 @@ info_task (struct ui_out *uiout, const char *taskno_str, struct inferior *inf) if (task_info->name[0] != '\0') printf_filtered (_("Name: %s\n"), task_info->name); else - printf_filtered (_("\n")); + fprintf_styled (gdb_stdout, metadata_style.style (), _("\n")); /* Print the TID and LWP. */ printf_filtered (_("Thread: %#lx\n"), task_info->ptid.tid ()); diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index 89a69e9bd4..c2461660ad 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -393,7 +393,8 @@ print_array_type (struct type *type, struct ui_file *stream, int show, if (type == NULL) { - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), + _("")); return; } @@ -838,7 +839,7 @@ ada_print_type (struct type *type0, const char *varstring, if (is_var_decl) fprintf_filtered (stream, "%.*s: ", ada_name_prefix_len (varstring), varstring); - fprintf_filtered (stream, ""); + fprintf_styled (stream, metadata_style.style (), ""); return; } @@ -894,8 +895,9 @@ ada_print_type (struct type *type0, const char *varstring, const char *name = ada_type_name (type); if (!ada_is_range_type_name (name)) - fprintf_filtered (stream, _("<%s-byte integer>"), - pulongest (TYPE_LENGTH (type))); + fprintf_styled (stream, metadata_style.style (), + _("<%s-byte integer>"), + pulongest (TYPE_LENGTH (type))); else { fprintf_filtered (stream, "range "); @@ -916,8 +918,9 @@ ada_print_type (struct type *type0, const char *varstring, } break; case TYPE_CODE_FLT: - fprintf_filtered (stream, _("<%s-byte float>"), - pulongest (TYPE_LENGTH (type))); + fprintf_styled (stream, metadata_style.style (), + _("<%s-byte float>"), + pulongest (TYPE_LENGTH (type))); break; case TYPE_CODE_ENUM: if (show < 0) diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 3060eb676b..714b6259ec 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -32,6 +32,7 @@ #include "infcall.h" #include "objfiles.h" #include "target-float.h" +#include "cli/cli-style.h" static int print_field_values (struct type *, const gdb_byte *, int, @@ -237,7 +238,8 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, value_embedded_offset (v0), 0, stream, recurse + 1, v0, &opts, current_language); annotate_elt_rep (i - i0); - fprintf_filtered (stream, _(" "), i - i0); + fprintf_filtered (stream, _(" %p[%p]"), + metadata_style.style ().ptr (), i - i0, nullptr); annotate_elt_rep_end (); } @@ -527,7 +529,8 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string, ada_emit_char (char_at (string, i, type_len, byte_order), elttype, stream, '\'', type_len); fputs_filtered ("'", stream); - fprintf_filtered (stream, _(" "), reps); + fprintf_filtered (stream, _(" %p[%p]"), + metadata_style.style ().ptr (), reps, nullptr); i = rep1 - 1; things_printed += options->repeat_count_threshold; need_comma = 1; @@ -671,7 +674,8 @@ print_field_values (struct type *type, const gdb_byte *valaddr, order problems. */ if (HAVE_CPLUS_STRUCT (type) && TYPE_FIELD_IGNORE (type, i)) { - fputs_filtered (_(""), stream); + fputs_styled (_(""), + metadata_style.style (), stream); } else { @@ -1069,7 +1073,8 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr, if (TYPE_CODE (elttype) == TYPE_CODE_UNDEF) { - fputs_filtered ("", stream); + fputs_styled ("", metadata_style.style (), + stream); return; } @@ -1212,8 +1217,9 @@ ada_val_print (struct type *type, } catch (const gdb_exception_error &except) { - fprintf_filtered (stream, _(""), - except.what ()); + fprintf_styled (stream, metadata_style.style (), + _(""), + except.what ()); } } diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c index 53540ee832..c475e8aca5 100644 --- a/gdb/break-catch-sig.c +++ b/gdb/break-catch-sig.c @@ -28,6 +28,7 @@ #include "valprint.h" #include "cli/cli-utils.h" #include "completer.h" +#include "cli/cli-style.h" #include @@ -241,7 +242,8 @@ signal_catchpoint_print_one (struct breakpoint *b, } else uiout->field_string ("what", - c->catch_all ? "" : ""); + c->catch_all ? "" : "", + metadata_style.style ()); uiout->text ("\" "); if (uiout->is_mi_like_p ()) diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index a165be62be..dde80b54a2 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -29,6 +29,7 @@ #include "arch-utils.h" #include "observable.h" #include "xml-syscall.h" +#include "cli/cli-style.h" /* An instance of this type is used to represent a syscall catchpoint. A breakpoint is really of this type iff its ops pointer points to @@ -273,7 +274,7 @@ print_one_catch_syscall (struct breakpoint *b, xfree (text); } else - uiout->field_string ("what", ""); + uiout->field_string ("what", "", metadata_style.style ()); uiout->text ("\" "); if (uiout->is_mi_like_p ()) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 2030687728..0a70516338 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4457,7 +4457,7 @@ static void watchpoint_value_print (struct value *val, struct ui_file *stream) { if (val == NULL) - fprintf_unfiltered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), _("")); else { struct value_print_options opts; @@ -6055,9 +6055,11 @@ print_one_breakpoint_location (struct breakpoint *b, { annotate_field (4); if (header_of_multiple) - uiout->field_string ("addr", ""); + uiout->field_string ("addr", "", + metadata_style.style ()); else if (b->loc == NULL || loc->shlib_disabled) - uiout->field_string ("addr", ""); + uiout->field_string ("addr", "", + metadata_style.style ()); else uiout->field_core_addr ("addr", loc->gdbarch, loc->address); diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 43ad3b3e0e..1a37c4edfb 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -1116,10 +1116,12 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, { if (TYPE_STUB (type)) fprintfi_filtered (level + 4, stream, - _("\n")); + _("%p[%p]\n"), + metadata_style.style ().ptr (), nullptr); else fprintfi_filtered (level + 4, stream, - _("\n")); + _("%p[%p]\n"), + metadata_style.style ().ptr (), nullptr); } /* Start off with no specific section type, so we can print @@ -1277,7 +1279,8 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, { /* Keep GDB from crashing here. */ fprintf_filtered (stream, - _(" %s;\n"), + _("%p[%p] %s;\n"), + metadata_style.style ().ptr (), nullptr, TYPE_FN_FIELD_PHYSNAME (f, j)); break; } @@ -1325,9 +1328,9 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, &local_flags); } else - fprintf_filtered (stream, - _(""), - mangled_name); + fprintf_styled (stream, metadata_style.style (), + _(""), + mangled_name); } else { @@ -1465,7 +1468,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, if (type == NULL) { - fputs_filtered (_(""), stream); + fputs_styled (_(""), metadata_style.style (), stream); return; } @@ -1511,7 +1514,8 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, couldn't resolve TYPE_TARGET_TYPE. Not much we can do. */ gdb_assert (TYPE_NAME (type) == NULL); gdb_assert (TYPE_TARGET_TYPE (type) == NULL); - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), + _("")); break; case TYPE_CODE_FUNC: @@ -1622,10 +1626,12 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, { if (TYPE_STUB (type)) fprintfi_filtered (level + 4, stream, - _("\n")); + _("%p[%p]\n"), + metadata_style.style ().ptr (), nullptr); else fprintfi_filtered (level + 4, stream, - _("\n")); + _("%p[%p]\n"), + metadata_style.style ().ptr (), nullptr); } len = TYPE_NFIELDS (type); for (i = 0; i < len; i++) @@ -1668,7 +1674,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, case TYPE_CODE_RANGE: /* This should not occur. */ - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), _("")); break; case TYPE_CODE_NAMESPACE: @@ -1690,8 +1696,8 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, { /* At least for dump_symtab, it is important that this not be an error (). */ - fprintf_filtered (stream, _(""), - TYPE_CODE (type)); + fprintf_styled (stream, metadata_style.style (), + _(""), TYPE_CODE (type)); } break; } diff --git a/gdb/cli-out.c b/gdb/cli-out.c index c713607e06..702e4e4dfe 100644 --- a/gdb/cli-out.c +++ b/gdb/cli-out.c @@ -188,16 +188,15 @@ cli_ui_out::do_field_string (int fldno, int width, ui_align align, void cli_ui_out::do_field_fmt (int fldno, int width, ui_align align, - const char *fldname, const char *format, - va_list args) + const char *fldname, const ui_file_style &style, + const char *format, va_list args) { if (m_suppress_output) return; std::string str = string_vprintf (format, args); - do_field_string (fldno, width, align, fldname, str.c_str (), - ui_file_style ()); + do_field_string (fldno, width, align, fldname, str.c_str (), style); } void diff --git a/gdb/cli-out.h b/gdb/cli-out.h index d7bd23b0ef..7d5b4febba 100644 --- a/gdb/cli-out.h +++ b/gdb/cli-out.h @@ -59,9 +59,9 @@ protected: const char *string, const ui_file_style &style) override; virtual void do_field_fmt (int fldno, int width, ui_align align, - const char *fldname, const char *format, - va_list args) - override ATTRIBUTE_PRINTF (6,0); + const char *fldname, const ui_file_style &style, + const char *format, va_list args) + override ATTRIBUTE_PRINTF (7, 0); virtual void do_spaces (int numspaces) override; virtual void do_text (const char *string) override; virtual void do_message (const ui_file_style &style, diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index ea301774d2..a0c5c0a950 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -85,6 +85,10 @@ cli_style_option title_style ("title", ui_file_style::BOLD); /* See cli-style.h. */ +cli_style_option metadata_style ("metadata", ui_file_style::DIM); + +/* See cli-style.h. */ + cli_style_option::cli_style_option (const char *name, ui_file_style::basic_color fg) : m_name (name), @@ -372,4 +376,11 @@ Highlight display styling.\n\ Configure highlight colors and display intensity\n\ Some commands use the highlight style to draw the attention to a part\n\ of their output.")); + + STYLE_ADD_SETSHOW_COMMANDS (metadata_style, + _("\ +Metadata display styling\n\ +Configure metadata colors and display intensity\n\ +The \"metadata\" style is used when GDB displays information about\n\ +your data, for example \"\"")); } diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h index 826162f578..6716471dec 100644 --- a/gdb/cli/cli-style.h +++ b/gdb/cli/cli-style.h @@ -34,6 +34,9 @@ public: /* Construct a CLI style option with an intensity. */ cli_style_option (const char *name, ui_file_style::intensity i); + /* Construct a CLI style option with an intensity. */ + cli_style_option (ui_file_style::intensity val); + /* Return a ui_file_style corresponding to the settings in this CLI style. */ ui_file_style style () const; @@ -108,6 +111,8 @@ extern cli_style_option highlight_style; /* The title style. */ extern cli_style_option title_style; +/* The metadata style. */ +extern cli_style_option metadata_style; /* True if source styling is enabled. */ extern bool source_styling; diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 530d8c5269..e73b0e27fa 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -37,6 +37,7 @@ #include "typeprint.h" #include "gdbsupport/byte-vector.h" #include "gdbarch.h" +#include "cli/cli-style.h" static struct obstack dont_print_vb_obstack; static struct obstack dont_print_statmem_obstack; @@ -170,7 +171,7 @@ cp_print_value_fields (struct type *type, struct type *real_type, /* If there are no data fields, skip this part */ if (len == n_baseclasses || !len) - fprintf_filtered (stream, ""); + fprintf_styled (stream, metadata_style.style (), ""); else { size_t statmem_obstack_initial_size = 0; @@ -268,7 +269,8 @@ cp_print_value_fields (struct type *type, struct type *real_type, byte order problems. */ if (TYPE_FIELD_IGNORE (type, i)) { - fputs_filtered ("", stream); + fputs_styled ("", + metadata_style.style (), stream); } else if (value_bits_synthetic_pointer (val, TYPE_FIELD_BITPOS (type, @@ -276,7 +278,8 @@ cp_print_value_fields (struct type *type, struct type *real_type, TYPE_FIELD_BITSIZE (type, i))) { - fputs_filtered (_(""), stream); + fputs_styled (_(""), + metadata_style.style (), stream); } else { @@ -292,8 +295,8 @@ cp_print_value_fields (struct type *type, struct type *real_type, { if (TYPE_FIELD_IGNORE (type, i)) { - fputs_filtered ("", - stream); + fputs_styled ("", + metadata_style.style (), stream); } else if (field_is_static (&TYPE_FIELD (type, i))) { @@ -307,9 +310,9 @@ cp_print_value_fields (struct type *type, struct type *real_type, } catch (const gdb_exception_error &ex) { - fprintf_filtered (stream, - _(""), - ex.what ()); + fprintf_styled (stream, metadata_style.style (), + _(""), + ex.what ()); } } else if (i == vptr_fieldno && type == vptr_basetype) diff --git a/gdb/expprint.c b/gdb/expprint.c index d7ad1a7187..c98638ab7f 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -29,6 +29,7 @@ #include "block.h" #include "objfiles.h" #include "valprint.h" +#include "cli/cli-style.h" #include @@ -510,8 +511,9 @@ print_subexp_standard (struct expression *exp, int *pos, if (exp->language_defn->la_name_of_this) fputs_filtered (exp->language_defn->la_name_of_this, stream); else - fprintf_filtered (stream, _(""), - exp->language_defn->la_name); + fprintf_styled (stream, metadata_style.style (), + _(""), + exp->language_defn->la_name); return; /* Modula-2 ops */ diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index 92b5093874..0093aebddc 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -31,6 +31,7 @@ #include "target.h" #include "f-lang.h" #include "typeprint.h" +#include "cli/cli-style.h" #if 0 /* Currently unused. */ static void f_type_print_args (struct type *, struct ui_file *); @@ -325,7 +326,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show, wrap_here (" "); if (type == NULL) { - fputs_filtered ("", stream); + fputs_styled ("", metadata_style.style (), stream); return; } diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 264416ec54..f9d49233fc 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -33,6 +33,7 @@ #include "command.h" #include "block.h" #include "dictionary.h" +#include "cli/cli-style.h" static void f77_get_dynamic_length_of_aggregate (struct type *); @@ -415,8 +416,9 @@ info_common_command_for_block (const struct block *block, const char *comname, catch (const gdb_exception_error &except) { - printf_filtered ("", - except.what ()); + fprintf_styled (gdb_stdout, metadata_style.style (), + "", + except.what ()); } putchar_filtered ('\n'); diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 6407c9beb8..1d4e43ad7f 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -28,6 +28,7 @@ #include "c-lang.h" #include "typeprint.h" #include +#include "cli/cli-style.h" static struct cp_abi_ops gnu_v3_abi_ops; @@ -912,7 +913,8 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value, } catch (const gdb_exception_error &ex) { - printf_filtered (_(""), ex.what ()); + fprintf_styled (gdb_stdout, metadata_style.style (), + _(""), ex.what ()); got_error = 1; } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index dc82ef043f..20523fed53 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -60,6 +60,7 @@ #include "interps.h" #include "gdbsupport/gdb_optional.h" #include "source.h" +#include "cli/cli-style.h" /* Local functions: */ @@ -1628,7 +1629,8 @@ print_return_value_1 (struct ui_out *uiout, struct return_value_info *rv) uiout->field_stream ("return-value", stb); } else - uiout->field_string ("return-value", _("")); + uiout->field_string ("return-value", _(""), + metadata_style.style ()); uiout->text ("\n"); } else diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c index dae07d1c53..3c1a8d2aed 100644 --- a/gdb/m2-typeprint.c +++ b/gdb/m2-typeprint.c @@ -31,6 +31,7 @@ #include "c-lang.h" #include "typeprint.h" #include "cp-abi.h" +#include "cli/cli-style.h" static void m2_print_bounds (struct type *type, struct ui_file *stream, int show, int level, @@ -81,7 +82,7 @@ m2_print_type (struct type *type, const char *varstring, wrap_here (" "); if (type == NULL) { - fputs_filtered (_(""), stream); + fputs_styled (_(""), metadata_style.style (), stream); return; } diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index 74f89ee45f..4dc0fe18e6 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -28,6 +28,7 @@ #include "c-lang.h" #include "m2-lang.h" #include "target.h" +#include "cli/cli-style.h" static int print_unpacked_pointer (struct type *type, CORE_ADDR address, CORE_ADDR addr, @@ -92,7 +93,8 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr, } else { - fprintf_filtered (stream, " %s }", _("")); + fprintf_styled (stream, metadata_style.style (), + " %s }", _("")); return; } @@ -407,7 +409,8 @@ m2_val_print (struct type *type, int embedded_offset, elttype = check_typedef (elttype); if (TYPE_STUB (elttype)) { - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), + _("")); break; } else @@ -423,7 +426,8 @@ m2_val_print (struct type *type, int embedded_offset, maybe_bad_bstring: if (i < 0) { - fputs_filtered (_(""), stream); + fputs_styled (_(""), metadata_style.style (), + stream); goto done; } diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c index 71af4865e9..ad4252f712 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -141,8 +141,8 @@ mi_ui_out::do_field_string (int fldno, int width, ui_align align, void mi_ui_out::do_field_fmt (int fldno, int width, ui_align align, - const char *fldname, const char *format, - va_list args) + const char *fldname, const ui_file_style &style, + const char *format, va_list args) { ui_file *stream = m_streams.back (); field_separator (); diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h index 9393809b5f..c8b42c295e 100644 --- a/gdb/mi/mi-out.h +++ b/gdb/mi/mi-out.h @@ -68,8 +68,9 @@ protected: const char *fldname, const char *string, const ui_file_style &style) override; virtual void do_field_fmt (int fldno, int width, ui_align align, - const char *fldname, const char *format, va_list args) - override ATTRIBUTE_PRINTF (6,0); + const char *fldname, const ui_file_style &style, + const char *format, va_list args) + override ATTRIBUTE_PRINTF (7,0); virtual void do_spaces (int numspaces) override; virtual void do_text (const char *string) override; virtual void do_message (const ui_file_style &style, diff --git a/gdb/p-lang.c b/gdb/p-lang.c index cfe2a88872..95911158d1 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -32,6 +32,7 @@ #include #include "c-lang.h" #include "gdbarch.h" +#include "cli/cli-style.h" /* All GPC versions until now (2007-09-27) also define a symbol called '_p_initialize'. Check for the presence of this symbol first. */ @@ -292,7 +293,9 @@ pascal_printstr (struct ui_file *stream, struct type *type, in_quotes = 0; } pascal_printchar (current_char, type, stream); - fprintf_filtered (stream, " ", reps); + fprintf_filtered (stream, " %p[%p]", + metadata_style.style ().ptr (), + reps, nullptr); i = rep1 - 1; things_printed += options->repeat_count_threshold; need_comma = 1; diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index d90b8ceb6e..fadc44eaee 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -32,6 +32,7 @@ #include "typeprint.h" #include "gdb-demangle.h" #include +#include "cli/cli-style.h" static void pascal_type_print_varspec_suffix (struct type *, struct ui_file *, int, int, int, @@ -470,7 +471,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, wrap_here (" "); if (type == NULL) { - fputs_filtered ("", stream); + fputs_styled ("", metadata_style.style (), stream); return; } @@ -827,8 +828,9 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, { /* At least for dump_symtab, it is important that this not be an error (). */ - fprintf_filtered (stream, "", - TYPE_CODE (type)); + fprintf_styled (stream, metadata_style.style (), + "", + TYPE_CODE (type)); } break; } diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index a3738a9252..10612f3bab 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -39,6 +39,7 @@ #include "cp-support.h" #include "objfiles.h" #include "gdbsupport/byte-vector.h" +#include "cli/cli-style.h" /* Decorations for Pascal. */ @@ -347,7 +348,7 @@ pascal_val_print (struct type *type, elttype = check_typedef (elttype); if (TYPE_STUB (elttype)) { - fprintf_filtered (stream, ""); + fprintf_styled (stream, metadata_style.style (), ""); break; } else @@ -370,7 +371,7 @@ pascal_val_print (struct type *type, maybe_bad_bstring: if (bound_info < 0) { - fputs_filtered ("", stream); + fputs_styled ("", metadata_style.style (), stream); goto done; } @@ -557,7 +558,7 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr, options, dont_print_vb); if (!len && n_baseclasses == 1) - fprintf_filtered (stream, ""); + fprintf_styled (stream, metadata_style.style (), ""); else { struct obstack tmp_obstack = dont_print_statmem_obstack; @@ -622,7 +623,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr, order problems. */ if (TYPE_FIELD_IGNORE (type, i)) { - fputs_filtered ("", stream); + fputs_styled ("", + metadata_style.style (), stream); } else if (value_bits_synthetic_pointer (val, TYPE_FIELD_BITPOS (type, @@ -630,7 +632,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr, TYPE_FIELD_BITSIZE (type, i))) { - fputs_filtered (_(""), stream); + fputs_styled (_(""), + metadata_style.style (), stream); } else { @@ -647,7 +650,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr, { if (TYPE_FIELD_IGNORE (type, i)) { - fputs_filtered ("", stream); + fputs_styled ("", + metadata_style.style (), stream); } else if (field_is_static (&TYPE_FIELD (type, i))) { diff --git a/gdb/printcmd.c b/gdb/printcmd.c index c17afe29bb..ea00f083b1 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2001,8 +2001,9 @@ do_one_display (struct display *d) } catch (const gdb_exception_error &ex) { - fprintf_filtered (gdb_stdout, _("\n"), - ex.what ()); + fprintf_filtered (gdb_stdout, _("%p[%p]\n"), + metadata_style.style ().ptr (), ex.what (), + nullptr); } } else @@ -2035,7 +2036,8 @@ do_one_display (struct display *d) } catch (const gdb_exception_error &ex) { - fprintf_filtered (gdb_stdout, _(""), ex.what ()); + fprintf_styled (gdb_stdout, metadata_style.style (), + _(""), ex.what ()); } printf_filtered ("\n"); @@ -2237,8 +2239,9 @@ print_variable_and_value (const char *name, struct symbol *var, } catch (const gdb_exception_error &except) { - fprintf_filtered (stream, "", name, - except.what ()); + fprintf_styled (stream, metadata_style.style (), + "", name, + except.what ()); } fprintf_filtered (stream, "\n"); diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index f82a239c2a..4dd6243ae9 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -397,7 +397,7 @@ py_print_single_arg (struct ui_out *out, if (val == NULL) { gdb_assert (fa != NULL && fa->error != NULL); - out->field_fmt ("value", + out->field_fmt ("value", metadata_style.style (), _(""), fa->error.get ()); } diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index fdc520d844..a4df48fe19 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -25,6 +25,7 @@ #include "extension-priv.h" #include "python.h" #include "python-internal.h" +#include "cli/cli-style.h" /* Return type of print_string_repr. */ @@ -259,10 +260,11 @@ print_stack_unless_memory_error (struct ui_file *stream) gdb::unique_xmalloc_ptr msg = fetched_error.to_string (); if (msg == NULL || *msg == '\0') - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), + _("")); else - fprintf_filtered (stream, _(""), - msg.get ()); + fprintf_styled (stream, metadata_style.style (), + _(""), msg.get ()); } else gdbpy_print_stack (); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 79f13311cd..cef0a9cb09 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -37,6 +37,7 @@ #include #include #include +#include "cli/cli-style.h" /* See rust-lang.h. */ @@ -473,7 +474,9 @@ rust_print_enum (struct type *type, int embedded_offset, if (rust_empty_enum_p (type)) { /* Print the enum type name here to be more clear. */ - fprintf_filtered (stream, _("%s {}"), TYPE_NAME (type)); + fprintf_filtered (stream, _("%s {%p[%p]}"), + TYPE_NAME (type), + metadata_style.style ().ptr (), nullptr); return; } diff --git a/gdb/skip.c b/gdb/skip.c index fcf41bf79a..cc10692f49 100644 --- a/gdb/skip.c +++ b/gdb/skip.c @@ -415,7 +415,9 @@ info_skip_command (const char *arg, int from_tty) current_uiout->field_string ("file", e.file ().empty () ? "" : e.file ().c_str (), - file_name_style.style ()); /* 4 */ + e.file ().empty () + ? metadata_style.style () + : file_name_style.style ()); /* 4 */ if (e.function_is_regexp ()) current_uiout->field_string ("regexp", "y"); /* 5 */ else @@ -424,7 +426,9 @@ info_skip_command (const char *arg, int from_tty) current_uiout->field_string ("function", e.function ().empty () ? "" : e.function ().c_str (), - function_name_style.style ()); /* 6 */ + e.function ().empty () + ? metadata_style.style () + : function_name_style.style ()); /* 6 */ current_uiout->text ("\n"); } diff --git a/gdb/stack.c b/gdb/stack.c index 4899d0f416..cb07e28b67 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -386,12 +386,16 @@ print_frame_arg (const frame_print_options &fp_opts, annotate_arg_name_end (); uiout->text ("="); + ui_file_style style; if (!arg->val && !arg->error) uiout->text ("..."); else { if (arg->error) - stb.printf (_(""), arg->error.get ()); + { + stb.printf (_(""), arg->error.get ()); + style = metadata_style.style (); + } else { try @@ -428,11 +432,12 @@ print_frame_arg (const frame_print_options &fp_opts, { stb.printf (_(""), except.what ()); + style = metadata_style.style (); } } } - uiout->field_stream ("value", stb); + uiout->field_stream ("value", stb, style); } /* Read in inferior function local SYM at FRAME into ARGP. Caller is @@ -1006,18 +1011,18 @@ print_frame_info (const frame_print_options &fp_opts, { annotate_function_call (); uiout->field_string ("func", "", - function_name_style.style ()); + metadata_style.style ()); } else if (get_frame_type (frame) == SIGTRAMP_FRAME) { annotate_signal_handler_caller (); uiout->field_string ("func", "", - function_name_style.style ()); + metadata_style.style ()); } else if (get_frame_type (frame) == ARCH_FRAME) { uiout->field_string ("func", "", - function_name_style.style ()); + metadata_style.style ()); } uiout->text ("\n"); annotate_frame_end (); @@ -1311,7 +1316,7 @@ print_frame (const frame_print_options &fp_opts, print_pc (uiout, gdbarch, frame, pc); else uiout->field_string ("addr", "", - address_style.style ()); + metadata_style.style ()); annotate_frame_address_end (); uiout->text (" in "); } @@ -1508,7 +1513,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p) if (frame_pc_p) fputs_filtered (paddress (gdbarch, get_frame_pc (fi)), gdb_stdout); else - fputs_filtered ("", gdb_stdout); + fputs_styled ("", metadata_style.style (), gdb_stdout); wrap_here (" "); if (funname) @@ -1545,8 +1550,9 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p) val_print_not_saved (gdb_stdout); break; default: - fprintf_filtered (gdb_stdout, _(""), - ex.what ()); + fprintf_styled (gdb_stdout, metadata_style.style (), + _(""), + ex.what ()); break; } } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 88cec5dfb3..784daf2e53 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-01 Tom Tromey + + * lib/gdb-utils.exp (style): Handle "metadata" argument. + * gdb.base/style.exp: Add metadata style test. + 2019-10-01 Tom Tromey * gdb.base/style.exp: Test "pwd". diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index fb0dfed006..0f812f7f1b 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -133,4 +133,8 @@ save_vars { env(TERM) } { "filename is styled when loading symbol file" gdb_test "pwd" "Working directory [style .*? file].*" + + gdb_test_no_output "set print repeat 3" + gdb_test "print {0,0,0,0,0,0,0,0}" \ + " = \\{0 [style {} metadata]\\}" } diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp index 89767dc51c..95ca348dc3 100644 --- a/gdb/testsuite/lib/gdb-utils.exp +++ b/gdb/testsuite/lib/gdb-utils.exp @@ -54,6 +54,7 @@ proc style {str style} { highlight { set style 31 } variable { set style 36 } address { set style 34 } + metadata { set style 2 } } return "\033\\\[${style}m${str}\033\\\[m" } diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 2f91e49efd..843341aaae 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -436,6 +436,7 @@ tvariables_info_1 (void) uiout->field_string ("name", std::string ("$") + tsv.name); uiout->field_string ("initial", plongest (tsv.initial_value)); + ui_file_style style; if (tsv.value_known) c = plongest (tsv.value); else if (uiout->is_mi_like_p ()) @@ -444,13 +445,19 @@ tvariables_info_1 (void) undefined does not seem important enough to represent. */ c = NULL; else if (current_trace_status ()->running || traceframe_number >= 0) - /* The value is/was defined, but we don't have it. */ - c = ""; + { + /* The value is/was defined, but we don't have it. */ + c = ""; + style = metadata_style.style (); + } else - /* It is not meaningful to ask about the value. */ - c = ""; + { + /* It is not meaningful to ask about the value. */ + c = ""; + style = metadata_style.style (); + } if (c) - uiout->field_string ("current", c); + uiout->field_string ("current", c, style); uiout->text ("\n"); } } diff --git a/gdb/tui/tui-out.c b/gdb/tui/tui-out.c index d415e7b64a..0d3f3be988 100644 --- a/gdb/tui/tui-out.c +++ b/gdb/tui/tui-out.c @@ -70,15 +70,15 @@ tui_ui_out::do_field_string (int fldno, int width, ui_align align, void tui_ui_out::do_field_fmt (int fldno, int width, ui_align align, - const char *fldname, const char *format, - va_list args) + const char *fldname, const ui_file_style &style, + const char *format, va_list args) { if (suppress_output ()) return; m_start_of_line++; - cli_ui_out::do_field_fmt (fldno, width, align, fldname, format, args); + cli_ui_out::do_field_fmt (fldno, width, align, fldname, style, format, args); } void diff --git a/gdb/tui/tui-out.h b/gdb/tui/tui-out.h index 9df9e93aa9..2b856af488 100644 --- a/gdb/tui/tui-out.h +++ b/gdb/tui/tui-out.h @@ -37,8 +37,9 @@ protected: void do_field_string (int fldno, int width, ui_align align, const char *fldname, const char *string, const ui_file_style &style) override; void do_field_fmt (int fldno, int width, ui_align align, const char *fldname, - const char *format, va_list args) override - ATTRIBUTE_PRINTF (6,0); + const ui_file_style &style, + const char *format, va_list args) override + ATTRIBUTE_PRINTF (7, 0); void do_text (const char *string) override; private: diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 41d95c2afb..357b88db53 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -36,6 +36,7 @@ #include "cli/cli-utils.h" #include "extension.h" #include "completer.h" +#include "cli/cli-style.h" const struct type_print_options type_print_raw_options = { @@ -415,7 +416,8 @@ type_to_string (struct type *type) void type_print_unknown_return_type (struct ui_file *stream) { - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), + _("")); } /* See typeprint.h. */ @@ -862,7 +864,7 @@ Show the number of recursive nested type definitions to print."), NULL, void val_print_not_allocated (struct ui_file *stream) { - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), _("")); } /* Print status to stream STREAM. */ @@ -870,5 +872,5 @@ val_print_not_allocated (struct ui_file *stream) void val_print_not_associated (struct ui_file *stream) { - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), _("")); } diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 8cbaa4e0bc..a64c79481c 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -545,7 +545,25 @@ ui_out::field_fmt (const char *fldname, const char *format, ...) va_start (args, format); - do_field_fmt (fldno, width, align, fldname, format, args); + do_field_fmt (fldno, width, align, fldname, ui_file_style (), format, args); + + va_end (args); +} + +void +ui_out::field_fmt (const char *fldname, const ui_file_style &style, + const char *format, ...) +{ + va_list args; + int fldno; + int width; + ui_align align; + + verify_field (&fldno, &width, &align); + + va_start (args, format); + + do_field_fmt (fldno, width, align, fldname, style, format, args); va_end (args); } diff --git a/gdb/ui-out.h b/gdb/ui-out.h index 0bba1280fc..5c96a7825b 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -194,6 +194,9 @@ class ui_out void field_skip (const char *fldname); void field_fmt (const char *fldname, const char *format, ...) ATTRIBUTE_PRINTF (3, 4); + void field_fmt (const char *fldname, const ui_file_style &style, + const char *format, ...) + ATTRIBUTE_PRINTF (4, 5); void spaces (int numspaces); void text (const char *string); @@ -291,9 +294,9 @@ class ui_out const char *fldname, const char *string, const ui_file_style &style) = 0; virtual void do_field_fmt (int fldno, int width, ui_align align, - const char *fldname, const char *format, - va_list args) - ATTRIBUTE_PRINTF (6,0) = 0; + const char *fldname, const ui_file_style &style, + const char *format, va_list args) + ATTRIBUTE_PRINTF (7, 0) = 0; virtual void do_spaces (int numspaces) = 0; virtual void do_text (const char *string) = 0; virtual void do_message (const ui_file_style &style, diff --git a/gdb/valprint.c b/gdb/valprint.c index e5b28f3ee9..919ab93821 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -38,6 +38,7 @@ #include "gdbsupport/byte-vector.h" #include "cli/cli-option.h" #include "gdbarch.h" +#include "cli/cli-style.h" /* Maximum number of wchars returned from wchar_iterate. */ #define MAX_WCHARS 4 @@ -347,7 +348,8 @@ valprint_check_validity (struct ui_file *stream, } if (!is_ref || !ref_is_addressable) - fputs_filtered (_(""), stream); + fputs_styled (_(""), metadata_style.style (), + stream); /* C++ references should be valid even if they're synthetic. */ return is_ref; @@ -369,25 +371,25 @@ val_print_optimized_out (const struct value *val, struct ui_file *stream) if (val != NULL && value_lval_const (val) == lval_register) val_print_not_saved (stream); else - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), _("")); } void val_print_not_saved (struct ui_file *stream) { - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), _("")); } void val_print_unavailable (struct ui_file *stream) { - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), _("")); } void val_print_invalid_address (struct ui_file *stream) { - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), _("")); } /* Print a pointer based on the type of its target. @@ -988,7 +990,7 @@ generic_val_print (struct type *type, /* This happens (without TYPE_STUB set) on systems which don't use dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" and no complete type for struct foo in that file. */ - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), _("")); break; case TYPE_CODE_COMPLEX: @@ -1047,7 +1049,7 @@ val_print (struct type *type, LONGEST embedded_offset, if (TYPE_STUB (real_type)) { - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), _("")); return; } @@ -1084,7 +1086,8 @@ val_print (struct type *type, LONGEST embedded_offset, } catch (const gdb_exception_error &except) { - fprintf_filtered (stream, _("")); + fprintf_styled (stream, metadata_style.style (), + _("")); } } @@ -1115,7 +1118,8 @@ value_check_printable (struct value *val, struct ui_file *stream, { if (val == 0) { - fprintf_filtered (stream, _("
")); + fprintf_styled (stream, metadata_style.style (), + _("
")); return 0; } @@ -1139,8 +1143,9 @@ value_check_printable (struct value *val, struct ui_file *stream, if (TYPE_CODE (value_type (val)) == TYPE_CODE_INTERNAL_FUNCTION) { - fprintf_filtered (stream, _(""), - value_internal_function_name (val)); + fprintf_styled (stream, metadata_style.style (), + _(""), + value_internal_function_name (val)); return 0; } @@ -2069,7 +2074,8 @@ val_print_array_elements (struct type *type, address, stream, recurse + 1, val, options, current_language); annotate_elt_rep (reps); - fprintf_filtered (stream, " ", reps); + fprintf_filtered (stream, " %p[%p]", + metadata_style.style ().ptr (), reps, nullptr); annotate_elt_rep_end (); i = rep1 - 1; diff --git a/gdb/value.c b/gdb/value.c index d58a964649..67fe2f17c0 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -43,6 +43,7 @@ #include "completer.h" #include "gdbsupport/selftest.h" #include "gdbsupport/array-view.h" +#include "cli/cli-style.h" /* Definition of a user function. */ struct internal_function @@ -2539,7 +2540,8 @@ show_convenience (const char *ignore, int from_tty) } catch (const gdb_exception_error &ex) { - fprintf_filtered (gdb_stdout, _(""), ex.what ()); + fprintf_styled (gdb_stdout, metadata_style.style (), + _(""), ex.what ()); } printf_filtered (("\n")); -- 2.34.1