Re: [PATCH] gdb: print size of downloaded debuginfod binary

Tom Tromey
2020-12-11T19:23:56Z

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> + gdb::optional<ui_out::progress_meter> meter;

Seems like a bit of a shame to have an optional here, but then
essentially require optional-style behavior in the CLI ui-out as well
(in deferring output until the first update).

Maybe it could be done in progress_meter itself. Not sure.

Tom> - /* Print this message only once. */
Tom> - data->has_printed = true;
Tom> - printf_filtered ("Downloading %s %ps...\n",
Tom> - data->desc,
Tom> - styled_string (file_name_style.style (), data->fname));
Tom> + float size_in_mb = 1.0f * total / (1024 * 1024);
Tom> + std::stringstream message;
Tom> + message.precision (2);
Tom> + message << "Downloading " << size_in_mb << " MB " << data->desc
Tom> + << " " << data->fname;

Seems like this could use string_printf.
I suspect there's some way to preserve the styling but offhand I don't
recall what it is. Maybe you have to use string_file to accomplish that.

Tom