]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Introduce metadata style
authorTom Tromey <tom@tromey.com>
Wed, 3 Apr 2019 02:00:18 +0000 (20:00 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 1 Oct 2019 21:12:40 +0000 (15:12 -0600)
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 "<unavailable>".

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  <tom@tromey.com>

* 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) <field_fmt>: New overload.
<do_field_fmt>: 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) <do_field_fmt>: 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) <do_field_fmt>: 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) <do_field_fmt>: 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  <tom@tromey.com>

* lib/gdb-utils.exp (style): Handle "metadata" argument.
* gdb.base/style.exp: Add metadata style test.

43 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/ada-tasks.c
gdb/ada-typeprint.c
gdb/ada-valprint.c
gdb/break-catch-sig.c
gdb/break-catch-syscall.c
gdb/breakpoint.c
gdb/c-typeprint.c
gdb/cli-out.c
gdb/cli-out.h
gdb/cli/cli-style.c
gdb/cli/cli-style.h
gdb/cp-valprint.c
gdb/expprint.c
gdb/f-typeprint.c
gdb/f-valprint.c
gdb/gnu-v3-abi.c
gdb/infcmd.c
gdb/m2-typeprint.c
gdb/m2-valprint.c
gdb/mi/mi-out.c
gdb/mi/mi-out.h
gdb/p-lang.c
gdb/p-typeprint.c
gdb/p-valprint.c
gdb/printcmd.c
gdb/python/py-framefilter.c
gdb/python/py-prettyprint.c
gdb/rust-lang.c
gdb/skip.c
gdb/stack.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/style.exp
gdb/testsuite/lib/gdb-utils.exp
gdb/tracepoint.c
gdb/tui/tui-out.c
gdb/tui/tui-out.h
gdb/typeprint.c
gdb/ui-out.c
gdb/ui-out.h
gdb/valprint.c
gdb/value.c

index 514a8bd99ac5d5b699dbe661d0203a6a09d98b06..9494dc4adc9ef588ee73247b376e5df29864d6c3 100644 (file)
@@ -1,3 +1,71 @@
+2019-10-01  Tom Tromey  <tom@tromey.com>
+
+       * 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) <field_fmt>: New overload.
+       <do_field_fmt>: 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) <do_field_fmt>: 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) <do_field_fmt>: 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) <do_field_fmt>: 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  <tom@tromey.com>
 
        * cli/cli-cmds.c (pwd_command): Style output.
