From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id ACC473858434 for ; Fri, 20 Jan 2023 21:46:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ACC473858434 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 2CF0D1004A84D for ; Fri, 20 Jan 2023 21:46:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDepfnSZNX2aIzDepTG37; Fri, 20 Jan 2023 21:46:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63cb0bc2 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=u7aU1g9GHqODsqPTMMkA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=FTJUBs8eZTcRK4TtbA6IZAmORZ0/bA0sYYbprUnWYlk=; b=oCTP8Ve9aYqkR8UveM1gmb69IF rmHEVnnVajySAtO3s6zztUTu77XnpxEKwNkeg4nNEDqdj463zCi9qCNziFpRNnb7SjlPcyNeiHw4R h4619PNisKGgTzJjAWNiFGBfb; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60144 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDd-001GNx-SD; Fri, 20 Jan 2023 14:46:41 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 21/27] Remove ALL_BLOCK_SYMBOLS Date: Fri, 20 Jan 2023 14:46:12 -0700 Message-Id: <20230120214618.3236224-22-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 97.122.76.186 X-Source-L: No X-Exim-ID: 1pIzDd-001GNx-SD X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60144 X-Source-Auth: tom+tromey.com X-Email-Count: 22 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This removes ALL_BLOCK_SYMBOLS in favor of foreach. --- gdb/ada-lang.c | 21 ++++++--------------- gdb/block.h | 9 --------- gdb/buildsym.c | 2 +- gdb/coffread.c | 5 +---- gdb/f-valprint.c | 4 +--- gdb/infrun.c | 4 +--- gdb/linespec.c | 4 +--- gdb/mdebugread.c | 9 ++------- gdb/mi/mi-cmd-stack.c | 4 +--- gdb/stack.c | 19 ++++++------------- gdb/symtab.c | 34 ++++++++++++++-------------------- gdb/tracepoint.c | 4 +--- 12 files changed, 35 insertions(+), 84 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b5e9f2ecff6..137925db81b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6121,10 +6121,8 @@ ada_add_block_symbols (std::vector &result, const std::string &ada_lookup_name = lookup_name.ada ().lookup_name (); const char *name = ada_lookup_name.c_str (); size_t name_len = ada_lookup_name.size (); - struct symbol *sym; - struct block_iterator iter; - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { if (symbol_matches_domain (sym->language (), sym->domain (), domain)) @@ -13069,10 +13067,7 @@ ada_add_exceptions_from_frame (compiled_regex *preg, while (block != 0) { - struct block_iterator iter; - struct symbol *sym; - - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { switch (sym->aclass ()) { @@ -13154,10 +13149,8 @@ ada_add_global_exceptions (compiled_regex *preg, for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++) { const struct block *b = bv->block (i); - struct block_iterator iter; - struct symbol *sym; - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) if (ada_is_non_standard_exception_sym (sym) && name_matches_regex (sym->natural_name (), preg)) { @@ -13659,9 +13652,7 @@ class ada_language : public language_defn const char *text, const char *word, enum type_code code) const override { - struct symbol *sym; const struct block *b, *surrounding_static_block = 0; - struct block_iterator iter; gdb_assert (code == TYPE_CODE_UNDEF); @@ -13721,7 +13712,7 @@ class ada_language : public language_defn if (!b->superblock ()) surrounding_static_block = b; /* For elmin of dups */ - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (completion_skip_symbol (mode, sym)) continue; @@ -13742,7 +13733,7 @@ class ada_language : public language_defn { QUIT; b = s->blockvector ()->global_block (); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (completion_skip_symbol (mode, sym)) continue; @@ -13764,7 +13755,7 @@ class ada_language : public language_defn /* Don't do this block twice. */ if (b == surrounding_static_block) continue; - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (completion_skip_symbol (mode, sym)) continue; diff --git a/gdb/block.h b/gdb/block.h index 35c41377f2c..6ccf3766d8f 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -595,15 +595,6 @@ extern int block_find_non_opaque_type (struct symbol *sym, void *data); extern int block_find_non_opaque_type_preferred (struct symbol *sym, void *data); -/* Macro to loop through all symbols in BLOCK, in no particular - order. ITER helps keep track of the iteration, and must be a - struct block_iterator. SYM points to the current symbol. */ - -#define ALL_BLOCK_SYMBOLS(block, iter, sym) \ - for ((sym) = block_iterator_first ((block), &(iter)); \ - (sym); \ - (sym) = block_iterator_next (&(iter))) - /* Given a vector of pairs, allocate and build an obstack allocated blockranges struct for a block. */ struct blockranges *make_blockranges (struct objfile *objfile, diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 7a009c2f626..9d45938f8e9 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -998,7 +998,7 @@ buildsym_compunit::end_compunit_symtab_with_blockvector /* Note that we only want to fix up symbols from the local blocks, not blocks coming from included symtabs. That is why - we use ALL_DICT_SYMBOLS here and not ALL_BLOCK_SYMBOLS. */ + we use ALL_DICT_SYMBOLS here and not a block iterator. */ ALL_DICT_SYMBOLS (block->multidict (), miter, sym) if (sym->symtab () == NULL) sym->set_symtab (symtab); diff --git a/gdb/coffread.c b/gdb/coffread.c index 4950a7324c8..69c9772f429 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1495,12 +1495,9 @@ patch_type (struct type *type, struct type *real_type) static void patch_opaque_types (struct symtab *s) { - struct block_iterator iter; - struct symbol *real_sym; - /* Go through the per-file symbols only. */ const struct block *b = s->compunit ()->blockvector ()->static_block (); - ALL_BLOCK_SYMBOLS (b, iter, real_sym) + for (struct symbol *real_sym : block_iterator_range (b)) { /* Find completed typedefs to use to fix opaque ones. Remove syms from the chain when their types are stored, diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 55dbcc8309f..fe0ee288a8e 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -600,13 +600,11 @@ static void info_common_command_for_block (const struct block *block, const char *comname, int *any_printed) { - struct block_iterator iter; - struct symbol *sym; struct value_print_options opts; get_user_print_options (&opts); - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) if (sym->domain () == COMMON_BLOCK_DOMAIN) { const struct common_block *common = sym->value_common_block (); diff --git a/gdb/infrun.c b/gdb/infrun.c index edfb5ab0a91..42fc95fb0ed 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8069,8 +8069,6 @@ check_exception_resume (struct execution_control_state *ecs, try { const struct block *b; - struct block_iterator iter; - struct symbol *sym; int argno = 0; /* The exception breakpoint is a thread-specific breakpoint on @@ -8088,7 +8086,7 @@ check_exception_resume (struct execution_control_state *ecs, handler. */ b = func->value_block (); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (!sym->is_argument ()) continue; diff --git a/gdb/linespec.c b/gdb/linespec.c index 61da545eb2e..bf1e5ee9727 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3900,14 +3900,12 @@ find_label_symbols_in_block (const struct block *block, { if (completion_mode) { - struct block_iterator iter; - struct symbol *sym; size_t name_len = strlen (name); int (*cmp) (const char *, const char *, size_t); cmp = case_sensitivity == case_sensitive_on ? strncmp : strncasecmp; - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { if (symbol_matches_domain (sym->language (), sym->domain (), LABEL_DOMAIN) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 8dc836a0f6e..7fa25ae3183 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1183,19 +1183,16 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, type. Set that from the type of the parameter symbols. */ int nparams = top_stack->numargs; int iparams; - struct symbol *sym; if (nparams > 0) { - struct block_iterator iter; - ftype->set_num_fields (nparams); ftype->set_fields ((struct field *) TYPE_ALLOC (ftype, nparams * sizeof (struct field))); iparams = 0; - ALL_BLOCK_SYMBOLS (cblock, iter, sym) + for (struct symbol *sym : block_iterator_range (cblock)) { if (iparams == nparams) break; @@ -4455,12 +4452,10 @@ static struct symbol * mylookup_symbol (const char *name, const struct block *block, domain_enum domain, enum address_class theclass) { - struct block_iterator iter; int inc; - struct symbol *sym; inc = name[0]; - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { if (sym->linkage_name ()[0] == inc && sym->domain () == domain diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 21bcf73ed24..30322b6fc56 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -571,8 +571,6 @@ list_args_or_locals (const frame_print_options &fp_opts, frame_info_ptr fi, int skip_unavailable) { const struct block *block; - struct symbol *sym; - struct block_iterator iter; struct type *type; const char *name_of_result; struct ui_out *uiout = current_uiout; @@ -598,7 +596,7 @@ list_args_or_locals (const frame_print_options &fp_opts, while (block != 0) { - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { int print_me = 0; diff --git a/gdb/stack.c b/gdb/stack.c index 0fd797836dc..0ffb1b512e1 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -758,10 +758,8 @@ print_frame_args (const frame_print_options &fp_opts, if (func) { const struct block *b = func->value_block (); - struct block_iterator iter; - struct symbol *sym; - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { struct frame_arg arg, entryarg; @@ -2237,10 +2235,7 @@ static void iterate_over_block_locals (const struct block *b, iterate_over_block_arg_local_vars_cb cb) { - struct block_iterator iter; - struct symbol *sym; - - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { switch (sym->aclass ()) { @@ -2486,10 +2481,7 @@ void iterate_over_block_arg_vars (const struct block *b, iterate_over_block_arg_local_vars_cb cb) { - struct block_iterator iter; - struct symbol *sym, *sym2; - - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { /* Don't worry about things which aren't arguments. */ if (sym->is_argument ()) @@ -2505,8 +2497,9 @@ iterate_over_block_arg_vars (const struct block *b, float). There are also LOC_ARG/LOC_REGISTER pairs which are not combined in symbol-reading. */ - sym2 = lookup_symbol_search_name (sym->search_name (), - b, VAR_DOMAIN).symbol; + struct symbol *sym2 + = lookup_symbol_search_name (sym->search_name (), + b, VAR_DOMAIN).symbol; cb (sym->print_name (), sym2); } } diff --git a/gdb/symtab.c b/gdb/symtab.c index 511299233ad..3ab26f3a003 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2906,23 +2906,25 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) if (section != 0) { - struct symbol *sym = NULL; - struct block_iterator iter; + struct symbol *found_sym = nullptr; for (int b_index = GLOBAL_BLOCK; - b_index <= STATIC_BLOCK && sym == NULL; + b_index <= STATIC_BLOCK && found_sym == nullptr; ++b_index) { const struct block *b = bv->block (b_index); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { fixup_symbol_section (sym, obj_file); if (matching_obj_sections (sym->obj_section (obj_file), section)) - break; + { + found_sym = sym; + break; + } } } - if (sym == NULL) + if (found_sym == nullptr) continue; /* No symbol in this symtab matches section. */ } @@ -2973,10 +2975,8 @@ find_symbol_at_address (CORE_ADDR address) for (int i = GLOBAL_BLOCK; i <= STATIC_BLOCK; ++i) { const struct block *b = bv->block (i); - struct block_iterator iter; - struct symbol *sym; - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (sym->aclass () == LOC_STATIC && sym->value_address () == addr) @@ -4739,11 +4739,9 @@ global_symbol_searcher::add_matching_symbols for (block_enum block : { GLOBAL_BLOCK, STATIC_BLOCK }) { - struct block_iterator iter; - struct symbol *sym; const struct block *b = bv->block (block); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { struct symtab *real_symtab = sym->symtab (); @@ -5703,8 +5701,6 @@ add_symtab_completions (struct compunit_symtab *cust, const char *text, const char *word, enum type_code code) { - struct symbol *sym; - struct block_iterator iter; int i; if (cust == NULL) @@ -5715,7 +5711,7 @@ add_symtab_completions (struct compunit_symtab *cust, QUIT; const struct block *b = cust->blockvector ()->block (i); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (completion_skip_symbol (mode, sym)) continue; @@ -5741,10 +5737,8 @@ default_collect_symbol_completion_matches_break_on frees them. I'm not going to worry about this; hopefully there won't be that many. */ - struct symbol *sym; const struct block *b; const struct block *surrounding_static_block, *surrounding_global_block; - struct block_iterator iter; /* The symbol we are completing on. Points in same buffer as text. */ const char *sym_text; @@ -5865,7 +5859,7 @@ default_collect_symbol_completion_matches_break_on { QUIT; - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (code == TYPE_CODE_UNDEF) { @@ -5893,12 +5887,12 @@ default_collect_symbol_completion_matches_break_on if (code == TYPE_CODE_UNDEF) { if (surrounding_static_block != NULL) - ALL_BLOCK_SYMBOLS (surrounding_static_block, iter, sym) + for (struct symbol *sym : block_iterator_range (surrounding_static_block)) completion_list_add_fields (tracker, sym, lookup_name, sym_text, word); if (surrounding_global_block != NULL) - ALL_BLOCK_SYMBOLS (surrounding_global_block, iter, sym) + for (struct symbol *sym : block_iterator_range (surrounding_global_block)) completion_list_add_fields (tracker, sym, lookup_name, sym_text, word); } diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 7e172dfb3fc..ad16b1e9d42 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2459,12 +2459,10 @@ tfind_outside_command (const char *args, int from_tty) static void info_scope_command (const char *args_in, int from_tty) { - struct symbol *sym; struct bound_minimal_symbol msym; const struct block *block; const char *symname; const char *save_args = args_in; - struct block_iterator iter; int j, count = 0; struct gdbarch *gdbarch; int regno; @@ -2492,7 +2490,7 @@ info_scope_command (const char *args_in, int from_tty) while (block != 0) { QUIT; /* Allow user to bail out with ^C. */ - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { QUIT; /* Allow user to bail out with ^C. */ if (count == 0) -- 2.39.0