From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 5B9863858412 for ; Sat, 8 Jul 2023 02:36:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5B9863858412 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1688783786; bh=BOAeUnroEDIILuu3ilCb5GjhepmuEEy3k4dwK9IhYIM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=QGNvlXIg2lzZewHFdvymYsTR0PCsaJ3IhwU2wjGJXa6mpnU9DwAYZbOZF7Srb1f3K /g5oeobk9orz06ekptup02o+xrQ/9CILMN6tuQIyc3EAL87etaBMt6F1vSQM//Hk2X W4U1Y0H9Y5v+w/Cjy3BGulG6hkqep4gIx7ryxK5w= Received: from [10.0.0.170] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 073731E0AC; Fri, 7 Jul 2023 22:36:25 -0400 (EDT) Message-ID: <09e275a6-b8e3-7e70-f011-b2b4b85721a3@simark.ca> Date: Fri, 7 Jul 2023 22:36:25 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCHv3] gdb: style filenames in separate debug file warnings To: Andrew Burgess , gdb-patches@sourceware.org Cc: Tom Tromey , ahajkova@redhat.com References: <6155eec155cc8295116def8a70a68a22ac45fdf6.1688483833.git.aburgess@redhat.com> <87v8evkblt.fsf@redhat.com> Content-Language: fr From: Simon Marchi In-Reply-To: <87v8evkblt.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 7/7/23 11:03, Andrew Burgess wrote: > Simon Marchi writes: > >>> @@ -209,7 +210,7 @@ build_id_to_exec_bfd (size_t build_id_len, const bfd_byte *build_id) >>> >>> std::string >>> find_separate_debug_file_by_buildid (struct objfile *objfile, >>> - std::vector *warnings_vector) >>> + deferred_warnings *warnings) >> Reference instead of pointer? > > I thought at one point (maybe I'm miss-remembering) GDB style was to > pass a pointer if an object was modified, and a const reference when an > object was not going to be modified. I've stuck to that since pretty > much forever for GDB code .... is this not (or was it never) a thing? > > I've not changed this for now, but I can do this if that's your > preference, just let me know. I had added it to the wiki for a brief period of time, but removed it since there was some disagreement (not in the thread, it must have been offline, on IRC, or in another thread): https://inbox.sourceware.org/gdb-patches/b31a374788e2b6067786fb8c6c0a3acc@polymtl.ca/ I based myself on the Google style guide at the time, which I thought had a good rationale. But they have since changed it to allow non-const references: https://github.com/google/styleguide/commit/7a7a2f510efe7d7fc Since then I've gotten used to it, and use non-const references when needed, since that's just the C++ way to do it. >>> @@ -1274,11 +1273,10 @@ elf_symfile_read_dwarf2 (struct objfile *objfile, >>> } >>> } >>> } >>> - /* If all the methods to collect the debuginfo failed, print >>> - the warnings, if there're any. */ >>> - if (debugfile.empty () && !has_dwarf2 && !warnings_vector.empty ()) >>> - for (const std::string &w : warnings_vector) >>> - warning ("%s", w.c_str ()); >>> + /* If all the methods to collect the debuginfo failed, print the >>> + warnings, if there are any. */ >>> + if (debugfile.empty () && !has_dwarf2 && !warnings.empty ()) >>> + warnings.emit (); >> >> The warnings.empty() seems unnecessary to me, since emit will be a no-op >> if there are no warnings. > > Funny you should call this out. I added the .empty() just prior to > posting this to the mailing list because, when I gave the patches a > final review, it in someway felt more obvious what was going on if there > was an empty check. But I'm not really tied to it, so I'm going to > remove the empty check. No strong feelings here. But the "if there are any" in your comment makes it clear to me that there might be no warnings to emit. > An updated version of the patch is below. I don't really have time right now to look at the updated patch, but if all you changed is things I pointed out: Approved-By: Simon Marchi Simon