Blame SOURCES/gdb-rhbz2068280-debuginfod-unavailable-size.patch

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