From patchwork Thu Jan 17 02:50:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31086 Received: (qmail 98813 invoked by alias); 17 Jan 2019 02:50:45 -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 98511 invoked by uid 89); 17 Jan 2019 02:50:42 -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=cust, FULL, adapter, obstack X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.47.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Jan 2019 02:50:36 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 577E253 for ; Wed, 16 Jan 2019 20:50:35 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id jxlLgV5YqdnCejxlLgZT1N; 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=mM7ro/xFA46hCqNa+mB7oODiQ4+FV5Xra7gaU48aHDA=; b=pPQooFlWuKp9Flod4qjq5ugyEo BwZPgNOZYInvRMebAMebGOfmdsXt5z6H0BuQJPPNb/aKVW9W+CblS8XI9WCJkPIelTd+mntIpt/o0 9JcmaBXANVu/k1xZ2XGCgOWF9; 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 1gjxlL-0045Wd-3R; Wed, 16 Jan 2019 20:50:35 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/6] Add compunits range adapter to objfile Date: Wed, 16 Jan 2019 19:50:29 -0700 Message-Id: <20190117025032.9265-4-tom@tromey.com> In-Reply-To: <20190117025032.9265-1-tom@tromey.com> References: <20190117025032.9265-1-tom@tromey.com> This removes the objfile_compunits range adapter in favor of using a method on objfile. gdb/ChangeLog 2019-01-15 Tom Tromey * symtab.c (lookup_objfile_from_block) (lookup_symbol_in_objfile_symtabs) (basic_lookup_transparent_type_1, find_pc_sect_compunit_symtab) (find_line_symtab, info_sources_command) (default_collect_symbol_completion_matches_break_on) (make_source_files_completion_list): Update. * symmisc.c (print_objfile_statistics, dump_objfile) (maintenance_print_symbols, maintenance_info_symtabs) (maintenance_check_symtabs, maintenance_info_line_tables): Update. * source.c (select_source_symtab) (forget_cached_source_info_for_objfile): Update. * objfiles.h (class objfile_compunits): Remove. (struct objfile) : New typedef. (compunits): New method. * objfiles.c (objfile_relocate1): Update. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update. * maint.c (count_symtabs_and_blocks): Update. * linespec.c (iterate_over_all_matching_symtabs): Update. * cp-support.c (add_symbol_overload_list_qualified): Update. * coffread.c (coff_symtab_read): Update. * ada-lang.c (add_nonlocal_symbols) (ada_collect_symbol_completion_matches) (ada_add_global_exceptions): Update. --- gdb/ChangeLog | 27 +++++++++++++++++++++++++++ gdb/ada-lang.c | 8 ++++---- gdb/coffread.c | 2 +- gdb/cp-support.c | 4 ++-- gdb/linespec.c | 2 +- gdb/maint.c | 2 +- gdb/mi/mi-cmd-file.c | 2 +- gdb/objfiles.c | 4 ++-- gdb/objfiles.h | 22 +++++++++------------- gdb/source.c | 4 ++-- gdb/symmisc.c | 16 ++++++++-------- gdb/symtab.c | 18 +++++++++--------- 12 files changed, 67 insertions(+), 44 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 54ac0fc668..978bfcf352 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5629,7 +5629,7 @@ add_nonlocal_symbols (struct obstack *obstackp, symbol_name_match_type::FULL, compare_names); - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { const struct block *global_block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cu), GLOBAL_BLOCK); @@ -6467,7 +6467,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker, for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *s : objfile_compunits (objfile)) + for (compunit_symtab *s : objfile->compunits ()) { QUIT; b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK); @@ -6486,7 +6486,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker, for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *s : objfile_compunits (objfile)) + for (compunit_symtab *s : objfile->compunits ()) { QUIT; b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK); @@ -13568,7 +13568,7 @@ ada_add_global_exceptions (compiled_regex *preg, for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *s : objfile_compunits (objfile)) + for (compunit_symtab *s : objfile->compunits ()) { const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (s); int i; diff --git a/gdb/coffread.c b/gdb/coffread.c index 4f05295712..2b75d8189f 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1203,7 +1203,7 @@ coff_symtab_read (minimal_symbol_reader &reader, /* Patch up any opaque types (references to types that are not defined in the file where they are referenced, e.g. "struct foo *bar"). */ { - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { for (symtab *s : compunit_filetabs (cu)) patch_opaque_types (s); diff --git a/gdb/cp-support.c b/gdb/cp-support.c index d147486e00..2ea5206193 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1397,7 +1397,7 @@ add_symbol_overload_list_qualified (const char *func_name, for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) { QUIT; b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK); @@ -1407,7 +1407,7 @@ add_symbol_overload_list_qualified (const char *func_name, for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) { QUIT; b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK); diff --git a/gdb/linespec.c b/gdb/linespec.c index 1cd3e251e0..769d76d3b2 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1150,7 +1150,7 @@ iterate_over_all_matching_symtabs NULL, NULL, search_domain); - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { struct symtab *symtab = COMPUNIT_FILETABS (cu); diff --git a/gdb/maint.c b/gdb/maint.c index 0037f5e0f4..b50757039e 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -773,7 +773,7 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr, { for (objfile *o : current_program_space->all_objfiles ()) { - for (compunit_symtab *cu : objfile_compunits (o)) + for (compunit_symtab *cu : o->compunits ()) { ++nr_compunit_symtabs; nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu)); diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c index a3c10955da..f24f9cf6c5 100644 --- a/gdb/mi/mi-cmd-file.c +++ b/gdb/mi/mi-cmd-file.c @@ -94,7 +94,7 @@ mi_cmd_file_list_exec_source_files (const char *command, char **argv, int argc) /* Look at all of the file symtabs. */ for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { for (symtab *s : compunit_filetabs (cu)) { diff --git a/gdb/objfiles.c b/gdb/objfiles.c index e9432ca145..e592dfb7bd 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -787,7 +787,7 @@ objfile_relocate1 (struct objfile *objfile, /* OK, get all the symtabs. */ { - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) { for (symtab *s : compunit_filetabs (cust)) { @@ -805,7 +805,7 @@ objfile_relocate1 (struct objfile *objfile, } } - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) { const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust); int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust); diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 244c1280be..86c88fc512 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -301,6 +301,15 @@ struct objfile partial_symtabs.reset (new psymtab_storage ()); } + typedef next_adapter compunits_range; + + /* A range adapter that makes it possible to iterate over all + compunits in one objfile. */ + + compunits_range compunits () + { + return compunits_range (compunit_symtabs); + } /* All struct objfile's are chained together by their next pointers. The program space field "objfiles" (frequently referenced via @@ -553,19 +562,6 @@ extern void default_iterate_over_objfiles_in_search_order void *cb_data, struct objfile *current_objfile); -/* A range adapter that makes it possible to iterate over all - compunits in one objfile. */ - -class objfile_compunits : public next_adapter -{ -public: - - explicit objfile_compunits (struct objfile *objfile) - : next_adapter (objfile->compunit_symtabs) - { - } -}; - /* A range adapter that makes it possible to iterate over all minimal symbols of an objfile. */ diff --git a/gdb/source.c b/gdb/source.c index 120bceb44b..202843d41c 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -271,7 +271,7 @@ select_source_symtab (struct symtab *s) for (objfile *ofp : current_program_space->all_objfiles ()) { - for (compunit_symtab *cu : objfile_compunits (ofp)) + for (compunit_symtab *cu : ofp->compunits ()) { for (symtab *symtab : compunit_filetabs (cu)) { @@ -353,7 +353,7 @@ show_directories_command (struct ui_file *file, int from_tty, void forget_cached_source_info_for_objfile (struct objfile *objfile) { - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { for (symtab *s : compunit_filetabs (cu)) { diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 772dd3adb4..11a3b7f4f0 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -108,7 +108,7 @@ print_objfile_statistics (void) if (objfile->sf) objfile->sf->qf->print_stats (objfile); i = linetables = 0; - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { for (symtab *s : compunit_filetabs (cu)) { @@ -117,8 +117,8 @@ print_objfile_statistics (void) linetables++; } } - blockvectors = std::distance (objfile_compunits (objfile).begin (), - objfile_compunits (objfile).end ()); + blockvectors = std::distance (objfile->compunits ().begin (), + objfile->compunits ().end ()); printf_filtered (_(" Number of symbol tables: %d\n"), i); printf_filtered (_(" Number of symbol tables with line tables: %d\n"), linetables); @@ -162,7 +162,7 @@ dump_objfile (struct objfile *objfile) if (objfile->compunit_symtabs != NULL) { printf_filtered ("Symtabs:\n"); - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { for (symtab *symtab : compunit_filetabs (cu)) { @@ -486,7 +486,7 @@ maintenance_print_symbols (const char *args, int from_tty) if (!print_for_objfile) continue; - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { for (symtab *s : compunit_filetabs (cu)) { @@ -784,7 +784,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty) actually find a symtab whose name matches. */ int printed_objfile_start = 0; - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) { int printed_compunit_symtab_start = 0; @@ -869,7 +869,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty) actually find something worth printing. */ int printed_objfile_start = 0; - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) { int found_something = 0; struct symtab *symtab = compunit_primary_filetab (cust); @@ -1032,7 +1032,7 @@ maintenance_info_line_tables (const char *regexp, int from_tty) ALL_PSPACES (pspace) for (objfile *objfile : pspace->all_objfiles ()) { - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) { for (symtab *symtab : compunit_filetabs (cust)) { diff --git a/gdb/symtab.c b/gdb/symtab.c index 713b845c3a..867fb6c927 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2171,7 +2171,7 @@ lookup_objfile_from_block (const struct block *block) /* Look through all blockvectors. */ for (objfile *obj : current_program_space->all_objfiles ()) { - for (compunit_symtab *cust : objfile_compunits (obj)) + for (compunit_symtab *cust : obj->compunits ()) if (block == BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK)) { @@ -2265,7 +2265,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index, name, domain_name (domain)); } - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) { const struct blockvector *bv; const struct block *block; @@ -2763,7 +2763,7 @@ basic_lookup_transparent_type_1 (struct objfile *objfile, int block_index, const struct block *block; const struct symbol *sym; - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) { bv = COMPUNIT_BLOCKVECTOR (cust); block = BLOCKVECTOR_BLOCK (bv, block_index); @@ -2904,7 +2904,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) for (objfile *obj_file : current_program_space->all_objfiles ()) { - for (compunit_symtab *cust : objfile_compunits (obj_file)) + for (compunit_symtab *cust : obj_file->compunits ()) { struct block *b; const struct blockvector *bv; @@ -3360,7 +3360,7 @@ find_line_symtab (struct symtab *sym_tab, int line, for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { for (symtab *s : compunit_filetabs (cu)) { @@ -4200,7 +4200,7 @@ info_sources_command (const char *ignore, int from_tty) data.first = 1; for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { for (symtab *s : compunit_filetabs (cu)) { @@ -4492,7 +4492,7 @@ search_symbols (const char *regexp, enum search_domain kind, for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) { bv = COMPUNIT_BLOCKVECTOR (cust); for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++) @@ -5293,7 +5293,7 @@ default_collect_symbol_completion_matches_break_on /* Add completions for all currently loaded symbol tables. */ for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *cust : objfile_compunits (objfile)) + for (compunit_symtab *cust : objfile->compunits ()) add_symtab_completions (cust, tracker, mode, lookup_name, sym_text, word, code); } @@ -5602,7 +5602,7 @@ make_source_files_completion_list (const char *text, const char *word) for (objfile *objfile : current_program_space->all_objfiles ()) { - for (compunit_symtab *cu : objfile_compunits (objfile)) + for (compunit_symtab *cu : objfile->compunits ()) { for (symtab *s : compunit_filetabs (cu)) {