From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92883 invoked by alias); 25 Nov 2018 16:54:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 92744 invoked by uid 89); 25 Nov 2018 16:54:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.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.2 spammy=sk:current, partial, iter, debugging X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.143.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 25 Nov 2018 16:54:46 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway31.websitewelcome.com (Postfix) with ESMTP id E82F210F41B for ; Sun, 25 Nov 2018 10:54:44 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id QxgCgEm1uSjJAQxgCgciV6; Sun, 25 Nov 2018 10:54:44 -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=hoq5hwGWCgaW2Ng7ZdmFX78bzh9YA0oWK0JBNEj5ZWc=; b=CrAnUh9ZjztPRqrsjGAAIunhmo uEO/KdejMeb0FPaN/0xL4B5yTDQSeyMG5eFSojl/QN1sNd/fVF8kudWyzDexuSGq9cDR2iTLMa1lm EcB2SBcIsSKWDnJ0+bADQRJds; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:51592 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gQxgC-0013GF-Ml; Sun, 25 Nov 2018 10:54:44 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 07/12] Remove ALL_COMPUNITS Date: Sun, 25 Nov 2018 16:54:00 -0000 Message-Id: <20181125165439.13773-8-tom@tromey.com> In-Reply-To: <20181125165439.13773-1-tom@tromey.com> References: <20181125165439.13773-1-tom@tromey.com> X-SW-Source: 2018-11/txt/msg00405.txt.bz2 This removes the ALL_COMPUNITS, replacing its uses with two nested ranged for loops. gdb/ChangeLog 2018-11-25 Tom Tromey * symtab.c (lookup_objfile_from_block) (find_pc_sect_compunit_symtab, search_symbols) (default_collect_symbol_completion_matches_break_on): Use objfile_compunits. * objfiles.h (ALL_COMPUNITS): Remove. * maint.c (count_symtabs_and_blocks): Use objfile_compunits. * cp-support.c (add_symbol_overload_list_qualified): Use objfile_compunits. * ada-lang.c (ada_collect_symbol_completion_matches) (ada_add_global_exceptions): Use objfile_compunits. --- gdb/ChangeLog | 13 +++++ gdb/ada-lang.c | 106 ++++++++++++++++++++-------------------- gdb/cp-support.c | 33 +++++++------ gdb/maint.c | 16 +++--- gdb/objfiles.h | 6 --- gdb/symtab.c | 125 +++++++++++++++++++++++------------------------ 6 files changed, 152 insertions(+), 147 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 1a1db17421..64f3b53303 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6461,41 +6461,42 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker, /* Go through the symtabs and check the externs and statics for symbols which match. */ - struct objfile *objfile; - ALL_COMPUNITS (objfile, s) - { - QUIT; - b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK); - ALL_BLOCK_SYMBOLS (b, iter, sym) - { - if (completion_skip_symbol (mode, sym)) - continue; + for (struct objfile *objfile : all_objfiles (current_program_space)) + for (struct compunit_symtab *s : objfile_compunits (objfile)) + { + QUIT; + b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK); + ALL_BLOCK_SYMBOLS (b, iter, sym) + { + if (completion_skip_symbol (mode, sym)) + continue; - completion_list_add_name (tracker, - SYMBOL_LANGUAGE (sym), - SYMBOL_LINKAGE_NAME (sym), - lookup_name, text, word); - } - } + completion_list_add_name (tracker, + SYMBOL_LANGUAGE (sym), + SYMBOL_LINKAGE_NAME (sym), + lookup_name, text, word); + } + } - ALL_COMPUNITS (objfile, s) - { - QUIT; - b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK); - /* Don't do this block twice. */ - if (b == surrounding_static_block) - continue; - ALL_BLOCK_SYMBOLS (b, iter, sym) - { - if (completion_skip_symbol (mode, sym)) - continue; + for (struct objfile *objfile : all_objfiles (current_program_space)) + for (struct compunit_symtab *s : objfile_compunits (objfile)) + { + QUIT; + b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK); + /* Don't do this block twice. */ + if (b == surrounding_static_block) + continue; + ALL_BLOCK_SYMBOLS (b, iter, sym) + { + if (completion_skip_symbol (mode, sym)) + continue; - completion_list_add_name (tracker, - SYMBOL_LANGUAGE (sym), - SYMBOL_LINKAGE_NAME (sym), - lookup_name, text, word); - } - } + completion_list_add_name (tracker, + SYMBOL_LANGUAGE (sym), + SYMBOL_LINKAGE_NAME (sym), + lookup_name, text, word); + } + } } /* Field Access */ @@ -13544,8 +13545,6 @@ static void ada_add_global_exceptions (compiled_regex *preg, std::vector *exceptions) { - struct objfile *objfile; - /* In Ada, the symbol "search name" is a linkage name, whereas the regular expression used to do the matching refers to the natural name. So match against the decoded name. */ @@ -13559,28 +13558,29 @@ ada_add_global_exceptions (compiled_regex *preg, NULL, VARIABLES_DOMAIN); - ALL_COMPUNITS (objfile, s) - { - const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (s); - int i; + for (struct objfile *objfile : all_objfiles (current_program_space)) + for (struct compunit_symtab *s : objfile_compunits (objfile)) + { + const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (s); + int i; - for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++) - { - struct block *b = BLOCKVECTOR_BLOCK (bv, i); - struct block_iterator iter; - struct symbol *sym; + for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++) + { + struct block *b = BLOCKVECTOR_BLOCK (bv, i); + struct block_iterator iter; + struct symbol *sym; - ALL_BLOCK_SYMBOLS (b, iter, sym) - if (ada_is_non_standard_exception_sym (sym) - && name_matches_regex (SYMBOL_NATURAL_NAME (sym), preg)) - { - struct ada_exc_info info - = {SYMBOL_PRINT_NAME (sym), SYMBOL_VALUE_ADDRESS (sym)}; + ALL_BLOCK_SYMBOLS (b, iter, sym) + if (ada_is_non_standard_exception_sym (sym) + && name_matches_regex (SYMBOL_NATURAL_NAME (sym), preg)) + { + struct ada_exc_info info + = {SYMBOL_PRINT_NAME (sym), SYMBOL_VALUE_ADDRESS (sym)}; - exceptions->push_back (info); - } - } - } + exceptions->push_back (info); + } + } + } } /* Implements ada_exceptions_list with the regular expression passed diff --git a/gdb/cp-support.c b/gdb/cp-support.c index e976354f1f..5b4119b67e 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1374,7 +1374,6 @@ static void add_symbol_overload_list_qualified (const char *func_name, std::vector *overload_list) { - struct objfile *objfile; const struct block *b, *surrounding_static_block = 0; /* Look through the partial symtabs for all symbols which begin by @@ -1397,22 +1396,24 @@ add_symbol_overload_list_qualified (const char *func_name, /* Go through the symtabs and check the externs and statics for symbols which match. */ - ALL_COMPUNITS (objfile, cust) - { - QUIT; - b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK); - add_symbol_overload_list_block (func_name, b, overload_list); - } + for (struct objfile *objfile : all_objfiles (current_program_space)) + for (struct compunit_symtab *cust : objfile_compunits (objfile)) + { + QUIT; + b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK); + add_symbol_overload_list_block (func_name, b, overload_list); + } - ALL_COMPUNITS (objfile, cust) - { - QUIT; - b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK); - /* Don't do this block twice. */ - if (b == surrounding_static_block) - continue; - add_symbol_overload_list_block (func_name, b, overload_list); - } + for (struct objfile *objfile : all_objfiles (current_program_space)) + for (struct compunit_symtab *cust : objfile_compunits (objfile)) + { + QUIT; + b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK); + /* Don't do this block twice. */ + if (b == surrounding_static_block) + continue; + add_symbol_overload_list_block (func_name, b, overload_list); + } } /* Lookup the rtti type for a class name. */ diff --git a/gdb/maint.c b/gdb/maint.c index 56fbf3cfba..5cd5b01936 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -762,7 +762,6 @@ static void count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr, int *nr_blocks_ptr) { - struct objfile *o; struct symtab *s; int nr_symtabs = 0; int nr_compunit_symtabs = 0; @@ -773,13 +772,14 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr, current_program_space may be NULL. */ if (current_program_space != NULL) { - ALL_COMPUNITS (o, cu) - { - ++nr_compunit_symtabs; - nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu)); - ALL_COMPUNIT_FILETABS (cu, s) - ++nr_symtabs; - } + for (struct objfile *o : all_objfiles (current_program_space)) + for (struct compunit_symtab *cu : objfile_compunits (o)) + { + ++nr_compunit_symtabs; + nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu)); + ALL_COMPUNIT_FILETABS (cu, s) + ++nr_symtabs; + } } *nr_symtabs_ptr = nr_symtabs; diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 916d80f571..165a6e3cf1 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -718,12 +718,6 @@ private: ALL_OBJFILES (objfile) \ ALL_OBJFILE_FILETABS (objfile, ps, s) -/* Traverse all compunits in all objfiles in the current program space. */ - -#define ALL_COMPUNITS(objfile, cu) \ - ALL_OBJFILES (objfile) \ - for (struct compunit_symtab *cu : objfile_compunits (objfile)) - #define ALL_OBJFILE_OSECTIONS(objfile, osect) \ for (osect = objfile->sections; osect < objfile->sections_end; osect++) \ if (osect->the_bfd_section == NULL) \ diff --git a/gdb/symtab.c b/gdb/symtab.c index 49dd30235c..86fa99b057 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2166,22 +2166,21 @@ lookup_local_symbol (const char *name, struct objfile * lookup_objfile_from_block (const struct block *block) { - struct objfile *obj; - if (block == NULL) return NULL; block = block_global_block (block); /* Look through all blockvectors. */ - ALL_COMPUNITS (obj, cust) - if (block == BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), - GLOBAL_BLOCK)) - { - if (obj->separate_debug_objfile_backlink) - obj = obj->separate_debug_objfile_backlink; + for (struct objfile *obj : all_objfiles (current_program_space)) + for (struct compunit_symtab *cust : objfile_compunits (obj)) + if (block == BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), + GLOBAL_BLOCK)) + { + if (obj->separate_debug_objfile_backlink) + obj = obj->separate_debug_objfile_backlink; - return obj; - } + return obj; + } return NULL; } @@ -2871,7 +2870,6 @@ struct compunit_symtab * find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) { struct compunit_symtab *best_cust = NULL; - struct objfile *objfile; CORE_ADDR distance = 0; struct bound_minimal_symbol msymbol; @@ -2904,57 +2902,58 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) It also happens for objfiles that have their functions reordered. For these, the symtab we are looking for is not necessarily read in. */ - ALL_COMPUNITS (objfile, cust) - { - struct block *b; - const struct blockvector *bv; + for (struct objfile *objfile : all_objfiles (current_program_space)) + for (struct compunit_symtab *cust : objfile_compunits (objfile)) + { + struct block *b; + const struct blockvector *bv; - bv = COMPUNIT_BLOCKVECTOR (cust); - b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); + bv = COMPUNIT_BLOCKVECTOR (cust); + b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); - if (BLOCK_START (b) <= pc - && BLOCK_END (b) > pc - && (distance == 0 - || BLOCK_END (b) - BLOCK_START (b) < distance)) - { - /* For an objfile that has its functions reordered, - find_pc_psymtab will find the proper partial symbol table - and we simply return its corresponding symtab. */ - /* In order to better support objfiles that contain both - stabs and coff debugging info, we continue on if a psymtab - can't be found. */ - if ((objfile->flags & OBJF_REORDERED) && objfile->sf) + if (BLOCK_START (b) <= pc + && BLOCK_END (b) > pc + && (distance == 0 + || BLOCK_END (b) - BLOCK_START (b) < distance)) { - struct compunit_symtab *result; - - result - = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, - msymbol, - pc, section, - 0); - if (result != NULL) - return result; - } - if (section != 0) - { - struct block_iterator iter; - struct symbol *sym = NULL; - - ALL_BLOCK_SYMBOLS (b, iter, sym) + /* For an objfile that has its functions reordered, + find_pc_psymtab will find the proper partial symbol table + and we simply return its corresponding symtab. */ + /* In order to better support objfiles that contain both + stabs and coff debugging info, we continue on if a psymtab + can't be found. */ + if ((objfile->flags & OBJF_REORDERED) && objfile->sf) { - fixup_symbol_section (sym, objfile); - if (matching_obj_sections (SYMBOL_OBJ_SECTION (objfile, sym), - section)) - break; + struct compunit_symtab *result; + + result + = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, + msymbol, + pc, section, + 0); + if (result != NULL) + return result; + } + if (section != 0) + { + struct block_iterator iter; + struct symbol *sym = NULL; + + ALL_BLOCK_SYMBOLS (b, iter, sym) + { + fixup_symbol_section (sym, objfile); + if (matching_obj_sections (SYMBOL_OBJ_SECTION (objfile, sym), + section)) + break; + } + if (sym == NULL) + continue; /* No symbol in this symtab matches + section. */ } - if (sym == NULL) - continue; /* No symbol in this symtab matches - section. */ + distance = BLOCK_END (b) - BLOCK_START (b); + best_cust = cust; } - distance = BLOCK_END (b) - BLOCK_START (b); - best_cust = cust; } - } if (best_cust != NULL) return best_cust; @@ -4463,7 +4462,7 @@ search_symbols (const char *regexp, enum search_domain kind, { /* Note: An important side-effect of these lookup functions is to expand the symbol table if msymbol is found, for the - benefit of the next loop on ALL_COMPUNITS. */ + benefit of the next loop compunits. */ if (kind == FUNCTIONS_DOMAIN ? (find_pc_compunit_symtab (MSYMBOL_VALUE_ADDRESS (objfile, msymbol)) == NULL) @@ -4477,9 +4476,8 @@ search_symbols (const char *regexp, enum search_domain kind, } } - { - struct objfile *objfile; - ALL_COMPUNITS (objfile, cust) + for (struct objfile *objfile : all_objfiles (current_program_space)) + for (struct compunit_symtab *cust : objfile_compunits (objfile)) { bv = COMPUNIT_BLOCKVECTOR (cust); for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++) @@ -4530,7 +4528,6 @@ search_symbols (const char *regexp, enum search_domain kind, } } } - } if (!result.empty ()) sort_search_symbols_remove_dups (&result); @@ -5274,10 +5271,10 @@ default_collect_symbol_completion_matches_break_on } /* Add completions for all currently loaded symbol tables. */ - struct objfile *objfile; - ALL_COMPUNITS (objfile, cust) - add_symtab_completions (cust, tracker, mode, lookup_name, - sym_text, word, code); + for (struct objfile *objfile : all_objfiles (current_program_space)) + for (struct compunit_symtab *cust : objfile_compunits (objfile)) + add_symtab_completions (cust, tracker, mode, lookup_name, + sym_text, word, code); /* Look through the partial symtabs for all symbols which begin by matching SYM_TEXT. Expand all CUs that you find to the list. */ -- 2.17.2