|
|
ab2726 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
ab2726 |
From: Kevin Buettner <kevinb@redhat.com>
|
|
|
ab2726 |
Date: Wed, 30 Mar 2022 13:28:26 -0700
|
|
|
ab2726 |
Subject: gdb-rhbz2068280-debuginfod-unavailable-size.patch
|
|
|
ab2726 |
|
|
|
ab2726 |
;; Backport upstream patch from Aaron Merey which suppresses debuginfod
|
|
|
ab2726 |
;; progress messages when size is zero. (RH BZ 2068280).
|
|
|
ab2726 |
|
|
|
ab2726 |
Remove download size from debuginfod progress messages if unavailable
|
|
|
ab2726 |
|
|
|
ab2726 |
Currently debuginfod progress update messages include the size of
|
|
|
ab2726 |
each download:
|
|
|
ab2726 |
|
|
|
ab2726 |
Downloading 7.5 MB separate debug info for /lib/libxyz.so.0
|
|
|
ab2726 |
|
|
|
ab2726 |
This value originates from the Content-Length HTTP header of the
|
|
|
ab2726 |
transfer. However this header is not guaranteed to be present for
|
|
|
ab2726 |
each download. This can happen when debuginfod servers compress files
|
|
|
ab2726 |
on-the-fly at the time of transfer. In this case gdb wrongly prints
|
|
|
ab2726 |
"-0.00 MB" as the size.
|
|
|
ab2726 |
|
|
|
ab2726 |
This patch removes download sizes from progress messages when they are
|
|
|
ab2726 |
not available. It also removes usage of the progress bar until
|
|
|
ab2726 |
a more thorough reworking of progress updating is implemented. [1]
|
|
|
ab2726 |
|
|
|
ab2726 |
[1] https://sourceware.org/pipermail/gdb-patches/2022-February/185798.html
|
|
|
ab2726 |
|
|
|
ab2726 |
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
|
|
|
ab2726 |
--- a/gdb/debuginfod-support.c
|
|
|
ab2726 |
+++ b/gdb/debuginfod-support.c
|
|
|
ab2726 |
@@ -81,12 +81,12 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
|
|
|
ab2726 |
struct user_data
|
|
|
ab2726 |
{
|
|
|
ab2726 |
user_data (const char *desc, const char *fname)
|
|
|
ab2726 |
- : desc (desc), fname (fname)
|
|
|
ab2726 |
+ : desc (desc), fname (fname), has_printed (false)
|
|
|
ab2726 |
{ }
|
|
|
ab2726 |
|
|
|
ab2726 |
const char * const desc;
|
|
|
ab2726 |
const char * const fname;
|
|
|
ab2726 |
- gdb::optional<ui_out::progress_meter> meter;
|
|
|
ab2726 |
+ bool has_printed;
|
|
|
ab2726 |
};
|
|
|
ab2726 |
|
|
|
ab2726 |
/* Deleter for a debuginfod_client. */
|
|
|
ab2726 |
@@ -116,24 +116,32 @@ progressfn (debuginfod_client *c, long cur, long total)
|
|
|
ab2726 |
return 1;
|
|
|
ab2726 |
}
|
|
|
ab2726 |
|
|
|
ab2726 |
- if (total == 0)
|
|
|
ab2726 |
- return 0;
|
|
|
ab2726 |
-
|
|
|
ab2726 |
- if (!data->meter.has_value ())
|
|
|
ab2726 |
+ if (!data->has_printed)
|
|
|
ab2726 |
{
|
|
|
ab2726 |
- float size_in_mb = 1.0f * total / (1024 * 1024);
|
|
|
ab2726 |
- string_file styled_filename (current_uiout->can_emit_style_escape ());
|
|
|
ab2726 |
- fprintf_styled (&styled_filename,
|
|
|
ab2726 |
- file_name_style.style (),
|
|
|
ab2726 |
- "%s",
|
|
|
ab2726 |
- data->fname);
|
|
|
ab2726 |
- std::string message
|
|
|
ab2726 |
- = string_printf ("Downloading %.2f MB %s %s", size_in_mb, data->desc,
|
|
|
ab2726 |
- styled_filename.c_str());
|
|
|
ab2726 |
- data->meter.emplace (current_uiout, message, 1);
|
|
|
ab2726 |
- }
|
|
|
ab2726 |
+ /* Include the transfer size, if available. */
|
|
|
ab2726 |
+ if (total > 0)
|
|
|
ab2726 |
+ {
|
|
|
ab2726 |
+ float size = 1.0f * total / 1024;
|
|
|
ab2726 |
+ const char *unit = "KB";
|
|
|
ab2726 |
+
|
|
|
ab2726 |
+ /* If size is greater than 0.01 MB, set unit to MB. */
|
|
|
ab2726 |
+ if (size > 10.24)
|
|
|
ab2726 |
+ {
|
|
|
ab2726 |
+ size /= 1024;
|
|
|
ab2726 |
+ unit = "MB";
|
|
|
ab2726 |
+ }
|
|
|
ab2726 |
+
|
|
|
ab2726 |
+ printf_filtered ("Downloading %.2f %s %s %ps...\n",
|
|
|
ab2726 |
+ size, unit, data->desc,
|
|
|
ab2726 |
+ styled_string (file_name_style.style (),
|
|
|
ab2726 |
+ data->fname));
|
|
|
ab2726 |
+ }
|
|
|
ab2726 |
+ else
|
|
|
ab2726 |
+ printf_filtered ("Downloading %s %ps...\n", data->desc,
|
|
|
ab2726 |
+ styled_string (file_name_style.style (), data->fname));
|
|
|
ab2726 |
|
|
|
ab2726 |
- current_uiout->progress ((double)cur / (double)total);
|
|
|
ab2726 |
+ data->has_printed = true;
|
|
|
ab2726 |
+ }
|
|
|
ab2726 |
|
|
|
ab2726 |
return 0;
|
|
|
ab2726 |
}
|