/* Output generating routines for GDB.
- Copyright (C) 1999-2019 Free Software Foundation, Inc.
+ Copyright (C) 1999-2021 Free Software Foundation, Inc.
Contributed by Cygnus Solutions.
Written by Fernando Nasser for Cygnus.
/* The possible kinds of fields. */
enum class field_kind
{
- SIGNED,
- STRING,
+ /* "FIELD_STRING" needs a funny name to avoid clashes with tokens
+ named "STRING". See PR build/25250. FIELD_SIGNED is given a
+ similar name for consistency. */
+ FIELD_SIGNED,
+ FIELD_STRING,
};
/* The base type of all fields that can be emitted using %pF. */
signed_field_s &&tmp = {})
{
tmp.name = name;
- tmp.kind = field_kind::SIGNED;
+ tmp.kind = field_kind::FIELD_SIGNED;
tmp.val = val;
return &tmp;
}
string_field_s &&tmp = {})
{
tmp.name = name;
- tmp.kind = field_kind::STRING;
+ tmp.kind = field_kind::FIELD_STRING;
tmp.str = str;
return &tmp;
}
uiout->field_signed(), uiout_>field_string() etc. calls when
the formatted message is translatable. E.g.:
- uiout->message (_("\nWatchpoint %pF deleted because the program has "
- "left the block in\n"
- "which its expression is valid.\n"),
- signed_field ("wpnum", b->number));
+ uiout->message (_("\nWatchpoint %pF deleted because the program has "
+ "left the block in\n"
+ "which its expression is valid.\n"),
+ signed_field ("wpnum", b->number));
- '%p[' - output the following text in a specified style.
'%p]' - output the following text in the default style.
escapes. */
virtual bool can_emit_style_escape () const = 0;
+ /* An object that starts and finishes a progress meter. */
+ class progress_meter
+ {
+ public:
+ /* SHOULD_PRINT indicates whether something should be printed for a tty. */
+ progress_meter (struct ui_out *uiout, const std::string &name,
+ bool should_print)
+ : m_uiout (uiout)
+ {
+ m_uiout->do_progress_start (name, should_print);
+ }
+
+ ~progress_meter ()
+ {
+ m_uiout->do_progress_notify (1.0);
+ m_uiout->do_progress_end ();
+ }
+
+ progress_meter (const progress_meter &) = delete;
+ progress_meter &operator= (const progress_meter &) = delete;
+
+ private:
+
+ struct ui_out *m_uiout;
+ };
+
+ /* Emit some progress corresponding to the most recently created
+ progress meter. HOWMUCH may range from 0.0 to 1.0. */
+ void progress (double howmuch)
+ {
+ do_progress_notify (howmuch);
+ }
+
protected:
virtual void do_table_begin (int nbrofcols, int nr_rows, const char *tblid)
virtual void do_flush () = 0;
virtual void do_redirect (struct ui_file *outstream) = 0;
+ virtual void do_progress_start (const std::string &, bool) = 0;
+ virtual void do_progress_notify (double) = 0;
+ virtual void do_progress_end () = 0;
+
/* Set as not MI-like by default. It is overridden in subclasses if
necessary. */