diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index e21b2f40ca..5a810b897d 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -43,14 +43,17 @@ debuginfod_debuginfo_query (const unsigned char *build_id, #else #include +#define PROGRESS_STEP_PERCENT 10 + struct user_data { user_data (const char *desc, const char *fname) - : desc (desc), fname (fname), has_printed (false) + : desc (desc), fname (fname), next_percent_progress (PROGRESS_STEP_PERCENT), has_printed (false) { } const char * const desc; const char * const fname; + long next_percent_progress; bool has_printed; }; @@ -74,6 +77,7 @@ progressfn (debuginfod_client *c, long cur, long total) if (check_quit_flag ()) { + // TODO printf_filtered ("Cancelling download of %s %ps...\n", data->desc, styled_string (file_name_style.style (), data->fname)); @@ -84,9 +88,23 @@ progressfn (debuginfod_client *c, long cur, long total) { /* Print this message only once. */ data->has_printed = true; - printf_filtered ("Downloading %s %ps...\n", + printf_filtered ("Downloading %.2f MB %s %ps.", + 1.0f * total / (1024 * 1024), data->desc, styled_string (file_name_style.style (), data->fname)); + gdb_flush (gdb_stdout); + } + else if (total != 0) + { + long percent = 100 * cur / total; + while (percent >= data->next_percent_progress) + { + printf ("..%ld%%", data->next_percent_progress); + data->next_percent_progress += PROGRESS_STEP_PERCENT; + } + if (percent == 100) + printf ("\n"); + gdb_flush (gdb_stdout); } return 0;