From patchwork Thu Jan 17 02:50:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31083 Received: (qmail 98018 invoked by alias); 17 Jan 2019 02:50:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 97889 invoked by uid 89); 17 Jan 2019 02:50:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=adapter, target_ops X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (50.116.127.2) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Jan 2019 02:50:36 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 948B3400C9DA8 for ; Wed, 16 Jan 2019 20:03:07 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id jxlKgaocT2PzOjxlLgD8NN; Wed, 16 Jan 2019 20:50:35 -0600 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=+goIqaStpaFIdIdDWJLh0J3uFxUN2MoPJMU8VyadIHo=; b=tKQONRKl/im0IJirb6lwoOI41k ditq1ztcGqQ6V0SS5f9ACGrxfaECPqw2QrsBfEbCACPwpdgOqmCBEUGlgogg1sjsdzpYi9EUnMk/a GDFg8GIjoUbiVIcCa4H3qyBKQ; Received: from 75-166-72-210.hlrn.qwest.net ([75.166.72.210]:41222 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gjxlK-0045Wd-NJ; Wed, 16 Jan 2019 20:50:34 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/6] Change all_objfiles_safe adapter to be a method on program_space Date: Wed, 16 Jan 2019 19:50:28 -0700 Message-Id: <20190117025032.9265-3-tom@tromey.com> In-Reply-To: <20190117025032.9265-1-tom@tromey.com> References: <20190117025032.9265-1-tom@tromey.com> This changes the all_objfiles_safe range adapter to be a method on the program space, and fixes up all the users. gdb/ChangeLog 2019-01-15 Tom Tromey * progspace.h (program_space) : New typedef. : New method. * objfiles.h (class all_objfiles_safe): Remove. * objfiles.c (free_all_objfiles, objfile_purge_solibs): Update. * jit.c (jit_inferior_exit_hook): Update. --- gdb/ChangeLog | 11 ++++++++++- gdb/jit.c | 2 +- gdb/objfiles.c | 4 ++-- gdb/objfiles.h | 22 ---------------------- gdb/progspace.h | 18 ++++++++++++++++++ 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/gdb/jit.c b/gdb/jit.c index 543eb60995..645b3ff97e 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -1391,7 +1391,7 @@ jit_breakpoint_re_set (void) static void jit_inferior_exit_hook (struct inferior *inf) { - for (objfile *objf : all_objfiles_safe (current_program_space)) + for (objfile *objf : current_program_space->all_objfiles_safe ()) { struct jit_objfile_data *objf_data = (struct jit_objfile_data *) objfile_data (objf, jit_objfile_data); diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 569e308b6b..e9432ca145 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -735,7 +735,7 @@ free_all_objfiles (void) for (so = master_so_list (); so; so = so->next) gdb_assert (so->objfile == NULL); - for (objfile *objfile : all_objfiles_safe (current_program_space)) + for (objfile *objfile : current_program_space->all_objfiles_safe ()) delete objfile; clear_symtab_users (0); } @@ -1044,7 +1044,7 @@ have_full_symbols (void) void objfile_purge_solibs (void) { - for (objfile *objf : all_objfiles_safe (current_program_space)) + for (objfile *objf : current_program_space->all_objfiles_safe ()) { /* We assume that the solib package has been purged already, or will be soon. */ diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 9ab0f38280..244c1280be 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -553,28 +553,6 @@ extern void default_iterate_over_objfiles_in_search_order void *cb_data, struct objfile *current_objfile); -/* An iterarable object that can be used to iterate over all - objfiles. The basic use is in a foreach, like: - - for (objfile *objf : all_objfiles_safe (pspace)) { ... } - - This variant uses a basic_safe_iterator so that objfiles can be - deleted during iteration. */ - -class all_objfiles_safe - : public next_adapter>> -{ -public: - - explicit all_objfiles_safe (struct program_space *pspace) - : next_adapter>> - (pspace->objfiles) - { - } -}; - /* A range adapter that makes it possible to iterate over all compunits in one objfile. */ diff --git a/gdb/progspace.h b/gdb/progspace.h index 5006840d85..dd97a4e2be 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -26,6 +26,8 @@ #include "gdb_bfd.h" #include "gdb_vecs.h" #include "registry.h" +#include "common/next-iterator.h" +#include "common/safe-iterator.h" struct target_ops; struct bfd; @@ -148,6 +150,22 @@ struct program_space return all_objfiles_range (objfiles); } + typedef next_adapter>> + all_objfiles_safe_range; + + /* An iterable object that can be used to iterate over all objfiles. + The basic use is in a foreach, like: + + for (objfile *objf : pspace->all_objfiles_safe ()) { ... } + + This variant uses a basic_safe_iterator so that objfiles can be + deleted during iteration. */ + all_objfiles_safe_range all_objfiles_safe () + { + return all_objfiles_safe_range (objfiles); + } + /* Pointer to next in linked list. */ struct program_space *next = NULL;