index 063b98bde5b725a5f59e1e3fb7e067fc0dcf4cd7..846c9b4dec586fce1f3b3d40df2495f90459eed6 100644 (file)
@@ -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 <no source file available>:%d\n"),
-                            sal.line);
+           printf_filtered (_(" at %p[<no source file available>%p]:%d\n"),
+                            metadata_style.style ().ptr (), nullptr, sal.line);
          else
            printf_filtered (_(" at %s:%d\n"),
                             symtab_to_filename_for_display (sal.symtab),
index 24ceab1fcab852992295f61600e3e65e651b7e86..e4a52976dcb791ff5d5d2527188d8713531a7487 100644 (file)
@@ -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
-                          : _("<no 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
+                        : _("<no 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 (_("<no name>\n"));
+    fprintf_styled (gdb_stdout, metadata_style.style (), _("<no name>\n"));
 
   /* Print the TID and LWP.  */
   printf_filtered (_("Thread: %#lx\n"), task_info->ptid.tid ());
index 89a69e9bd4435b7be86eea82f8713f95655154f4..c2461660ad4aff9553b41fd1172d2e3e4ccfe42f 100644 (file)
@@ -393,7 +393,8 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
 
   if (type == NULL)
     {
-      fprintf_filtered (stream, _("<undecipherable array type>"));
+      fprintf_styled (stream, metadata_style.style (),
+                     _("<undecipherable array type>"));
       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, "<null type?>");
+      fprintf_styled (stream, metadata_style.style (), "<null type?>");
       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)
index 3060eb676b6f923f294ecc2a1ca7dd25be2ba5e5..714b6259ec0e6edd8b98b072aab26798aac387dd 100644 (file)
@@ -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, _(" <repeats %u times>"), i - i0);
+         fprintf_filtered (stream, _(" %p[<repeats %u times>%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, _(" <repeats %u times>"), reps);
+         fprintf_filtered (stream, _(" %p[<repeats %u times>%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 (_("<optimized out or zero length>"), stream);
+             fputs_styled (_("<optimized out or zero length>"),
+                           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 ("<ref to undefined type>", stream);
+      fputs_styled ("<ref to undefined type>", metadata_style.style (),
+                   stream);
       return;
     }
 
@@ -1212,8 +1217,9 @@ ada_val_print (struct type *type,
     }
   catch (const gdb_exception_error &except)
     {
-      fprintf_filtered (stream, _("<error reading variable: %s>"),
-                       except.what ());
+      fprintf_styled (stream, metadata_style.style (),
+                     _("<error reading variable: %s>"),
+                     except.what ());
     }
 }
 
index 53540ee8320b31fc2aeab2c59e2f0e62999c003c..c475e8aca57244b347bb0932f8f08cc672fb24a1 100644 (file)
@@ -28,6 +28,7 @@
 #include "valprint.h"
 #include "cli/cli-utils.h"
 #include "completer.h"
+#include "cli/cli-style.h"
 
 #include <string>
 
@@ -241,7 +242,8 @@ signal_catchpoint_print_one (struct breakpoint *b,
     }
   else
     uiout->field_string ("what",
-                        c->catch_all ? "<any signal>" : "<standard signals>");
+                        c->catch_all ? "<any signal>" : "<standard signals>",
+                        metadata_style.style ());
   uiout->text ("\" ");
 
   if (uiout->is_mi_like_p ())
index a165be62be13be6bc097975d00c362950237820a..dde80b54a2fb98e946381250591368b3d99ce54b 100644 (file)
@@ -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", "<any syscall>");
+    uiout->field_string ("what", "<any syscall>", metadata_style.style ());
   uiout->text ("\" ");
 
   if (uiout->is_mi_like_p ())
index 2030687728cfd17e637f50baf8e1f629512cb8ef..0a705163386ebae7dbc5a9b96ebb6145dca548e7 100644 (file)
@@ -4457,7 +4457,7 @@ static void
 watchpoint_value_print (struct value *val, struct ui_file *stream)
 {
   if (val == NULL)
-    fprintf_unfiltered (stream, _("<unreadable>"));
+    fprintf_styled (stream, metadata_style.style (), _("<unreadable>"));
   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", "<MULTIPLE>");
+               uiout->field_string ("addr", "<MULTIPLE>",
+                                    metadata_style.style ());
              else if (b->loc == NULL || loc->shlib_disabled)
-               uiout->field_string ("addr", "<PENDING>");
+               uiout->field_string ("addr", "<PENDING>",
+                                    metadata_style.style ());
              else
                uiout->field_core_addr ("addr",
                                        loc->gdbarch, loc->address);
index 43ad3b3e0e6ced43f3ecb405c7b9cc63edb25159..1a37c4edfb8665f29bb0280ac44c8851828ffc9d 100644 (file)
@@ -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,
-                              _("<incomplete type>\n"));
+                              _("%p[<incomplete type>%p]\n"),
+                              metadata_style.style ().ptr (), nullptr);
          else
            fprintfi_filtered (level + 4, stream,
-                              _("<no data fields>\n"));
+                              _("%p[<no data fields>%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,
-                                   _("<undefined type> %s;\n"),
+                                   _("%p[<undefined type>%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,
-                                     _("<badly mangled name '%s'>"),
-                                     mangled_name);
+                   fprintf_styled (stream, metadata_style.style (),
+                                   _("<badly mangled name '%s'>"),
+                                   mangled_name);
                }
              else
                {
@@ -1465,7 +1468,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
 
   if (type == NULL)
     {
-      fputs_filtered (_("<type unknown>"), stream);
+      fputs_styled (_("<type unknown>"), 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, _("<unnamed typedef>"));
+      fprintf_styled (stream, metadata_style.style (),
+                     _("<unnamed typedef>"));
       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,
-                                    _("<incomplete type>\n"));
+                                    _("%p[<incomplete type>%p]\n"),
+                                    metadata_style.style ().ptr (), nullptr);
                else
                  fprintfi_filtered (level + 4, stream,
-                                    _("<no data fields>\n"));
+                                    _("%p[<no data fields>%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, _("<range type>"));
+      fprintf_styled (stream, metadata_style.style (), _("<range type>"));
       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, _("<invalid type code %d>"),
-                           TYPE_CODE (type));
+         fprintf_styled (stream, metadata_style.style (),
+                         _("<invalid type code %d>"), TYPE_CODE (type));
        }
       break;
     }
