aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/cli-out.c17
-rw-r--r--gdb/debuginfod-support.c54
-rw-r--r--gdb/mi/mi-out.c2
3 files changed, 19 insertions, 54 deletions
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 3e5af16..7a2720d 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -295,7 +295,7 @@ cli_ui_out::do_progress_start ()
void
cli_ui_out::do_progress_notify (const std::string &msg,
const std::string &size,
- double cur, double total)
+ double howmuch, double total)
{
struct ui_file *stream = m_streams.back ();
cli_progress_info &info (m_progress_info.back ());
@@ -323,12 +323,11 @@ cli_ui_out::do_progress_notify (const std::string &msg,
|| !stream->isatty ())
return;
- double howmuch = cur / total;
- if (howmuch >= 0 && howmuch <= 1.0)
+ if (total > 0 && howmuch >= 0 && howmuch <= 1.0)
{
- std::string progress = string_printf (" %.02f %s / %.02f %s",
- cur, size.c_str (),
- total, size.c_str ());
+ std::string progress = string_printf (" %3.d%% (%.02f %s)",
+ (int)(howmuch * 100), total,
+ size.c_str ());
int width = chars_per_line - progress.size () - 3;
int max = width * howmuch;
@@ -357,11 +356,11 @@ cli_ui_out::do_progress_notify (const std::string &msg,
int width = chars_per_line - 3;
gdb_printf (stream, "\r[");
-
for (int i = 0; i < width; ++i)
{
- if (i >= info.pos % width
- && i < (info.pos + 3) % width)
+ if (i == info.pos % width
+ || i == (info.pos + 1) % width
+ || i == (info.pos + 2) % width)
gdb_printf (stream, "#");
else
gdb_printf (stream, " ");
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 77e2839..0613e4e 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -119,25 +119,25 @@ using debuginfod_client_up
static void
get_size_and_unit (double &size, std::string &unit)
{
- if (size < 10.24)
+ if (size < 1024)
{
- /* If size is less than 0.01 KB then set unit to B. */
+ /* If size is less than 1 KB then set unit to B. */
unit = "B";
return;
}
size /= 1024;
- if (size < 10.24)
+ if (size < 1024)
{
- /* If size is less than 0.01 MB then set unit to KB. */
+ /* If size is less than 1 MB then set unit to KB. */
unit = "KB";
return;
}
size /= 1024;
- if (size < 10.24)
+ if (size < 1024)
{
- /* If size is less than 0.01 GB then set unit to MB. */
+ /* If size is less than 1 GB then set unit to MB. */
unit = "MB";
return;
}
@@ -146,17 +146,6 @@ get_size_and_unit (double &size, std::string &unit)
unit = "GB";
}
-static void
-convert_to_unit (double &size, const std::string &unit)
-{
- if (unit == "KB")
- size /= 1024;
- else if (unit == "MB")
- size /= 1024 * 1024;
- else if (unit == "GB")
- size /= 1024 * 1024 * 1024;
-}
-
static int
progressfn (debuginfod_client *c, long cur, long total)
{
@@ -169,7 +158,6 @@ progressfn (debuginfod_client *c, long cur, long total)
if (check_quit_flag ())
{
- //current_uiout->do_progress_end (); ///?
gdb_printf ("Cancelling download of %s %s...\n",
data->desc, styled_fname.c_str ());
return 1;
@@ -187,15 +175,13 @@ progressfn (debuginfod_client *c, long cur, long total)
if (howmuch >= 0.0 && howmuch <= 1.0)
{
double d_total = (double) total;
- double d_cur = (double) cur;
std::string unit = "";
get_size_and_unit (d_total, unit);
- convert_to_unit (d_cur, unit);
std::string msg = string_printf ("Downloading %0.2f %s %s %s\n",
d_total, unit.c_str (), data->desc,
styled_fname.c_str ());
- data->progress.update_progress (msg, unit, d_cur, d_total);
+ data->progress.update_progress (msg, unit, howmuch, d_total);
return 0;
}
}
@@ -299,29 +285,9 @@ print_outcome (user_data &data, int fd)
fprintf_styled (&styled_fname, file_name_style.style (), "%s",
data.fname);
- if (debuginfod_verbose > 1 && fd >= 0)
- {
- struct stat s;
-
- if (fstat (fd, &s) == 0)
- {
- double size = (double)s.st_size;
- std::string unit = "";
-
- get_size_and_unit (size, unit);
- gdb_printf (_("Retrieved %.02f %s %s %s\n"), size, unit.c_str (),
- data.desc, styled_fname.c_str ());
- }
- else
- warning (_("Retrieved %s %s but size cannot be read: %s\n"),
- data.desc, styled_fname.c_str (),
- safe_strerror (errno));
- }
- else if (fd < 0 && fd != -ENOENT)
- gdb_printf (_("Download failed: %s. " \
- "Continuing without %s %s.\n"),
- safe_strerror (-fd), data.desc,
- styled_fname.c_str ());
+ if (fd < 0 && fd != -ENOENT)
+ gdb_printf (_("Download failed: %s. Continuing without %s %s.\n"),
+ safe_strerror (-fd), data.desc, styled_fname.c_str ());
}
/* See debuginfod-support.h */
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index ee0f4db..90a2362 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -278,7 +278,7 @@ mi_ui_out::do_progress_notify (const std::string &msg, const std::string &unit,
if (info.state == progress_update::START)
{
struct ui_file *stream = gdb_stdout;
- gdb_printf (stream, "%s\n", msg.c_str ());
+ gdb_printf (stream, "%s", msg.c_str ());
info.state = progress_update::WORKING;
}
}