From patchwork Wed Jul 31 20:14:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33875 Received: (qmail 96048 invoked by alias); 31 Jul 2019 20:14:18 -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 96000 invoked by uid 89); 31 Jul 2019 20:14:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=tromeyadacorecom, tromey@adacore.com, sk:tromey, sk:tromey@ X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Jul 2019 20:14:16 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 37E57116EA7; Wed, 31 Jul 2019 16:14:15 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id HiTOzQTHxyOl; Wed, 31 Jul 2019 16:14:15 -0400 (EDT) Received: from murgatroyd.Home (97-122-178-82.hlrn.qwest.net [97.122.178.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id D7189116BDB; Wed, 31 Jul 2019 16:14:14 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/8] Change iterate_over_symbols to return bool Date: Wed, 31 Jul 2019 14:14:05 -0600 Message-Id: <20190731201411.8044-3-tromey@adacore.com> In-Reply-To: <20190731201411.8044-1-tromey@adacore.com> References: <20190731201411.8044-1-tromey@adacore.com> MIME-Version: 1.0 This changes iterate_over_symbols to return a bool. This allows it to be reused in another context in a subsequent patch. gdb/ChangeLog 2019-07-31 Tom Tromey * ada-lang.c (ada_iterate_over_symbols): Return bool. * language.h (struct language_defn) : Return bool. * symtab.c (iterate_over_symbols): Return bool. * symtab.h (iterate_over_symbols): Return bool. --- gdb/ChangeLog | 8 ++++++++ gdb/ada-lang.c | 6 ++++-- gdb/language.h | 2 +- gdb/symtab.c | 13 ++++--------- gdb/symtab.h | 11 ++++++++++- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index d1784431946..8294101c06e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5741,7 +5741,7 @@ ada_lookup_symbol_list (const char *name, const struct block *block, /* Implementation of the la_iterate_over_symbols method. */ -static void +static bool ada_iterate_over_symbols (const struct block *block, const lookup_name_info &name, domain_enum domain, @@ -5755,8 +5755,10 @@ ada_iterate_over_symbols for (i = 0; i < ndefs; ++i) { if (!callback (&results[i])) - break; + return false; } + + return true; } /* The result is as for ada_lookup_symbol_list with FULL_SEARCH set diff --git a/gdb/language.h b/gdb/language.h index 2a100b04917..0088e5de2dd 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -407,7 +407,7 @@ struct language_defn This field may not be NULL. If the language does not need any special processing here, 'iterate_over_symbols' should be used as the definition. */ - void (*la_iterate_over_symbols) + bool (*la_iterate_over_symbols) (const struct block *block, const lookup_name_info &name, domain_enum domain, gdb::function_view callback); diff --git a/gdb/symtab.c b/gdb/symtab.c index 87a0c8e4da6..ba348f01bbf 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2832,15 +2832,9 @@ basic_lookup_transparent_type (const char *name) return (struct type *) 0; } -/* Iterate over the symbols named NAME, matching DOMAIN, in BLOCK. - - For each symbol that matches, CALLBACK is called. The symbol is - passed to the callback. - - If CALLBACK returns false, the iteration ends. Otherwise, the - search continues. */ +/* See symtab.h. */ -void +bool iterate_over_symbols (const struct block *block, const lookup_name_info &name, const domain_enum domain, @@ -2857,9 +2851,10 @@ iterate_over_symbols (const struct block *block, struct block_symbol block_sym = {sym, block}; if (!callback (&block_sym)) - return; + return false; } } + return true; } /* Find the compunit symtab associated with PC and SECTION. diff --git a/gdb/symtab.h b/gdb/symtab.h index 9880ecc4c53..e62dd2b0ab3 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2101,7 +2101,16 @@ std::vector find_pcs_for_symtab_line typedef bool (symbol_found_callback_ftype) (struct block_symbol *bsym); -void iterate_over_symbols (const struct block *block, +/* Iterate over the symbols named NAME, matching DOMAIN, in BLOCK. + + For each symbol that matches, CALLBACK is called. The symbol is + passed to the callback. + + If CALLBACK returns false, the iteration ends and this function + returns false. Otherwise, the search continues, and the function + eventually returns true. */ + +bool iterate_over_symbols (const struct block *block, const lookup_name_info &name, const domain_enum domain, gdb::function_view callback);