From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id /onoNWhSz1/AZQAAWB0awg (envelope-from ) for ; Tue, 08 Dec 2020 05:16:08 -0500 Received: by simark.ca (Postfix, from userid 112) id D578C1F096; Tue, 8 Dec 2020 05:16:08 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2042B1E99A for ; Tue, 8 Dec 2020 05:16:08 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3D1B384A4BF; Tue, 8 Dec 2020 10:16:07 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 830833865470 for ; Tue, 8 Dec 2020 10:16:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 830833865470 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mliska@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9766DAD07; Tue, 8 Dec 2020 10:16:04 +0000 (UTC) Subject: Re: [PATCH] gdb: print size of downloaded debuginfod binary To: Simon Marchi , gdb-patches@sourceware.org References: <6ad82f30-0ca3-8b19-2907-d71f0dfecafe@suse.cz> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <2c28a403-a169-0dc3-9b64-58484237c8c2@suse.cz> Date: Tue, 8 Dec 2020 11:16:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------179757F006A7236C70E35057" Content-Language: en-US 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This is a multi-part message in MIME format. --------------179757F006A7236C70E35057 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit On 12/7/20 6:07 PM, Simon Marchi wrote: > > > On 2020-12-07 6:43 a.m., Martin Liška wrote: >> With the patch, one can see now: >> >> Reading symbols from /usr/bin/gcc... >> Downloading 2.69 MiB separate debug info for /usr/bin/gcc... >> Downloading 1.00 MiB separate debug info for /lib64/ld-linux-x86-64.so.2... >> Downloading 10.72 MiB separate debug info for /lib64/libc.so.6... >> ... > Thank you for the review. > I think that's a good idea.  Given that we don't have a progress bar (yet), this gives clue to the user about why it might take some time. Btw. I can also offer a WIP patch that implements the progress bar: ... Temporary breakpoint 1 at 0x406150: file /home/marxin/Programming/gcc/gcc/gcc-main.c, line 44. Starting program: /home/marxin/bin/gcc/bin/gcc Downloading 1.00 MB separate debug info for /lib64/ld-linux-x86-64.so.2...10%..20%..30%..40%..50%..60%..70%..80%..90%..100% Downloading 4.20 MB separate debug info for /lib64/libm.so.6...10%..20%..30%..40%..50%..60%..70%..80%..90%..100% Downloading 10.72 MB separate debug info for /lib64/libc.so.6...10%..20%..30%..40%..50% Thoughts? > > Let's see if others have other opinions about this.  If nothing comes for by next week, you can go ahead and merge it. All right, thanks, Martin > > Simon --------------179757F006A7236C70E35057 Content-Type: text/x-patch; charset=UTF-8; name="gdb-progress-bar.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdb-progress-bar.patch" diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index e21b2f40ca..5a810b897d 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -43,14 +43,17 @@ debuginfod_debuginfo_query (const unsigned char *build_id, #else #include +#define PROGRESS_STEP_PERCENT 10 + struct user_data { user_data (const char *desc, const char *fname) - : desc (desc), fname (fname), has_printed (false) + : desc (desc), fname (fname), next_percent_progress (PROGRESS_STEP_PERCENT), has_printed (false) { } const char * const desc; const char * const fname; + long next_percent_progress; bool has_printed; }; @@ -74,6 +77,7 @@ progressfn (debuginfod_client *c, long cur, long total) if (check_quit_flag ()) { + // TODO printf_filtered ("Cancelling download of %s %ps...\n", data->desc, styled_string (file_name_style.style (), data->fname)); @@ -84,9 +88,23 @@ progressfn (debuginfod_client *c, long cur, long total) { /* Print this message only once. */ data->has_printed = true; - printf_filtered ("Downloading %s %ps...\n", + printf_filtered ("Downloading %.2f MB %s %ps.", + 1.0f * total / (1024 * 1024), data->desc, styled_string (file_name_style.style (), data->fname)); + gdb_flush (gdb_stdout); + } + else if (total != 0) + { + long percent = 100 * cur / total; + while (percent >= data->next_percent_progress) + { + printf ("..%ld%%", data->next_percent_progress); + data->next_percent_progress += PROGRESS_STEP_PERCENT; + } + if (percent == 100) + printf ("\n"); + gdb_flush (gdb_stdout); } return 0; --------------179757F006A7236C70E35057--