index c713607e06800201b6b25149ff44ea95360b6fb7..702e4e4dfe2eb187f019a5e7a26ff57092984eb8 100644 (file)
@@ -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
index d7bd23b0ef22ae7560866dc82452bfd0f4091f63..7d5b4febba5435b1c568547d4107f8e11a81b881 100644 (file)
@@ -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,
index ea301774d22896f60d1a3973f86a56126a35668c..a0c5c0a950d1e31a4d47eb798da4ed339e11203a 100644 (file)
@@ -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 \"<unavailable>\""));
 }
index 826162f5788e51fe6a9394581071bce225ddd621..6716471dec3ff14a8bb50e2e73af65ce57647b28 100644 (file)
@@ -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;
index 530d8c526915285519506582ce2c606fc76cf8e6..e73b0e27faf45df222551eb4a443e9a61b6dd30e 100644 (file)
@@ -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, "<No data fields>");
+    fprintf_styled (stream, metadata_style.style (), "<No data fields>");
   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 ("<optimized out or zero length>", stream);
+                 fputs_styled ("<optimized out or zero length>",
+                               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 (_("<synthetic pointer>"), stream);
+                 fputs_styled (_("<synthetic pointer>"),
+                               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 ("<optimized out or zero length>",
-                                 stream);
+                 fputs_styled ("<optimized out or zero length>",
+                               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,
-                                       _("<error reading variable: %s>"),
-                                       ex.what ());
+                     fprintf_styled (stream, metadata_style.style (),
+                                     _("<error reading variable: %s>"),
+                                     ex.what ());
                    }
                }
              else if (i == vptr_fieldno && type == vptr_basetype)
index d7ad1a71878077f22a2028eeef2e874e57d2512e..c98638ab7fe9cfb0c496600bcedbc9548f2669c0 100644 (file)
@@ -29,6 +29,7 @@
 #include "block.h"
 #include "objfiles.h"
 #include "valprint.h"
+#include "cli/cli-style.h"
 
 #include <ctype.h>
 
@@ -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, _("<language %s has no 'this'>"),
-                         exp->language_defn->la_name);
+       fprintf_styled (stream, metadata_style.style (),
+                       _("<language %s has no 'this'>"),
+                       exp->language_defn->la_name);
       return;
 
       /* Modula-2 ops */
index 92b50938740a78ce59a998a9efe40c5984827562..0093aebddc2c10886729f9bac5645263e0d1fb56 100644 (file)
@@ -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 ("<type unknown>", stream);
+      fputs_styled ("<type unknown>", metadata_style.style (), stream);
       return;
     }
 
