From patchwork Tue Apr 9 18:09:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32226 Received: (qmail 58992 invoked by alias); 9 Apr 2019 18:09:52 -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 58958 invoked by uid 89); 9 Apr 2019 18:09:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=FULL X-HELO: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.46.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Apr 2019 18:09:48 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 6479F400D9BB4 for ; Tue, 9 Apr 2019 13:09:47 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id DvBrhLrCZ90onDvBrhYNWL; Tue, 09 Apr 2019 13:09:47 -0500 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=W+9Y5JnUduEoffrUg+FXlb/CDJV+EwST2kPwPtudDSE=; b=usreVru2ldt2Vfi6IzondpJolF nH+QUlVB0TpQI2qjbUf1Y+ZC7B6d9UHVWPhvrRE7MDx2gO06FV8tNFRq/8KEct8GJ81xXi0PigNpc wzX4CLYGE8j61RZISpqhQ8D/r; Received: from 174-29-37-56.hlrn.qwest.net ([174.29.37.56]:33050 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hDvBr-003Khd-66; Tue, 09 Apr 2019 13:09:47 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/3] Remove some uses of "object_files" Date: Tue, 9 Apr 2019 12:09:43 -0600 Message-Id: <20190409180945.21621-2-tom@tromey.com> In-Reply-To: <20190409180945.21621-1-tom@tromey.com> References: <20190409180945.21621-1-tom@tromey.com> The "object_files" macro is sometimes used when iterating over objfiles. This patch removes a few such uses in favor of the new range adapter. gdb/ChangeLog 2019-04-09 Tom Tromey * ia64-tdep.c (ia64_get_dyn_info_list): Use foreach. * minsyms.c (lookup_minimal_symbol): Use foreach. (lookup_minimal_symbol_text, lookup_minimal_symbol_by_pc_name) (lookup_minimal_symbol_solib_trampoline): Likewise. * symfile.c (reread_symbols): Use foreach. --- gdb/ChangeLog | 8 ++++++++ gdb/ia64-tdep.c | 3 +-- gdb/minsyms.c | 26 ++++++++++---------------- gdb/symfile.c | 3 +-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 7b4d0a0bfa1..f46673986ba 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -2845,7 +2845,6 @@ ia64_get_dyn_info_list (unw_addr_space_t as, unw_word_t *dilap, void *arg) { struct obj_section *text_sec; - struct objfile *objfile; unw_word_t ip, addr; unw_dyn_info_t di; int ret; @@ -2853,7 +2852,7 @@ ia64_get_dyn_info_list (unw_addr_space_t as, if (!libunwind_is_initialized ()) return -UNW_ENOINFO; - for (objfile = object_files; objfile; objfile = objfile->next) + for (objfile *objfile : current_program_space->objfiles ()) { void *buf = NULL; diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 51b65f51421..34198d122dc 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -308,7 +308,6 @@ struct bound_minimal_symbol lookup_minimal_symbol (const char *name, const char *sfile, struct objfile *objf) { - struct objfile *objfile; found_minimal_symbols found; unsigned int mangled_hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; @@ -323,10 +322,11 @@ lookup_minimal_symbol (const char *name, const char *sfile, lookup_name_info lookup_name (name, symbol_name_match_type::FULL); - for (objfile = object_files; - objfile != NULL && found.external_symbol.minsym == NULL; - objfile = objfile->next) + for (objfile *objfile : current_program_space->objfiles ()) { + if (found.external_symbol.minsym != NULL) + break; + if (objf == NULL || objf == objfile || objf == objfile->separate_debug_objfile_backlink) { @@ -522,17 +522,17 @@ iterate_over_minimal_symbols struct bound_minimal_symbol lookup_minimal_symbol_text (const char *name, struct objfile *objf) { - struct objfile *objfile; struct minimal_symbol *msymbol; struct bound_minimal_symbol found_symbol = { NULL, NULL }; struct bound_minimal_symbol found_file_symbol = { NULL, NULL }; unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; - for (objfile = object_files; - objfile != NULL && found_symbol.minsym == NULL; - objfile = objfile->next) + for (objfile *objfile : current_program_space->objfiles ()) { + if (found_symbol.minsym != NULL) + break; + if (objf == NULL || objf == objfile || objf == objfile->separate_debug_objfile_backlink) { @@ -574,14 +574,11 @@ struct minimal_symbol * lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name, struct objfile *objf) { - struct objfile *objfile; struct minimal_symbol *msymbol; unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; - for (objfile = object_files; - objfile != NULL; - objfile = objfile->next) + for (objfile *objfile : current_program_space->objfiles ()) { if (objf == NULL || objf == objfile || objf == objfile->separate_debug_objfile_backlink) @@ -606,15 +603,12 @@ struct bound_minimal_symbol lookup_minimal_symbol_solib_trampoline (const char *name, struct objfile *objf) { - struct objfile *objfile; struct minimal_symbol *msymbol; struct bound_minimal_symbol found_symbol = { NULL, NULL }; unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; - for (objfile = object_files; - objfile != NULL; - objfile = objfile->next) + for (objfile *objfile : current_program_space->objfiles ()) { if (objf == NULL || objf == objfile || objf == objfile->separate_debug_objfile_backlink) diff --git a/gdb/symfile.c b/gdb/symfile.c index dbfc306c521..ba82f1b83ca 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2427,7 +2427,6 @@ remove_symbol_file_command (const char *args, int from_tty) void reread_symbols (void) { - struct objfile *objfile; long new_modtime; struct stat new_statbuf; int res; @@ -2439,7 +2438,7 @@ reread_symbols (void) This routine should then walk down each partial symbol table and see if the symbol table that it originates from has been changed. */ - for (objfile = object_files; objfile; objfile = objfile->next) + for (objfile *objfile : current_program_space->objfiles ()) { if (objfile->obfd == NULL) continue;