aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
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/mi
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/mi')
-rw-r--r--gdb/mi/mi-out.c32
-rw-r--r--gdb/mi/mi-out.h28
2 files changed, 50 insertions, 10 deletions
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index 028c005..725c1c6 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -259,6 +259,38 @@ mi_ui_out::main_stream ()
return (string_file *) m_streams.back ();
}
+/* Initialize a progress update to be displayed with
+ mi_ui_out::do_progress_notify. */
+
+void
+mi_ui_out::do_progress_start ()
+{
+ m_progress_info.emplace_back ();
+}
+
+/* Indicate that a task described by MSG is in progress. */
+
+void
+mi_ui_out::do_progress_notify (const std::string &msg, const char *unit,
+ double cur, double total)
+{
+ mi_progress_info &info (m_progress_info.back ());
+
+ if (info.state == progress_update::START)
+ {
+ gdb_printf ("%s...\n", msg.c_str ());
+ info.state = progress_update::WORKING;
+ }
+}
+
+/* Remove the most recent progress update from the progress_info stack. */
+
+void
+mi_ui_out::do_progress_end ()
+{
+ m_progress_info.pop_back ();
+}
+
/* Clear the buffer. */
void
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index 36d7e42..d51d810 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -83,17 +83,11 @@ protected:
virtual bool do_is_mi_like_p () const override
{ return true; }
- virtual void do_progress_start (const std::string &, bool) override
- {
- }
+ virtual void do_progress_start () override;
+ virtual void do_progress_notify (const std::string &, const char *,
+ double, double) override;
- virtual void do_progress_notify (double) override
- {
- }
-
- virtual void do_progress_end () override
- {
- }
+ virtual void do_progress_end () override;
private:
@@ -101,6 +95,20 @@ private:
void open (const char *name, ui_out_type type);
void close (ui_out_type type);
+ /* The state of a recent progress_update. */
+ struct mi_progress_info
+ {
+ /* The current state. */
+ progress_update::state state;
+
+ mi_progress_info ()
+ : state (progress_update::START)
+ {}
+ };
+
+ /* Stack of progress info. */
+ std::vector<mi_progress_info> m_progress_info;
+
/* Convenience method that returns the MI out's string stream cast
to its appropriate type. Assumes/asserts that output was not
redirected. */