index 264416ec5408e1c763ad40b21af7c8966d854a6d..f9d49233fcaeb51a96a4b1ba7202282c9dc9fefa 100644 (file)
@@ -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 ("<error reading variable: %s>",
-                                except.what ());
+               fprintf_styled (gdb_stdout, metadata_style.style (),
+                               "<error reading variable: %s>",
+                               except.what ());
              }
 
            putchar_filtered ('\n');
index 6407c9beb82fe3aeb6dd0b5ef1aa9d855bfa939e..1d4e43ad7f6a367f2fd2aeee7f004896613fecab 100644 (file)
@@ -28,6 +28,7 @@
 #include "c-lang.h"
 #include "typeprint.h"
 #include <algorithm>
+#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 (_("<error: %s>"), ex.what ());
+         fprintf_styled (gdb_stdout, metadata_style.style (),
+                         _("<error: %s>"), ex.what ());
          got_error = 1;
        }
 
index dc82ef043fe85deaef3419e7171e6148af06f977..20523fed534ab4451fb5b21ac438107944b210f1 100644 (file)
@@ -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", _("<not displayed>"));
+       uiout->field_string ("return-value", _("<not displayed>"),
+                            metadata_style.style ());
       uiout->text ("\n");
     }
   else
index dae07d1c531a02c6eac4cb9b56cc9ad7e793aae7..3c1a8d2aed392ca5bf06a5e8bf2afc1bd80513f1 100644 (file)
@@ -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 (_("<type unknown>"), stream);
+      fputs_styled (_("<type unknown>"), metadata_style.style (), stream);
       return;
     }
 
index 74f89ee45fb33f70ec54b07b70000aba5b7883ca..4dc0fe18e6a785864467e3aaae7ac5746cb163f5 100644 (file)
@@ -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 }", _("<unknown bounds of set>"));
+      fprintf_styled (stream, metadata_style.style (),
+                     " %s }", _("<unknown bounds of set>"));
       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, _("<incomplete type>"));
+         fprintf_styled (stream, metadata_style.style (),
+                         _("<incomplete type>"));
          break;
        }
       else
@@ -423,7 +426,8 @@ m2_val_print (struct type *type, int embedded_offset,
        maybe_bad_bstring:
          if (i < 0)
            {
-             fputs_filtered (_("<error value>"), stream);
+             fputs_styled (_("<error value>"), metadata_style.style (),
+                           stream);
              goto done;
            }
 
index 71af4865e9745e2f3cad112552c02ef389a6cdbf..ad4252f71228ba56cc11959b2b20299319010193 100644 (file)
@@ -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 ();
index 9393809b5f20c296afe93b308fb1834ae5bd95bb..c8b42c295ee7bc36f5b8e99931c09910a1565446 100644 (file)
@@ -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,
index cfe2a8887229d6d9b4b5262deb397d433f2ca583..95911158d15ea9e7678964515156b099686f3a96 100644 (file)
@@ -32,6 +32,7 @@
 #include <ctype.h>
 #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, " <repeats %u times>", reps);
+         fprintf_filtered (stream, " %p[<repeats %u times>%p]",
+                           metadata_style.style ().ptr (),
+                           reps, nullptr);
          i = rep1 - 1;
          things_printed += options->repeat_count_threshold;
          need_comma = 1;
index d90b8ceb6eaa59a250e9336f72c7354b27f76e5a..fadc44eaee87510b0f787c665ca8e6f72804e56d 100644 (file)
@@ -32,6 +32,7 @@
 #include "typeprint.h"
 #include "gdb-demangle.h"
 #include <ctype.h>
+#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 ("<type unknown>", stream);
+      fputs_styled ("<type unknown>", 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, "<invalid unnamed pascal type code %d>",
-                           TYPE_CODE (type));
+         fprintf_styled (stream, metadata_style.style (),
+                         "<invalid unnamed pascal type code %d>",
+                         TYPE_CODE (type));
        }
       break;
     }
