From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 7SJfDzzzjl9WbgAAWB0awg (envelope-from ) for ; Tue, 20 Oct 2020 10:25:00 -0400 Received: by simark.ca (Postfix, from userid 112) id 32A7C1EFC3; Tue, 20 Oct 2020 10:25:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 863C71EFBF for ; Tue, 20 Oct 2020 10:24:59 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27CC03945C2C; Tue, 20 Oct 2020 14:24:59 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 1AB1C3945C2C for ; Tue, 20 Oct 2020 14:24:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1AB1C3945C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (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 A80F81EF48; Tue, 20 Oct 2020 10:24:56 -0400 (EDT) Subject: Re: [PATCH v2 07/16] Remove the exec_bfd macro To: Tom Tromey , gdb-patches@sourceware.org References: <20201019214429.13815-1-tom@tromey.com> <20201019214429.13815-8-tom@tromey.com> From: Simon Marchi Message-ID: <8c4c1ec0-cdc9-ebc9-26fa-216f59493d9b@simark.ca> Date: Tue, 20 Oct 2020 10:24:56 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201019214429.13815-8-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2020-10-19 5:44 p.m., Tom Tromey wrote: > This removes the exec_bfd macro, in favor of new accessors on > program_space. In one spot the accessor can't be used; but this is > still a big improvement over the macro, IMO. Maybe just check for lines that are too long after the replacement. A quick way I use is: $ git show | sed 's|\t| |' | less And when in less, I search for: ^\+.{81} That highlights the lines that are added that are too long. > @@ -480,18 +482,20 @@ exec_file_attach (const char *filename, int from_tty) > gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); > } > > - target_section_table sections = build_section_table (exec_bfd); > + target_section_table sections > + = build_section_table (current_program_space->exec_bfd ()); > > - current_program_space->ebfd_mtime = bfd_get_mtime (exec_bfd); > + current_program_space->ebfd_mtime > + = bfd_get_mtime (current_program_space->exec_bfd ()); > > validate_files (); > > - set_gdbarch_from_file (exec_bfd); > + set_gdbarch_from_file (current_program_space->exec_bfd ()); > > /* Add the executable's sections to the current address spaces' > list of sections. This possibly pushes the exec_ops > target. */ > - add_target_sections (&exec_bfd, sections); > + add_target_sections (¤t_program_space->ebfd, sections); It's odd that the owner of these sections is the address of the ebfd field in the program_space structure, and not the bfd pointer itself. Do you know if this is done on purpose? The only reason I would see is if we wanted a stable "owner" value even when the exec bfd changes. But I don't see any comment to that effect. Looking at the code, it looks like adding and removing the target sections is tied to setting and unsetting the exec bfd. - exec_file_attach sets the exec bfd and adds the corresponding target sections - program_space::close unsets the exec bfd and removes the corresponding target sections I don't see anything that could change the value of exec bfd in the mean time, that would make the "owner" value of these sections stale. So I believe it would be safe to use `current_program_space->exec_bfd ()` as the owner. Otherwise, this patch LGTM. Simon