On 12/11/20 8:23 PM, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries writes: > > Tom> + gdb::optional 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). > Well, the natural place to declare "ui_out::progress_meter meter" given its lifetime is in debuginfod_source_query and debuginfod_debuginfo_query. But the only constructor has the name argument with no means of changing it later, and the name (containing the size) is only known lateron, when progressfn is called. So the optional is used as a means to have lifetime as we want it, while postponing construction until we known all the constructor arguments. > 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. Done. > 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. > Done. Thanks, - Tom