index a3738a9252d11104777802f42436be50f8c857be..10612f3babe8ad82121136229f39d7790fcbb408 100644 (file)
@@ -39,6 +39,7 @@
 #include "cp-support.h"
 #include "objfiles.h"
 #include "gdbsupport/byte-vector.h"
+#include "cli/cli-style.h"
 \f
 
 /* Decorations for Pascal.  */
@@ -347,7 +348,7 @@ pascal_val_print (struct type *type,
       elttype = check_typedef (elttype);
       if (TYPE_STUB (elttype))
        {
-         fprintf_filtered (stream, "<incomplete type>");
+         fprintf_styled (stream, metadata_style.style (), "<incomplete type>");
          break;
        }
       else
@@ -370,7 +371,7 @@ pascal_val_print (struct type *type,
        maybe_bad_bstring:
          if (bound_info < 0)
            {
-             fputs_filtered ("<error value>", stream);
+             fputs_styled ("<error value>", 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, "<No data fields>");
+    fprintf_styled (stream, metadata_style.style (), "<No data fields>");
   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 ("<optimized out or zero length>", stream);
+                 fputs_styled ("<optimized out or zero length>",
+                               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 (_("<synthetic pointer>"), stream);
+                 fputs_styled (_("<synthetic pointer>"),
+                               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 ("<optimized out or zero length>", stream);
+                 fputs_styled ("<optimized out or zero length>",
+                               metadata_style.style (), stream);
                }
              else if (field_is_static (&TYPE_FIELD (type, i)))
                {
index c17afe29bb2072ffd81c1dd8242c5af8804ea17d..ea00f083b12d77140e894327885417d5f638bf9d 100644 (file)
@@ -2001,8 +2001,9 @@ do_one_display (struct display *d)
        }
       catch (const gdb_exception_error &ex)
        {
-         fprintf_filtered (gdb_stdout, _("<error: %s>\n"),
-                           ex.what ());
+         fprintf_filtered (gdb_stdout, _("%p[<error: %s>%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, _("<error: %s>"), ex.what ());
+         fprintf_styled (gdb_stdout, metadata_style.style (),
+                         _("<error: %s>"), 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, "<error reading variable %s (%s)>", name,
-                       except.what ());
+      fprintf_styled (stream, metadata_style.style (),
+                     "<error reading variable %s (%s)>", name,
+                     except.what ());
     }
 
   fprintf_filtered (stream, "\n");
index f82a239c2a85e1f6aa8f4c19e66a547ab4563b9b..4dd6243ae99eb63fb91230b37f2f3482ec0803c0 100644 (file)
@@ -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 (),
                              _("<error reading variable: %s>"),
                              fa->error.get ());
            }
index fdc520d84432a8bee1cfc59901176ab10914848e..a4df48fe19ab08ae3e4f02efa99769cdd2065443 100644 (file)
@@ -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<char> msg = fetched_error.to_string ();
 
       if (msg == NULL || *msg == '\0')
-       fprintf_filtered (stream, _("<error reading variable>"));
+       fprintf_styled (stream, metadata_style.style (),
+                       _("<error reading variable>"));
       else
-       fprintf_filtered (stream, _("<error reading variable: %s>"),
-                         msg.get ());
+       fprintf_styled (stream, metadata_style.style (),
+                       _("<error reading variable: %s>"), msg.get ());
     }
   else
     gdbpy_print_stack ();
index 79f13311cd8f7f0ce2af55e87de9a83819ee1f30..cef0a9cb092e58c6a012c50660d722bf5d0092a3 100644 (file)
@@ -37,6 +37,7 @@
 #include <algorithm>
 #include <string>
 #include <vector>
+#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 {<No data fields>}"), TYPE_NAME (type));
+      fprintf_filtered (stream, _("%s {%p[<No data fields>%p]}"),
+                       TYPE_NAME (type),
+                       metadata_style.style ().ptr (), nullptr);
       return;
     }
 
index fcf41bf79a732d05ac7a4eebf12d2feeaf08e662..cc10692f4933db0157cb0b76fc1be99038787d86 100644 (file)
@@ -415,7 +415,9 @@ info_skip_command (const char *arg, int from_tty)
       current_uiout->field_string ("file",
                                   e.file ().empty () ? "<none>"
                                   : 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 () ? "<none>"
                                   : e.function ().c_str (),
-                                  function_name_style.style ()); /* 6 */
+                                  e.function ().empty ()
+                                  ? metadata_style.style ()
+                                  : function_name_style.style ()); /* 6 */
 
       current_uiout->text ("\n");
     }
