aboutsummaryrefslogtreecommitdiff
path: root/gdb/ui-out.h
diff options
context:
space:
mode:
authorAaron Merey <amerey@redhat.com>2022-10-24 14:05:06 -0400
committerAaron Merey <amerey@redhat.com>2022-11-10 12:01:18 -0500
commit27859c6b9d73a8ae1b51c5c40fc2b3aefd2228a0 (patch)
treeae917c80fce78e048cbbd357f68ac2e9d2a61434 /gdb/ui-out.h
parentf71e3f86e83c9c22e3d86112b5ddb61919390a1a (diff)
downloadgdb-27859c6b9d73a8ae1b51c5c40fc2b3aefd2228a0.zip
gdb-27859c6b9d73a8ae1b51c5c40fc2b3aefd2228a0.tar.gz
gdb-27859c6b9d73a8ae1b51c5c40fc2b3aefd2228a0.tar.bz2
gdb/debuginfod: Improve progress updates
If the download size is known, a progress bar is displayed along with the percentage of completion and the total download size. Downloading separate debug info for /lib/libxyz.so [############ ] 25% (10.01 M) If the download size is not known, a progress indicator is displayed with a ticker ("###") that moves across the screen at a rate of 1 tick every 0.5 seconds. Downloading separate debug info for /lib/libxyz.so [ ### ] If the output stream is not a tty, batch mode is enabled, the screen is too narrow or width has been set to 'unlimited', then only a static description of the download is printed. No bar or ticker is displayed. Downloading separate debug info for /lib/libxyz.so... In any case, if the size of the download is known at the time the description is printed then it will be included in the description. Downloading 10.01 MB separate debug info for /lib/libxyz.so...
Diffstat (limited to 'gdb/ui-out.h')
-rw-r--r--gdb/ui-out.h53
1 files changed, 35 insertions, 18 deletions
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 65d4087..5390c23 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -278,39 +278,56 @@ class ui_out
escapes. */
virtual bool can_emit_style_escape () const = 0;
- /* An object that starts and finishes a progress meter. */
- class progress_meter
+ /* An object that starts and finishes displaying progress updates. */
+ class progress_update
{
public:
+ /* Represents the printing state of a progress update. */
+ enum state
+ {
+ /* Printing will start with the next update. */
+ START,
+ /* Printing has already started. */
+ WORKING,
+ /* Progress bar printing has already started. */
+ BAR
+ };
+
/* 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)
+ progress_update ()
{
- m_uiout->do_progress_start (name, should_print);
+ m_uiout = current_uiout;
+ m_uiout->do_progress_start ();
}
- ~progress_meter ()
+ ~progress_update ()
{
- 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;
+ progress_update (const progress_update &) = delete;
+ progress_update &operator= (const progress_update &) = delete;
- /* Emit some progress for this progress meter. HOWMUCH may range
- from 0.0 to 1.0. */
- void progress (double howmuch)
+ /* Emit some progress for this progress meter. Includes current
+ amount of progress made and total amount in the display. */
+ void update_progress (const std::string& msg, const char *unit,
+ double cur, double total)
{
- m_uiout->do_progress_notify (howmuch);
+ m_uiout->do_progress_notify (msg, unit, cur, total);
}
+ /* Emit some progress for this progress meter. */
+ void update_progress (const std::string& msg)
+ {
+ m_uiout->do_progress_notify (msg, "", -1, -1);
+ }
private:
struct ui_out *m_uiout;
};
+ virtual void do_progress_end () = 0;
+
protected:
virtual void do_table_begin (int nbrofcols, int nr_rows, const char *tblid)
@@ -345,9 +362,9 @@ class ui_out
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;
+ virtual void do_progress_start () = 0;
+ virtual void do_progress_notify (const std::string &, const char *,
+ double, double) = 0;
/* Set as not MI-like by default. It is overridden in subclasses if
necessary. */