From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id A3A5C39A3C0B for ; Wed, 28 Jul 2021 21:03:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A3A5C39A3C0B Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 16SL3hQd029530 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jul 2021 17:03:47 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 16SL3hQd029530 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 0424B1E813; Wed, 28 Jul 2021 17:03:42 -0400 (EDT) Subject: Re: [PATCH 16/16] gdb: make string-like set show commands use std::string variable To: Tom Tromey , Simon Marchi via Gdb-patches References: <20210714045520.1623120-1-simon.marchi@polymtl.ca> <20210714045520.1623120-17-simon.marchi@polymtl.ca> <87o8amchfu.fsf@tromey.com> From: Simon Marchi Message-ID: <0edeb3c4-21fe-b368-6c2e-fbb6028eb859@polymtl.ca> Date: Wed, 28 Jul 2021 17:03:42 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <87o8amchfu.fsf@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 28 Jul 2021 21:03:43 +0000 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP 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, 28 Jul 2021 21:03:49 -0000 On 2021-07-28 4:27 p.m., Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi via Gdb-patches writes: > > Simon> String-like settings (var_string, var_filename, var_optional_filename, > Simon> var_string_noescape) currently take a pointer to a `char *` storage > Simon> variable (typically global) that holds the setting's value. I'd like to > Simon> "mordernize" this by changing them to use an std::string for storage. > > It seems like a decent idea to me. I didn't go through the patch. I > imagine it's mostly fairly mechanical transforms. Yes, although there could be more subtle cases where empty string vs nullptr did matter. > Simon> The add_path function in source.c is really complex and twisted, I'd > Simon> rather not try to change it to work on an std::string right now. > Simon> Instead, I added an overload that copies the std:string to a `char *` > Simon> and back. This means more copying, but this is not used in a hot path > Simon> at all, so I think it is acceptable. > > That seems fine. It might be nice if we had a way to track these little > cleanup items. Maybe a tag in bugzilla. I'll try to think adding one when this patch (a subsequent version of it) gets merged. > I suppose the main danger of this patch is lingering old-style variables > in code you couldn't build, say some of the less-supported native > targets. But, we usually handle those on a best-effort basis anyway. > And, maybe they don't use this feature. I did my best to grep and check for those native files I know aren't compiled, but as you say it's best effort. Like with other code-base-wide changes, I think that if I forgot any spots, they will be very easy to fix. Simon