index 4899d0f416984f3a7237ea8959f57ce5bb53c2bf..cb07e28b6714f2104380c42c74e2349aeabf338b 100644 (file)
@@ -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 (_("<error reading variable: %s>"), arg->error.get ());
+       {
+         stb.printf (_("<error reading variable: %s>"), arg->error.get ());
+         style = metadata_style.style ();
+       }
       else
        {
          try
@@ -428,11 +432,12 @@ print_frame_arg (const frame_print_options &fp_opts,
            {
              stb.printf (_("<error reading variable: %s>"),
                          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 called from gdb>",
-                              function_name_style.style ());
+                              metadata_style.style ());
        }
       else if (get_frame_type (frame) == SIGTRAMP_FRAME)
         {
          annotate_signal_handler_caller ();
           uiout->field_string ("func", "<signal handler called>",
-                              function_name_style.style ());
+                              metadata_style.style ());
         }
       else if (get_frame_type (frame) == ARCH_FRAME)
         {
           uiout->field_string ("func", "<cross-architecture call>",
-                              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", "<unavailable>",
-                                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 ("<unavailable>", gdb_stdout);
+    fputs_styled ("<unavailable>", 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, _("<error: %s>"),
-                               ex.what ());
+             fprintf_styled (gdb_stdout, metadata_style.style (),
+                             _("<error: %s>"),
+                             ex.what ());
              break;
            }
        }
index 88cec5dfb379cabe68f2b4b791b472bd525a0718..784daf2e530699d57763f6e6707809da7183defc 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-01  Tom Tromey  <tom@tromey.com>
+
+       * lib/gdb-utils.exp (style): Handle "metadata" argument.
+       * gdb.base/style.exp: Add metadata style test.
+
 2019-10-01  Tom Tromey  <tom@tromey.com>
 
        * gdb.base/style.exp: Test "pwd".
index fb0dfed00617d7be60991162b8c851ac65a35c73..0f812f7f1bc03d08d48ae34b34859220a6a914ea 100644 (file)
@@ -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 {<repeats.*8.*times>} metadata]\\}"
 }
index 89767dc51c4ed350c6cce947b075db5c56aa3d16..95ca348dc3368b909bd6ab29f1b49c4abc79b99d 100644 (file)
@@ -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"
 }
index 2f91e49efd3f21450495542145bfe11fe3bdc020..843341aaae17fb12cd8f0c8631cd596b560a2cb2 100644 (file)
@@ -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 = "<unknown>";
+         {
+           /* The value is/was defined, but we don't have it.  */
+           c = "<unknown>";
+           style = metadata_style.style ();
+         }
        else
-         /* It is not meaningful to ask about the value.  */
-         c = "<undefined>";
+         {
+           /* It is not meaningful to ask about the value.  */
+           c = "<undefined>";
+           style = metadata_style.style ();
+         }
        if (c)
-         uiout->field_string ("current", c);
+         uiout->field_string ("current", c, style);
        uiout->text ("\n");
       }
   }
