/* Output generating routines for GDB.
- Copyright (C) 1999-2016 Free Software Foundation, Inc.
+ Copyright (C) 1999-2019 Free Software Foundation, Inc.
Contributed by Cygnus Solutions.
Written by Fernando Nasser for Cygnus.
#include <vector>
#include <memory>
#include <string>
-#include <memory>
+
+namespace {
/* A header of a ui_out_table. */
std::string m_header;
};
+} // namespace
+
/* A level of nesting (either a list or a tuple) in a ui_out output. */
class ui_out_level
m_table_up = nullptr;
}
-static void
-do_cleanup_table_end (void *data)
-{
- ui_out *uiout = (ui_out *) data;
-
- uiout->table_end ();
-}
-
-struct cleanup *
-make_cleanup_ui_out_table_begin_end (ui_out *uiout, int nr_cols, int nr_rows,
- const char *tblid)
-{
- uiout->table_begin (nr_cols, nr_rows, tblid);
- return make_cleanup (do_cleanup_table_end, uiout);
-}
-
void
ui_out::begin (ui_out_type type, const char *id)
{
do_end (type);
}
-struct ui_out_end_cleanup_data
-{
- struct ui_out *uiout;
- enum ui_out_type type;
-};
-
-static void
-do_cleanup_end (void *data)
-{
- struct ui_out_end_cleanup_data *end_cleanup_data
- = (struct ui_out_end_cleanup_data *) data;
-
- end_cleanup_data->uiout->end (end_cleanup_data->type);
- xfree (end_cleanup_data);
-}
-
-static struct cleanup *
-make_cleanup_ui_out_end (struct ui_out *uiout,
- enum ui_out_type type)
+void
+ui_out::field_signed (const char *fldname, LONGEST value)
{
- struct ui_out_end_cleanup_data *end_cleanup_data;
-
- end_cleanup_data = XNEW (struct ui_out_end_cleanup_data);
- end_cleanup_data->uiout = uiout;
- end_cleanup_data->type = type;
- return make_cleanup (do_cleanup_end, end_cleanup_data);
-}
+ int fldno;
+ int width;
+ ui_align align;
-struct cleanup *
-make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout,
- const char *id)
-{
- uiout->begin (ui_out_type_tuple, id);
- return make_cleanup_ui_out_end (uiout, ui_out_type_tuple);
-}
+ verify_field (&fldno, &width, &align);
-struct cleanup *
-make_cleanup_ui_out_list_begin_end (struct ui_out *uiout,
- const char *id)
-{
- uiout->begin (ui_out_type_list, id);
- return make_cleanup_ui_out_end (uiout, ui_out_type_list);
+ do_field_signed (fldno, width, align, fldname, value);
}
void
-ui_out::field_int (const char *fldname, int value)
+ui_out::field_fmt_signed (int input_width, ui_align input_align,
+ const char *fldname, LONGEST value)
{
int fldno;
int width;
verify_field (&fldno, &width, &align);
- do_field_int (fldno, width, align, fldname, value);
+ do_field_signed (fldno, input_width, input_align, fldname, value);
}
+/* See ui-out.h. */
+
void
-ui_out::field_fmt_int (int input_width, ui_align input_align,
- const char *fldname, int value)
+ui_out::field_unsigned (const char *fldname, ULONGEST value)
{
int fldno;
int width;
verify_field (&fldno, &width, &align);
- do_field_int (fldno, input_width, input_align, fldname, value);
+ do_field_unsigned (fldno, width, align, fldname, value);
}
/* Documented in ui-out.h. */
ui_out::field_core_addr (const char *fldname, struct gdbarch *gdbarch,
CORE_ADDR address)
{
- field_string (fldname, print_core_address (gdbarch, address));
+ field_string (fldname, print_core_address (gdbarch, address),
+ ui_out_style_kind::ADDRESS);
}
void
-ui_out::field_stream (const char *fldname, ui_file *stream)
+ui_out::field_stream (const char *fldname, string_file &stream,
+ ui_out_style_kind style)
{
- std::string buffer = ui_file_as_string (stream);
-
- if (!buffer.empty ())
- field_string (fldname, buffer.c_str ());
+ if (!stream.empty ())
+ field_string (fldname, stream.c_str (), style);
else
field_skip (fldname);
- ui_file_rewind (stream);
+ stream.clear ();
}
/* Used to omit a field. */
}
void
-ui_out::field_string (const char *fldname, const char *string)
+ui_out::field_string (const char *fldname, const char *string,
+ ui_out_style_kind style)
{
int fldno;
int width;
verify_field (&fldno, &width, &align);
- do_field_string (fldno, width, align, fldname, string);
+ do_field_string (fldno, width, align, fldname, string, style);
+}
+
+void
+ui_out::field_string (const char *fldname, const std::string &string)
+{
+ field_string (fldname, string.c_str ());
}
/* VARARGS */
int width;
ui_align align;
- /* Will not align, but has to call anyway. */
verify_field (&fldno, &width, &align);
va_start (args, format);
do_flush ();
}
-int
+void
ui_out::redirect (ui_file *outstream)
{
- return do_redirect (outstream);
+ do_redirect (outstream);
}
/* Test the flags against the mask given. */
}
bool
-ui_out::is_mi_like_p ()
+ui_out::is_mi_like_p () const
{
return do_is_mi_like_p ();
}