From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yGLUBdEIjl+ERwAAWB0awg (envelope-from ) for ; Mon, 19 Oct 2020 17:44:49 -0400 Received: by simark.ca (Postfix, from userid 112) id 14A911EFC7; Mon, 19 Oct 2020 17:44:49 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,URIBL_BLOCKED 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 131761EFBB for ; Mon, 19 Oct 2020 17:44:47 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 129AD3894C35; Mon, 19 Oct 2020 21:44:42 +0000 (GMT) Received: from gateway20.websitewelcome.com (gateway20.websitewelcome.com [192.185.50.28]) by sourceware.org (Postfix) with ESMTPS id 054E0388EC11 for ; Mon, 19 Oct 2020 21:44:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 054E0388EC11 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 56874400C50C7 for ; Mon, 19 Oct 2020 16:42:55 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id UcxHkSRUvPiqfUcxHkYhSW; Mon, 19 Oct 2020 16:44:35 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=oD3XDd+/s2hlhd9RGCa2SQKWottPsvMPu//JQJ4W4RA=; b=xce0+ue3cEEg6l9TH8RQ68HYj/ 3rFua6zmKO0EuZbwxU8uJVKJQrAs88JV2Bc5z4vXRQaJDd4z8t60RsowVxgiWrYUik5YSWLQzSY5w q5OiQGyKR04xSzuWkjeePMp8l; Received: from 75-166-102-113.hlrn.qwest.net ([75.166.102.113]:45712 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kUcxH-004Oci-E2; Mon, 19 Oct 2020 15:44:35 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH v2 12/16] Change remove_target_sections to method on program_space Date: Mon, 19 Oct 2020 15:44:25 -0600 Message-Id: <20201019214429.13815-13-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20201019214429.13815-1-tom@tromey.com> References: <20201019214429.13815-1-tom@tromey.com> 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: 75.166.102.113 X-Source-L: No X-Exim-ID: 1kUcxH-004Oci-E2 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-102-113.hlrn.qwest.net (bapiya.Home) [75.166.102.113]:45712 X-Source-Auth: tom+tromey.com X-Email-Count: 13 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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) { - 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 ()) diff --git a/gdb/exec.h b/gdb/exec.h index 8590e78710a..d5b3cff3855 100644 --- a/gdb/exec.h +++ b/gdb/exec.h @@ -92,10 +92,6 @@ extern enum target_xfer_status /* Set the loaded address of a section. */ extern void exec_set_section_address (const char *, int, CORE_ADDR); -/* Remove all target sections owned by OWNER. */ - -extern void remove_target_sections (void *owner); - /* Add the sections array defined by [SECTIONS..SECTIONS_END[ to the current set of target sections. */ diff --git a/gdb/progspace.h b/gdb/progspace.h index fa5247f8ac2..f4e1107c6ec 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -297,6 +297,9 @@ struct program_space space. */ bool empty (); + /* Remove all target sections owned by OWNER. */ + void remove_target_sections (void *owner); + /* Unique ID number. */ int num = 0; diff --git a/gdb/solib.c b/gdb/solib.c index baa1801635b..64b2035cd89 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -824,7 +824,7 @@ update_solib_list (int from_tty) /* Some targets' section tables might be referring to sections from so->abfd; remove them. */ - remove_target_sections (gdb); + current_program_space->remove_target_sections (gdb); free_so (gdb); gdb = *gdb_link; @@ -1175,7 +1175,7 @@ clear_solib (void) current_program_space->so_list = so->next; gdb::observers::solib_unloaded.notify (so); - remove_target_sections (so); + current_program_space->remove_target_sections (so); free_so (so); } @@ -1295,7 +1295,7 @@ reload_shared_libraries_1 (int from_tty) if (so->objfile && ! (so->objfile->flags & OBJF_USERLOADED) && !solib_used (so)) so->objfile->unlink (); - remove_target_sections (so); + current_program_space->remove_target_sections (so); clear_so (so); } diff --git a/gdb/symfile.c b/gdb/symfile.c index 493411fa417..504132754b0 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3709,7 +3709,7 @@ symfile_free_objfile (struct objfile *objfile) { /* Remove the target sections owned by this objfile. */ if (objfile != NULL) - remove_target_sections ((void *) objfile); + current_program_space->remove_target_sections ((void *) objfile); } /* Wrapper around the quick_symbol_functions expand_symtabs_matching "method". -- 2.17.2