From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 2/8] Change iterate_over_symbols to return bool
Date: Wed, 31 Jul 2019 20:14:00 -0000 [thread overview]
Message-ID: <20190731201411.8044-3-tromey@adacore.com> (raw)
In-Reply-To: <20190731201411.8044-1-tromey@adacore.com>
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 <tromey@adacore.com>
* ada-lang.c (ada_iterate_over_symbols): Return bool.
* language.h (struct language_defn) <la_iterate_over_symbols>:
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<symbol_found_callback_ftype> 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<CORE_ADDR> 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<symbol_found_callback_ftype> callback);
--
2.20.1
next prev parent reply other threads:[~2019-07-31 20:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 20:14 [PATCH 0/8] Add Ada support for .debug_names Tom Tromey
2019-07-31 20:14 ` [PATCH 3/8] Simplify psym_map_matching_symbols Tom Tromey
2019-07-31 20:14 ` [PATCH 8/8] Update "save gdb-index" documentation Tom Tromey
2019-08-01 2:36 ` Eli Zaretskii
2019-07-31 20:14 ` [PATCH 6/8] Add Ada support for .debug_names Tom Tromey
2019-07-31 20:14 ` Tom Tromey [this message]
2019-07-31 20:14 ` [PATCH 7/8] Add Ada support to cc-with-tweaks.exp Tom Tromey
2019-07-31 20:14 ` [PATCH 1/8] Change map_matching_symbols to take a symbol_found_callback_ftype Tom Tromey
2019-07-31 20:22 ` [PATCH 5/8] Fix latent bug in .debug_names file-name handling Tom Tromey
2019-07-31 20:22 ` [PATCH 4/8] Change map_matching_symbols to take a lookup_name_info Tom Tromey
2019-09-10 14:22 ` [PATCH 0/8] Add Ada support for .debug_names Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190731201411.8044-3-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox