+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.
#include "gdbsupport/gdb_vecs.h"
#include "typeprint.h"
#include "namespace.h"
+#include "cli/cli-style.h"
#include "psymtab.h"
#include "value.h"
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),
#include "gdbthread.h"
#include "progspace.h"
#include "objfiles.h"
+#include "cli/cli-style.h"
static int ada_build_task_list ();
/* 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");
}
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 ());
if (type == NULL)
{
- fprintf_filtered (stream, _("<undecipherable array type>"));
+ fprintf_styled (stream, metadata_style.style (),
+ _("<undecipherable array type>"));
return;
}
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;
}
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 ");
}
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)
#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,
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 ();
}
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;
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
{
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;
}
}
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 ());
}
}
#include "valprint.h"
#include "cli/cli-utils.h"
#include "completer.h"
+#include "cli/cli-style.h"
#include <string>
}
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 ())
#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
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 ())
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;
{
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);
{
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
{
/* 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;
}
&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
{
if (type == NULL)
{
- fputs_filtered (_("<type unknown>"), stream);
+ fputs_styled (_("<type unknown>"), metadata_style.style (), stream);
return;
}
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:
{
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++)
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:
{
/* 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;
}
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
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,
/* 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),
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>\""));
}
/* 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;
/* 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;
#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;
/* 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;
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,
TYPE_FIELD_BITSIZE (type,
i)))
{
- fputs_filtered (_("<synthetic pointer>"), stream);
+ fputs_styled (_("<synthetic pointer>"),
+ metadata_style.style (), stream);
}
else
{
{
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)))
{
}
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)
#include "block.h"
#include "objfiles.h"
#include "valprint.h"
+#include "cli/cli-style.h"
#include <ctype.h>
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 */
#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 *);
wrap_here (" ");
if (type == NULL)
{
- fputs_filtered ("<type unknown>", stream);
+ fputs_styled ("<type unknown>", metadata_style.style (), stream);
return;
}
#include "command.h"
#include "block.h"
#include "dictionary.h"
+#include "cli/cli-style.h"
static void f77_get_dynamic_length_of_aggregate (struct type *);
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');
#include "c-lang.h"
#include "typeprint.h"
#include <algorithm>
+#include "cli/cli-style.h"
static struct cp_abi_ops gnu_v3_abi_ops;
}
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;
}
#include "interps.h"
#include "gdbsupport/gdb_optional.h"
#include "source.h"
+#include "cli/cli-style.h"
/* Local functions: */
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
#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,
wrap_here (" ");
if (type == NULL)
{
- fputs_filtered (_("<type unknown>"), stream);
+ fputs_styled (_("<type unknown>"), metadata_style.style (), stream);
return;
}
#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,
}
else
{
- fprintf_filtered (stream, " %s }", _("<unknown bounds of set>"));
+ fprintf_styled (stream, metadata_style.style (),
+ " %s }", _("<unknown bounds of set>"));
return;
}
elttype = check_typedef (elttype);
if (TYPE_STUB (elttype))
{
- fprintf_filtered (stream, _("<incomplete type>"));
+ fprintf_styled (stream, metadata_style.style (),
+ _("<incomplete type>"));
break;
}
else
maybe_bad_bstring:
if (i < 0)
{
- fputs_filtered (_("<error value>"), stream);
+ fputs_styled (_("<error value>"), metadata_style.style (),
+ stream);
goto done;
}
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 ();
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,
#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. */
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;
#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,
wrap_here (" ");
if (type == NULL)
{
- fputs_filtered ("<type unknown>", stream);
+ fputs_styled ("<type unknown>", metadata_style.style (), stream);
return;
}
{
/* 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;
}
#include "cp-support.h"
#include "objfiles.h"
#include "gdbsupport/byte-vector.h"
+#include "cli/cli-style.h"
\f
/* Decorations for Pascal. */
elttype = check_typedef (elttype);
if (TYPE_STUB (elttype))
{
- fprintf_filtered (stream, "<incomplete type>");
+ fprintf_styled (stream, metadata_style.style (), "<incomplete type>");
break;
}
else
maybe_bad_bstring:
if (bound_info < 0)
{
- fputs_filtered ("<error value>", stream);
+ fputs_styled ("<error value>", metadata_style.style (), stream);
goto done;
}
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;
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,
TYPE_FIELD_BITSIZE (type,
i)))
{
- fputs_filtered (_("<synthetic pointer>"), stream);
+ fputs_styled (_("<synthetic pointer>"),
+ metadata_style.style (), stream);
}
else
{
{
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)))
{
}
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
}
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");
}
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");
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 ());
}
#include "extension-priv.h"
#include "python.h"
#include "python-internal.h"
+#include "cli/cli-style.h"
/* Return type of print_string_repr. */
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 ();
#include <algorithm>
#include <string>
#include <vector>
+#include "cli/cli-style.h"
/* See rust-lang.h. */
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;
}
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
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");
}
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
{
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
{
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 ();
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 ");
}
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)
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;
}
}
+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".
"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]\\}"
}
highlight { set style 31 }
variable { set style 36 }
address { set style 34 }
+ metadata { set style 2 }
}
return "\033\\\[${style}m${str}\033\\\[m"
}
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 ())
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");
}
}
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
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:
#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 =
{
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. */
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. */
void
val_print_not_associated (struct ui_file *stream)
{
- fprintf_filtered (stream, _("<not associated>"));
+ fprintf_styled (stream, metadata_style.style (), _("<not associated>"));
}
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);
}
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);
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,
#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
}
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;
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.
/* 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:
if (TYPE_STUB (real_type))
{
- fprintf_filtered (stream, _("<incomplete type>"));
+ fprintf_styled (stream, metadata_style.style (), _("<incomplete type>"));
return;
}
}
catch (const gdb_exception_error &except)
{
- fprintf_filtered (stream, _("<error reading variable>"));
+ fprintf_styled (stream, metadata_style.style (),
+ _("<error reading variable>"));
}
}
{
if (val == 0)
{
- fprintf_filtered (stream, _("<address of value unknown>"));
+ fprintf_styled (stream, metadata_style.style (),
+ _("<address of value unknown>"));
return 0;
}
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;
}
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;
#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
}
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"));