From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id A15BB3858C50 for ; Mon, 17 Apr 2023 15:17:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A15BB3858C50 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 cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 096A91003FB85 for ; Mon, 17 Apr 2023 15:17:19 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id oQbWpsiRfZSXQoQbWpWnn3; Mon, 17 Apr 2023 15:17:19 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=a8T1SWeF c=1 sm=1 tr=0 ts=643d62ff a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=dKHAf1wccvYA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=CCpqsmhAAAAA:8 a=lN4rJeL8KTbm00fnnBkA:9 a=QEXdDO2ut3YA:10:nop_charset_2 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To: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=SfEgT2AI3S/srz6kXxMhI9AzA/WlCm9TDyhe7U0Mlj8=; b=o3g9AKrO13pnAYEyHKf7DKB9iE NU+oatZEVd2K0G802fCPISsZixo/bNrgNG6NsFp8QfSs9Z3wioi6J5QlnX0ZrcRSZi4cW+EWM7pY1 EnmP/ueri/ldrcxTexW9+n8ns; Received: from 71-211-191-82.hlrn.qwest.net ([71.211.191.82]:47280 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 1poQbW-000Vpj-JC; Mon, 17 Apr 2023 09:17:18 -0600 From: Tom Tromey To: Alexandra =?utf-8?B?SMOhamtvdsOh?= via Gdb-patches Cc: Alexandra =?utf-8?B?SMOhamtvdsOh?= Subject: Re: [PATCH v2] Use styled_string when defering warnings when loading separate debug files References: <20230320145638.1202335-1-ahajkova@redhat.com> X-Attribution: Tom Date: Mon, 17 Apr 2023 09:17:17 -0600 In-Reply-To: <20230320145638.1202335-1-ahajkova@redhat.com> ("Alexandra =?utf-8?B?SMOhamtvdsOh?= via Gdb-patches"'s message of "Mon, 20 Mar 2023 15:56:38 +0100") Message-ID: <87jzya4jya.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: 71.211.191.82 X-Source-L: No X-Exim-ID: 1poQbW-000Vpj-JC X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-191-82.hlrn.qwest.net (murgatroyd) [71.211.191.82]:47280 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3019.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "Alexandra" =3D=3D Alexandra H=C3=A1jkov=C3=A1 via Gdb-patches writes: Alexandra> This version uses ui_file rather instead of vector of Alexandra> callback functions that emit warnings. I think instead of a std::vector, what I meant was just use a single string_file. The caller can make it, using something like: string_file file (gdb_stderr->can_emit_style_escape ()); Alexandra> + string_file warnings (true); ... since I think 'true' isn't always correct. Alexandra> + warnings.printf ("\"%ps\":separate debug info file has no de= bug info", Alexandra> + styled_string (file_name_style.style (), Alexandra> + bfd_get_filename (abfd.get ()))); Then this printf can either add a 'warning:' prefix like warning() does, or we can add an overload of "warning" that takes a ui_file as its first parameter. Alexandra> - for (const std::string &w : warnings_vector) Alexandra> + for (const string_file &w : warnings_vector) Alexandra> warning ("%s", w.c_str ()); The approach I mention seems fine because the caller ends up not doing anything except possibly printing the strings. Alexandra> + string_file(string_file &&other) Alexandra> + : m_string (std::move (other.c_str ())), Alexandra> + m_term_out (other.m_term_out) Alexandra> + { Alexandra> + Alexandra> + } Then you wouldn't need this, either. But for future reference I think this is just: string_file (string_file &&other) =3D default; thanks, Tom