From patchwork Mon Oct 27 04:26:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 3393 Received: (qmail 26740 invoked by alias); 27 Oct 2014 04:27:32 -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 26730 invoked by uid 89); 27 Oct 2014 04:27:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pd0-f175.google.com Received: from mail-pd0-f175.google.com (HELO mail-pd0-f175.google.com) (209.85.192.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 27 Oct 2014 04:27:30 +0000 Received: by mail-pd0-f175.google.com with SMTP id y13so4875071pdi.34 for ; Sun, 26 Oct 2014 21:27:28 -0700 (PDT) X-Received: by 10.68.202.1 with SMTP id ke1mr2492674pbc.60.1414384048521; Sun, 26 Oct 2014 21:27:28 -0700 (PDT) Received: from seba.sebabeach.org.gmail.com (173-13-178-50-sfba.hfc.comcastbusiness.net. [173.13.178.50]) by mx.google.com with ESMTPSA id yt3sm9533954pbc.34.2014.10.26.21.27.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Oct 2014 21:27:27 -0700 (PDT) From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH 2/9] Add macro ALL_BLOCK_SYMBOLS_WITH_NAME. Date: Sun, 26 Oct 2014 21:26:40 -0700 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. This patch adds macro ALL_BLOCK_SYMBOLS_WITH_NAME to go with the ALL_BLOCK_SYMBOLS macro already in block.h. 2014-10-26 Doug Evans * block.h (ALL_BLOCK_SYMBOLS_WITH_NAME): New macro. * cp-support.c (make_symbol_overload_list_block): Use it. * symtab.c (iterate_over_symbols): Use it. diff --git a/gdb/block.h b/gdb/block.h index e8d3452..50a7919 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -286,4 +286,13 @@ extern struct symbol *block_lookup_symbol (const struct block *block, (sym); \ (sym) = block_iterator_next (&(iter))) +/* Macro to loop through all symbols with name NAME 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_WITH_NAME(block, name, iter, sym) \ + for ((sym) = block_iter_name_first ((block), (name), &(iter)); \ + (sym) != NULL; \ + (sym) = block_iter_name_next ((name), &(iter))) + #endif /* BLOCK_H */ diff --git a/gdb/cp-support.c b/gdb/cp-support.c index b475491..4abbb2e 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1218,9 +1218,7 @@ make_symbol_overload_list_block (const char *name, struct block_iterator iter; struct symbol *sym; - for (sym = block_iter_name_first (block, name, &iter); - sym != NULL; - sym = block_iter_name_next (name, &iter)) + ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym) overload_list_add_symbol (sym, name); } diff --git a/gdb/symtab.c b/gdb/symtab.c index c27ea51..19753bc 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2029,9 +2029,7 @@ iterate_over_symbols (const struct block *block, const char *name, struct block_iterator iter; struct symbol *sym; - for (sym = block_iter_name_first (block, name, &iter); - sym != NULL; - sym = block_iter_name_next (name, &iter)) + ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym) { if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), SYMBOL_DOMAIN (sym), domain))