aboutsummaryrefslogtreecommitdiff
path: root/gdb/addrmap.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-06-25 08:40:37 -0600
committerTom Tromey <tom@tromey.com>2021-06-25 08:40:37 -0600
commit50a6759f0f541ea965c7330bfbfe335cb8d66af8 (patch)
tree5f7add1207929170a7fcc2effc07c3e25335065d /gdb/addrmap.h
parent67470e9d8be180344494635dcef34e054938bfb8 (diff)
downloadgdb-50a6759f0f541ea965c7330bfbfe335cb8d66af8.zip
gdb-50a6759f0f541ea965c7330bfbfe335cb8d66af8.tar.gz
gdb-50a6759f0f541ea965c7330bfbfe335cb8d66af8.tar.bz2
Use gdb::function_view in addrmap_foreach
While working on the DWARF psymtab replacement, I needed addrmap_foreach to accept a gdb::function_view. This seemed like a worthwhile change on its own, so I've written it separately for submission. Regression tested on x86-64 Fedora 32. gdb/ChangeLog 2021-06-25 Tom Tromey <tom@tromey.com> * dwarf2/index-write.c (struct addrmap_index_data): Add initializers. <operator()>: Declare. (addrmap_index_data::operator()): Rename from add_address_entry_worker. Remove 'datap' parameter. (write_address_map): Update. * psymtab.c (struct dump_psymtab_addrmap_data): Remove (dump_psymtab_addrmap_1): Remove 'data' parameter, add other parameters. (dump_psymtab_addrmap): Update. * addrmap.c (struct addrmap_funcs) <foreach>: Remove 'data' parameter. (addrmap_foreach, addrmap_fixed_foreach): Likewise. (struct mutable_foreach_data): Remove. (addrmap_mutable_foreach_worker): Update. (addrmap_mutable_foreach): Remove 'data' parameter. * addrmap.h (addrmap_foreach_fn): Use gdb::function_view. (addrmap_foreach): Remove 'data' parameter.
Diffstat (limited to 'gdb/addrmap.h')
-rw-r--r--gdb/addrmap.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index bcefc00..4b1a596 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -20,6 +20,8 @@
#ifndef ADDRMAP_H
#define ADDRMAP_H
+#include "gdbsupport/function-view.h"
+
/* An address map is essentially a table mapping CORE_ADDRs onto GDB
data structures, like blocks, symtabs, partial symtabs, and so on.
An address map uses memory proportional to the number of
@@ -93,13 +95,13 @@ void addrmap_relocate (struct addrmap *map, CORE_ADDR offset);
/* The type of a function used to iterate over the map.
OBJ is NULL for unmapped regions. */
-typedef int (*addrmap_foreach_fn) (void *data, CORE_ADDR start_addr,
- void *obj);
-
-/* Call FN, passing it DATA, for every address in MAP, following an
- in-order traversal. If FN ever returns a non-zero value, the
- iteration ceases immediately, and the value is returned.
- Otherwise, this function returns 0. */
-int addrmap_foreach (struct addrmap *map, addrmap_foreach_fn fn, void *data);
+typedef gdb::function_view<int (CORE_ADDR start_addr, void *obj)>
+ addrmap_foreach_fn;
+
+/* Call FN for every address in MAP, following an in-order traversal.
+ If FN ever returns a non-zero value, the iteration ceases
+ immediately, and the value is returned. Otherwise, this function
+ returns 0. */
+int addrmap_foreach (struct addrmap *map, addrmap_foreach_fn fn);
#endif /* ADDRMAP_H */