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 80A44385780F for ; Tue, 20 Oct 2020 14:40:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 80A44385780F 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 360061EF48; Tue, 20 Oct 2020 10:40:49 -0400 (EDT) Subject: Re: [PP?] [PATCH v2 12/16] Change remove_target_sections to method on program_space To: Tom Tromey , gdb-patches@sourceware.org References: <20201019214429.13815-1-tom@tromey.com> <20201019214429.13815-13-tom@tromey.com> From: Simon Marchi Message-ID: <64804345-db3f-d562-6e82-137fb577df41@simark.ca> Date: Tue, 20 Oct 2020 10:40:49 -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-13-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Tue, 20 Oct 2020 14:40:50 -0000 On 2020-10-19 5:44 p.m., Tom Tromey wrote: > This changes remove_target_sections to be a method on program_space. > This makes sense because this function manipulates data that is > attached to the program space. > > gdb/ChangeLog > 2020-10-19 Tom Tromey > > * progspace.h (struct program_space) : > Declare. > * exec.c (program_space::remove_target_sections): Now a method. > * exec.h (remove_target_sections): Don't declare. > --- > gdb/ChangeLog | 7 +++++++ > gdb/exec.c | 15 ++++++--------- > gdb/exec.h | 4 ---- > gdb/progspace.h | 3 +++ > gdb/solib.c | 6 +++--- > gdb/symfile.c | 2 +- > 6 files changed, 20 insertions(+), 17 deletions(-) > > diff --git a/gdb/exec.c b/gdb/exec.c > index 4a82b38ea41..8952a99bf1a 100644 > --- a/gdb/exec.c > +++ b/gdb/exec.c > @@ -651,31 +651,28 @@ add_target_sections_of_objfile (struct objfile *objfile) > OWNER must be the same value passed to add_target_sections. */ > > void > -remove_target_sections (void *owner) > +program_space::remove_target_sections (void *owner) Would it make sense to make a subsequent patch that just moves this method to progspace.c? I think it's ok to leave it in exec.c in this patch, so we can more easily see the diff, but I think in the end it belongs to progspace.c. The only thing that doesn't belong to progspace.c in this method is: unpush_target (&exec_ops); But I think it just means that we need better decoupling. We could have a "program_space_target_sections_changed" observer, which exec.c would attach to, and push/unpush as necessary. > { > - target_section_table *table = ¤t_program_space->target_sections; > - > gdb_assert (owner != NULL); > > - auto it = std::remove_if (table->begin (), > - table->end (), > + auto it = std::remove_if (target_sections.begin (), > + target_sections.end (), > [&] (target_section §) > { > return sect.owner == owner; > }); > - table->erase (it, table->end ()); > + target_sections.erase (it, target_sections.end ()); > > /* If we don't have any more sections to read memory from, > remove the file_stratum target from the stack of each > inferior sharing the program space. */ > - if (table->empty ()) > + if (target_sections.empty ()) > { > scoped_restore_current_pspace_and_thread restore_pspace_thread; > - program_space *curr_pspace = current_program_space; > > for (inferior *inf : all_inferiors ()) > { > - if (inf->pspace != curr_pspace) > + if (inf->pspace != this) > continue; > > if (!inf->pspace->target_sections.empty ()) This line can be simplified, I believe: if (!this->target_sections.empty ()) (you can omit `this` to be consistent with the rest of the code, I just happen to like using `this` to access fields that aren't prefixed with `m_`, for clarity) Simon