From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id BDBDB3934FCF for ; Fri, 21 Oct 2022 20:01:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BDBDB3934FCF Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 6276F100436F3 for ; Fri, 21 Oct 2022 20:01:39 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id lyD4omtFpT2g2lyD5oDjEh; Fri, 21 Oct 2022 20:01:39 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Pds6Ogtd c=1 sm=1 tr=0 ts=6352faa3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=Qawa6l4ZSaYA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=CCpqsmhAAAAA:8 a=RfUlwQO6Gl3gACZviTgA:9 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=K8DXmn4rfdsukgc5vMCGO165n2xqxCXRM+ReGgctS3s=; b=colGeITXajgrUGkpPTGJSKwuyz BE8YHfvPw2TFDx/r0N1NdpK+l5xPjQwQ7lvyCBv5CMmK5YpjiwAyQsbTWd90qHZJvFEz/3urTddKs +XLYeaNkGqAnocibQVvujiZ53; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:56752 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1olyD4-001oj0-5y; Fri, 21 Oct 2022 14:01:38 -0600 From: Tom Tromey To: Aaron Merey via Gdb-patches Subject: Re: [PING*4][PATCH v4] gdb: Improve debuginfod progress updates References: <20221012185327.370210-1-amerey@redhat.com> X-Attribution: Tom Date: Fri, 21 Oct 2022 14:01:35 -0600 In-Reply-To: (Aaron Merey via Gdb-patches's message of "Fri, 21 Oct 2022 12:42:55 -0400") Message-ID: <875ygdaqu8.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.76.186 X-Source-L: No X-Exim-ID: 1olyD4-001oj0-5y X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (murgatroyd) [97.122.76.186]:56752 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3028.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Fri, 21 Oct 2022 20:01:59 -0000 >>>>> "Aaron" == Aaron Merey via Gdb-patches writes: Aaron> Ping Aaron> Thanks, Aaron> Aaron Thanks for the patch. >> + cli_progress_info info; >> + >> + info.pos = 0; >> + info.state = progress_update::START; I think it would be better to have cli_progress_info initialize itself instead of doing it here. >> + m_progress_info.push_back (std::move (info)); This could be just emplace_back then. >> + { >> + /* Position of the progress indicator. */ >> + int pos; like this could be '= 0' >> + /* The current state. */ >> + progress_update::state state; '= progress_update::START' >> diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c >> index 5f04a2b38ca..fc62412fff2 100644 >> --- a/gdb/debuginfod-support.c >> +++ b/gdb/debuginfod-support.c >> @@ -24,7 +24,9 @@ >> #include "gdbsupport/gdb_optional.h" >> #include "cli/cli-cmds.h" >> #include "cli/cli-style.h" >> +#include "cli-out.h" >> #include "target.h" >> +#include Is this include used? >> +/* Convert SIZE into a unit suitable for use with progress updates. >> + SIZE should in given in bytes and will be converted into KB, MB, GB >> + or remain unchanged. UNIT will be set to "B", "KB", "MB" or "GB" >> + accordingly. */ There's a bunch of pedantic thought about the proper suffixes, but I think we should just follow GNU coreutils and use the shorter B/K/M/G. df --help says: The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). Binary prefixes can be used, too: KiB=K, MiB=M, and so on. Also since all the responses are just a constant string, it's better to just return a 'const char *' from the function and avoid allocation. >> +/* Print the result of the most recent attempted download. */ >> + >> +static void >> +print_outcome (user_data &data, int fd) >> +{ >> + /* Clears the current line of progress output. */ >> + current_uiout->do_progress_end (); >> + >> + string_file styled_fname (current_uiout->can_emit_style_escape ()); >> + fprintf_styled (&styled_fname, file_name_style.style (), "%s", >> + data.fname); >> + >> + if (fd < 0 && fd != -ENOENT) >> + gdb_printf (_("Download failed: %s. Continuing without %s %s.\n"), >> + safe_strerror (-fd), data.desc, styled_fname.c_str ()); I think you can use %ps and styled_string here instead of a separate string_file. Not sure this applied elsewhere but it's worth looking. Hmm the old code did it: >> - if (fd.get () < 0 && fd.get () != -ENOENT) >> - gdb_printf (_("Download failed: %s. Continuing without source file %ps.\n"), >> - safe_strerror (-fd.get ()), >> - styled_string (file_name_style.style (), srcpath)); Seems like that can just be reused. >> +void >> +mi_ui_out::do_progress_start () >> +{ >> + mi_progress_info info; >> + >> + info.state = progress_update::START; I don't understand why this creates an object and pushes it on a vector. Wouldn't printing the message from do_progress_start be the same, but avoid all the hair? >> + struct ui_file *stream = gdb_stdout; >> + gdb_printf (stream, "%s...\n", msg.c_str ()); I don't think an explicit stream is needed here. Nothing ever pops the mi_progress_info from the stack. >> void >> diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h >> index 36d7e42345f..d80a7fce259 100644 >> --- a/gdb/mi/mi-out.h >> +++ b/gdb/mi/mi-out.h >> @@ -25,7 +25,6 @@ >> struct ui_out; >> struct ui_file; >> >> - >> class mi_ui_out : public ui_out Spurious change. Tom