From patchwork Fri Nov 7 08:57:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 3605 Received: (qmail 2610 invoked by alias); 7 Nov 2014 08:58:10 -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 2591 invoked by uid 89); 7 Nov 2014 08:58:10 -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-pa0-f54.google.com Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 07 Nov 2014 08:58:08 +0000 Received: by mail-pa0-f54.google.com with SMTP id rd3so3145973pab.27 for ; Fri, 07 Nov 2014 00:58:06 -0800 (PST) X-Received: by 10.70.129.135 with SMTP id nw7mr10304461pdb.129.1415350686878; Fri, 07 Nov 2014 00:58:06 -0800 (PST) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by mx.google.com with ESMTPSA id ra4sm8125653pab.33.2014.11.07.00.58.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Nov 2014 00:58:06 -0800 (PST) From: Doug Evans To: "gdb-patches\@sourceware.org" Subject: Re: [PATCH 2/9] Add macro ALL_BLOCK_SYMBOLS_WITH_NAME. References: Date: Fri, 07 Nov 2014 00:57:15 -0800 In-Reply-To: (Doug Evans's message of "Mon, 27 Oct 2014 16:19:11 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Doug Evans writes: > On Sun, Oct 26, 2014 at 9:26 PM, Doug Evans wrote: >> 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. > > Heh. block_lookup_symbol in 1/9 of this series could use this macro. > https://sourceware.org/ml/gdb-patches/2014-10/msg00720.html > I'll add that to this patch. Here's what I committed. 2014-11-06 Doug Evans * block.h (ALL_BLOCK_SYMBOLS_WITH_NAME): New macro. * block.c (block_lookup_symbol): Use it. * cp-support.c (make_symbol_overload_list_block): Use it. * symtab.c (iterate_over_symbols): Use it. diff --git a/gdb/block.c b/gdb/block.c index 3bb9de0..1cb9875 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -706,9 +706,7 @@ block_lookup_symbol (const struct block *block, const char *name, if (!BLOCK_FUNCTION (block)) { - 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)) @@ -726,9 +724,7 @@ block_lookup_symbol (const struct block *block, const char *name, struct symbol *sym_found = NULL; - 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)) 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 d35920c..72ffb52 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 482a23d..9add71f 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2031,9 +2031,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))