/* Print values for GDB, the GNU debugger.
- Copyright (C) 1986-2019 Free Software Foundation, Inc.
+ Copyright (C) 1986-2020 Free Software Foundation, Inc.
This file is part of GDB.
#include "cli/cli-option.h"
#include "gdbarch.h"
#include "cli/cli-style.h"
+#include "count-one-bits.h"
/* Maximum number of wchars returned from wchar_iterate. */
#define MAX_WCHARS 4
{
int first = 1;
- /* We have a "flag" enum, so we try to decompose it into
- pieces as appropriate. A flag enum has disjoint
- constants by definition. */
+ /* We have a "flag" enum, so we try to decompose it into pieces as
+ appropriate. The enum may have multiple enumerators representing
+ the same bit, in which case we choose to only print the first one
+ we find. */
fputs_filtered ("(", stream);
for (i = 0; i < len; ++i)
{
QUIT;
- if ((val & TYPE_FIELD_ENUMVAL (type, i)) != 0)
+ ULONGEST enumval = TYPE_FIELD_ENUMVAL (type, i);
+ int nbits = count_one_bits_ll (enumval);
+
+ gdb_assert (nbits == 0 || nbits == 1);
+
+ if ((val & enumval) != 0)
{
if (!first)
fputs_filtered (" | ", stream);
{
std::string str = memory_error_message (TARGET_XFER_E_IO, gdbarch, addr);
- fprintf_filtered (stream, "<error: ");
- fputs_filtered (str.c_str (), stream);
- fprintf_filtered (stream, ">");
+ fprintf_filtered (stream, _("<error: %ps>"),
+ styled_string (metadata_style.style (),
+ str.c_str ()));
}
return (bytes_read / width);
NULL, /* help_doc */
},
+ boolean_option_def {
+ "raw-values",
+ [] (value_print_options *opt) { return &opt->raw; },
+ NULL, /* show_cmd_cb */
+ N_("Set whether to print values in raw form."),
+ N_("Show whether to print values in raw form."),
+ N_("If set, values are printed in raw form, bypassing any\n\
+pretty-printers for that value.")
+ },
+
uinteger_option_def {
"repeats",
[] (value_print_options *opt) { return &opt->repeat_count_threshold; },
return {{value_print_option_defs}, opts};
}
+void _initialize_valprint ();
void
-_initialize_valprint (void)
+_initialize_valprint ()
{
cmd_list_element *cmd;