From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 8C3883853804 for ; Wed, 23 Mar 2022 18:06:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8C3883853804 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-K7DqRHMrPTqVrpPCVI_wfQ-1; Wed, 23 Mar 2022 14:06:48 -0400 X-MC-Unique: K7DqRHMrPTqVrpPCVI_wfQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 374411044562 for ; Wed, 23 Mar 2022 18:06:48 +0000 (UTC) Received: from localhost.localdomain (unknown [10.22.34.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC41F140262B; Wed, 23 Mar 2022 18:06:47 +0000 (UTC) From: Aaron Merey To: keiths@redhat.com Cc: kevinb@redhat.com, gdb-patches@sourceware.org, Aaron Merey Subject: Re: [PATCH] Remove download size from debuginfod progress messages Date: Wed, 23 Mar 2022 14:06:16 -0400 Message-Id: <20220323180616.29957-1-amerey@redhat.com> In-Reply-To: <5ed305d0-3650-a9f9-e128-22f873cd96a0@redhat.com> References: <5ed305d0-3650-a9f9-e128-22f873cd96a0@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2022 18:06:56 -0000 Hi Keith, On Wed, Mar 23, 2022 at 12:02 PM Keith Seitz wrote: > On 3/22/22 17:34, Aaron Merey wrote: > > Currently debuginfod progress update messages include the size of > > each download: > > > >    Downloading 7.5 MB separate debug info /lib/libxyz.so.0 > > > > This value originates from the Content-Length HTTP header of the > > transfer.  However this header is not guaranteed to be present for > > each download.  This can happen when debuginfod servers compress files > > on-the-fly at the time of transfer.  In this case gdb wrongly prints > > "-0.00 MB" as the size. > > I realize this is an interim patch to address an issue currently > under development, and I'm okay with that. There are a lot of > people that use devel versions of gdb to do work. [At least I > hope I'm not alone!] > > However, I would really rather not simply remove all download > sizes. If we can detect the condition that would print the unhelpful > "-0.00 MB", then *just* removing the download size for that case (or > printing "unknown" or something) would be my preferred path. I wanted to keep this patch as simple as possible in order to avoid getting bogged down by details that might be more appropriate for the patch in-progress that reworks these messages. But I agree that we should continue to print sizes if they are available. I've added this to the patch below. Aaron --- Remove download size from debuginfod progress messages if unavailable Currently debuginfod progress update messages include the size of each download: Downloading 7.5 MB separate debug info /lib/libxyz.so.0 This value originates from the Content-Length HTTP header of the transfer. However this header is not guaranteed to be present for each download. This can happen when debuginfod servers compress files on-the-fly at the time of transfer. In this case gdb wrongly prints "-0.00 MB" as the size. This patch removes download sizes from progress messages when they are not available. It also removes usage of the progress bar until a more thorough reworking of progress updating is implemented. [1] [1] https://sourceware.org/pipermail/gdb-patches/2022-February/185798.html --- gdb/debuginfod-support.c | 44 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index 3614ff23882..d5d023ff7bb 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -86,12 +86,12 @@ debuginfod_exec_query (const unsigned char *build_id, struct user_data { user_data (const char *desc, const char *fname) - : desc (desc), fname (fname) + : desc (desc), fname (fname), has_printed (false) { } const char * const desc; const char * const fname; - gdb::optional meter; + bool has_printed; }; /* Deleter for a debuginfod_client. */ @@ -121,24 +121,32 @@ progressfn (debuginfod_client *c, long cur, long total) return 1; } - if (total == 0) - return 0; - - if (!data->meter.has_value ()) + if (!data->has_printed) { - float size_in_mb = 1.0f * total / (1024 * 1024); - string_file styled_filename (current_uiout->can_emit_style_escape ()); - fprintf_styled (&styled_filename, - file_name_style.style (), - "%s", - data->fname); - std::string message - = string_printf ("Downloading %.2f MB %s %s", size_in_mb, data->desc, - styled_filename.c_str()); - data->meter.emplace (current_uiout, message, 1); - } + /* Include the transfer size, if available. */ + if (total > 0) + { + float size = 1.0f * total / 1024; + const char *unit = "KB"; + + /* If size is greater than 0.01 MB, set unit to MB. */ + if (size > 10.24) + { + size /= 1024; + unit = "MB"; + } + + printf_filtered ("Downloading %.2f %s %s %ps...\n", + size, unit, data->desc, + styled_string (file_name_style.style (), + data->fname)); + } + else + printf_filtered ("Downloading %s %ps...\n", data->desc, + styled_string (file_name_style.style (), data->fname)); - data->meter->progress ((double)cur / (double)total); + data->has_printed = true; + } return 0; } -- 2.35.1