index d415e7b64a0404dbbe38fb78fde4c1b86e09c51a..0d3f3be98803495f8f9e6e2513385ad1b3cd7357 100644 (file)
@@ -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
index 9df9e93aa9df676a5068c387cbee30ac11bd429c..2b856af48835e286a8447546ffa94432c2d9c617 100644 (file)
@@ -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:
index 41d95c2afb23dcb804f21e5b271e20184f74879b..357b88db5317031f81b996e36155c7f46109465f 100644 (file)
@@ -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, _("<unknown return type>"));
+  fprintf_styled (stream, metadata_style.style (),
+                 _("<unknown return type>"));
 }
 
 /* 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, _("<not allocated>"));
+  fprintf_styled (stream, metadata_style.style (), _("<not allocated>"));
 }
 
 /* Print <not associated> 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, _("<not associated>"));
+  fprintf_styled (stream, metadata_style.style (), _("<not associated>"));
 }
index 8cbaa4e0bc19a42010544cf2a3b2cdbf1b0ea9f2..a64c79481cad9447880d68cf4043474df75b8193 100644 (file)
@@ -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);
 }
index 0bba1280fcc672ed05121dde597b14409223fb8c..5c96a7825be4aaeca10a9b7ae976742127010fa3 100644 (file)
@@ -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,
index e5b28f3ee9ebe7fd85765aa859278dbcc43efc8d..919ab9382137c1e16f7353acb1bf135c681378a9 100644 (file)
@@ -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 (_("<synthetic pointer>"), stream);
+           fputs_styled (_("<synthetic pointer>"), 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, _("<optimized out>"));
+    fprintf_styled (stream, metadata_style.style (), _("<optimized out>"));
 }
 
 void
 val_print_not_saved (struct ui_file *stream)
 {
-  fprintf_filtered (stream, _("<not saved>"));
+  fprintf_styled (stream, metadata_style.style (), _("<not saved>"));
 }
 
 void
 val_print_unavailable (struct ui_file *stream)
 {
-  fprintf_filtered (stream, _("<unavailable>"));
+  fprintf_styled (stream, metadata_style.style (), _("<unavailable>"));
 }
 
 void
 val_print_invalid_address (struct ui_file *stream)
 {
-  fprintf_filtered (stream, _("<invalid address>"));
+  fprintf_styled (stream, metadata_style.style (), _("<invalid address>"));
 }
 
 /* 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, _("<incomplete type>"));
+      fprintf_styled (stream, metadata_style.style (), _("<incomplete type>"));
       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, _("<incomplete type>"));
+      fprintf_styled (stream, metadata_style.style (), _("<incomplete type>"));
       return;
     }
 
@@ -1084,7 +1086,8 @@ val_print (struct type *type, LONGEST embedded_offset,
     }
   catch (const gdb_exception_error &except)
     {
-      fprintf_filtered (stream, _("<error reading variable>"));
+      fprintf_styled (stream, metadata_style.style (),
+                     _("<error reading variable>"));
     }
 }
 
@@ -1115,7 +1118,8 @@ value_check_printable (struct value *val, struct ui_file *stream,
 {
   if (val == 0)
     {
-      fprintf_filtered (stream, _("<address of value unknown>"));
+      fprintf_styled (stream, metadata_style.style (),
+                     _("<address of value unknown>"));
       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, _("<internal function %s>"),
-                       value_internal_function_name (val));
+      fprintf_styled (stream, metadata_style.style (),
+                     _("<internal function %s>"),
+                     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, " <repeats %u times>", reps);
+         fprintf_filtered (stream, " %p[<repeats %u times>%p]",
+                           metadata_style.style ().ptr (), reps, nullptr);
          annotate_elt_rep_end ();
 
          i = rep1 - 1;
index d58a964649be80bc2ff079d4bf2bf68fda289e04..67fe2f17c051a95a0cab640446a011fabba6c540 100644 (file)
@@ -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, _("<error: %s>"), ex.what ());
+         fprintf_styled (gdb_stdout, metadata_style.style (),
+                         _("<error: %s>"), ex.what ());
        }
 
       printf_filtered (("\n"));