From: "Martin Liška" <mliska@suse.cz>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: print size of downloaded debuginfod binary
Date: Wed, 9 Dec 2020 11:51:16 +0100 [thread overview]
Message-ID: <f47d2e0d-ef8a-e842-78c8-2dfb6481b60f@suse.cz> (raw)
In-Reply-To: <cfcaa2c3-0708-d2f5-ba8d-18d7e28954ca@polymtl.ca>
[-- Attachment #1: Type: text/plain, Size: 774 bytes --]
On 12/8/20 3:28 PM, Simon Marchi wrote:
> On 2020-12-08 5:16 a.m., Martin Liška wrote:
>> 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?
>
> Could you make it so the percentage always gets written at the same place, overwriting the previous percentage written?
Sure, implemented in the attached patch.
Martin
>
> Simon
[-- Attachment #2: 0001-gdb-Print-percent-progress-for-debuginfod.patch --]
[-- Type: text/x-patch, Size: 2171 bytes --]
From 51f332475399ce42767fc912291fa879b91d4ddf Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Wed, 9 Dec 2020 11:48:15 +0100
Subject: [PATCH] gdb: Print percent progress for debuginfod.
Prints progress like:
Downloading 4.89 MB separate debug info for /usr/lib64/libgcrypt.so.20.. 100%
Downloading 1.10 MB separate debug info for /usr/lib64/liblzma.so.5.. 100%
Downloading 1.31 MB separate debug info for /usr/lib64/liblz4.so.1.. 100%
Downloading 0.96 MB separate debug info for /usr/lib64/libsmime3.so.. 36%
ChangeLog:
* gdb/debuginfod-support.c (struct user_data): Add
last_percent_printed field.
(progressfn): Print progress.
---
gdb/debuginfod-support.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index e21b2f40ca..3d68f08fc0 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -46,12 +46,12 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
struct user_data
{
user_data (const char *desc, const char *fname)
- : desc (desc), fname (fname), has_printed (false)
+ : desc (desc), fname (fname), last_percent_printed (-1)
{ }
const char * const desc;
const char * const fname;
- bool has_printed;
+ long last_percent_printed;
};
/* Deleter for a debuginfod_client. */
@@ -80,13 +80,20 @@ progressfn (debuginfod_client *c, long cur, long total)
return 1;
}
- if (!data->has_printed && total != 0)
+ if (total != 0)
{
/* Print this message only once. */
- data->has_printed = true;
- printf_filtered ("Downloading %s %ps...\n",
- data->desc,
- styled_string (file_name_style.style (), data->fname));
+ long percent = 100 * cur / total;
+ if (percent != data->last_percent_printed)
+ {
+ data->last_percent_printed = percent;
+ printf_filtered ("\rDownloading %.2f MB %s %ps.. %3ld%%%s",
+ 1.0f * total / (1024 * 1024),
+ data->desc,
+ styled_string (file_name_style.style (), data->fname),
+ percent, cur == total ? "\n" : "");
+ gdb_flush (gdb_stdout);
+ }
}
return 0;
--
2.29.2
next prev parent reply other threads:[~2020-12-09 10:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 11:43 Martin Liška
2020-12-07 17:07 ` Simon Marchi via Gdb-patches
2020-12-08 10:16 ` Martin Liška
2020-12-08 14:28 ` Simon Marchi via Gdb-patches
2020-12-09 10:51 ` Martin Liška [this message]
2020-12-09 23:26 ` Tom de Vries
2020-12-10 8:26 ` Martin Liška
2020-12-10 19:21 ` Tom Tromey
2020-12-11 17:51 ` [gdb/cli] Add a progress meter Tom de Vries
2020-12-11 17:54 ` [PATCH] gdb: print size of downloaded debuginfod binary Tom de Vries
2020-12-11 19:23 ` Tom Tromey
2020-12-12 16:43 ` Tom de Vries
2020-12-15 20:29 ` Tom Tromey
2020-12-11 19:21 ` [gdb/cli] Add a progress meter Tom Tromey
2020-12-12 16:35 ` Tom de Vries
2020-12-15 20:28 ` Tom Tromey
2020-12-09 20:16 ` [PATCH] gdb: print size of downloaded debuginfod binary Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f47d2e0d-ef8a-e842-78c8-2dfb6481b60f@suse.cz \
--to=mliska@suse.cz \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox