diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7a5cc4272c6..d1784431946 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5332,8 +5332,8 @@ struct match_data
   int found_sym;
 };
 
-/* A callback for add_nonlocal_symbols that adds SYM, found in BLOCK,
-   to a list of symbols.  DATA0 is a pointer to a struct match_data *
+/* A callback for add_nonlocal_symbols that adds symbol, found in BSYM,
+   to a list of symbols.  DATA is a pointer to a struct match_data *
    containing the obstack that collects the symbol list, the file that SYM
    must come from, a flag indicating whether a non-argument symbol has
    been found in the current block, and the last argument symbol
@@ -5341,12 +5341,13 @@ struct match_data
    marking the end of a block, the argument symbol is added if no
    other has been found.  */
 
-static int
-aux_add_nonlocal_symbols (const struct block *block, struct symbol *sym,
-			  void *data0)
+static bool
+aux_add_nonlocal_symbols (struct block_symbol *bsym,
+			  struct match_data *data)
 {
-  struct match_data *data = (struct match_data *) data0;
-  
+  const struct block *block = bsym->block;
+  struct symbol *sym = bsym->symbol;
+
   if (sym == NULL)
     {
       if (!data->found_sym && data->arg_sym != NULL) 
@@ -5359,7 +5360,7 @@ aux_add_nonlocal_symbols (const struct block *block, struct symbol *sym,
   else 
     {
       if (SYMBOL_CLASS (sym) == LOC_UNRESOLVED)
-	return 0;
+	return true;
       else if (SYMBOL_IS_ARGUMENT (sym))
 	data->arg_sym = sym;
       else
@@ -5370,7 +5371,7 @@ aux_add_nonlocal_symbols (const struct block *block, struct symbol *sym,
 			   block);
 	}
     }
-  return 0;
+  return true;
 }
 
 /* Helper for add_nonlocal_symbols.  Find symbols in DOMAIN which are
@@ -5541,20 +5542,23 @@ add_nonlocal_symbols (struct obstack *obstackp,
 
   bool is_wild_match = lookup_name.ada ().wild_match_p ();
 
+  auto callback = [&] (struct block_symbol *bsym)
+    {
+      return aux_add_nonlocal_symbols (bsym, &data);
+    };
+
   for (objfile *objfile : current_program_space->objfiles ())
     {
       data.objfile = objfile;
 
       if (is_wild_match)
 	objfile->sf->qf->map_matching_symbols (objfile, lookup_name.name ().c_str (),
-					       domain, global,
-					       aux_add_nonlocal_symbols, &data,
+					       domain, global, callback,
 					       symbol_name_match_type::WILD,
 					       NULL);
       else
 	objfile->sf->qf->map_matching_symbols (objfile, lookup_name.name ().c_str (),
-					       domain, global,
-					       aux_add_nonlocal_symbols, &data,
+					       domain, global, callback,
 					       symbol_name_match_type::FULL,
 					       compare_names);
 
@@ -5578,9 +5582,7 @@ add_nonlocal_symbols (struct obstack *obstackp,
         {
 	  data.objfile = objfile;
 	  objfile->sf->qf->map_matching_symbols (objfile, name1.c_str (),
-						 domain, global,
-						 aux_add_nonlocal_symbols,
-						 &data,
+						 domain, global, callback,
 						 symbol_name_match_type::FULL,
 						 compare_names);
 	}
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 3d90d632891..e86fdaa7bc8 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4181,13 +4181,13 @@ dw2_expand_symtabs_with_fullname (struct objfile *objfile,
 }
 
 static void
-dw2_map_matching_symbols (struct objfile *objfile,
-			  const char * name, domain_enum domain,
-			  int global,
-			  int (*callback) (const struct block *,
-					   struct symbol *, void *),
-			  void *data, symbol_name_match_type match,
-			  symbol_compare_ftype *ordered_compare)
+dw2_map_matching_symbols
+  (struct objfile *objfile,
+   const char * name, domain_enum domain,
+   int global,
+   gdb::function_view<symbol_found_callback_ftype> callback,
+   symbol_name_match_type match,
+   symbol_compare_ftype *ordered_compare)
 {
   /* Currently unimplemented; used for Ada.  The function can be called if the
      current language is Ada for a non-Ada objfile using GNU index.  As Ada
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 6cc7566580a..c667a6273c2 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1164,14 +1164,14 @@ psymtab_to_fullname (struct partial_symtab *ps)
 
 /* For all symbols, s, in BLOCK that are in DOMAIN and match NAME
    according to the function MATCH, call CALLBACK(BLOCK, s, DATA).
-   BLOCK is assumed to come from OBJFILE.  Returns 1 iff CALLBACK
-   ever returns non-zero, and otherwise returns 0.  */
+   BLOCK is assumed to come from OBJFILE.  Returns false iff CALLBACK
+   ever returns false, and otherwise returns true.  */
 
-static int
+static bool
 map_block (const char *name, domain_enum domain, struct objfile *objfile,
 	   const struct block *block,
-	   int (*callback) (const struct block *, struct symbol *, void *),
-	   void *data, symbol_name_match_type match)
+	   gdb::function_view<symbol_found_callback_ftype> callback,
+	   symbol_name_match_type match)
 {
   struct block_iterator iter;
   struct symbol *sym;
@@ -1185,26 +1185,26 @@ map_block (const char *name, domain_enum domain, struct objfile *objfile,
       if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
 				 SYMBOL_DOMAIN (sym), domain))
 	{
-	  if (callback (block, sym, data))
-	    return 1;
+	  struct block_symbol block_sym = {sym, block};
+	  if (!callback (&block_sym))
+	    return false;
 	}
     }
 
-  return 0;
+  return true;
 }
 
 /* Psymtab version of map_matching_symbols.  See its definition in
    the definition of quick_symbol_functions in symfile.h.  */
 
 static void
-psym_map_matching_symbols (struct objfile *objfile,
-			   const char *name, domain_enum domain,
-			   int global,
-			   int (*callback) (const struct block *,
-					    struct symbol *, void *),
-			   void *data,
-			   symbol_name_match_type match,
-			   symbol_compare_ftype *ordered_compare)
+psym_map_matching_symbols
+  (struct objfile *objfile,
+   const char *name, domain_enum domain,
+   int global,
+   gdb::function_view<symbol_found_callback_ftype> callback,
+   symbol_name_match_type match,
+   symbol_compare_ftype *ordered_compare)
 {
   const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
 
@@ -1221,10 +1221,10 @@ psym_map_matching_symbols (struct objfile *objfile,
 	  if (cust == NULL)
 	    continue;
 	  block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind);
-	  if (map_block (name, domain, objfile, block,
-			 callback, data, match))
+	  if (!map_block (name, domain, objfile, block, callback, match))
 	    return;
-	  if (callback (block, NULL, data))
+	  struct block_symbol block_sym = {nullptr, block};
+	  if (!callback (&block_sym))
 	    return;
 	}
     }
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 0f9da66e536..17bc5e8b977 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -228,30 +228,27 @@ debug_qf_expand_symtabs_with_fullname (struct objfile *objfile,
 }
 
 static void
-debug_qf_map_matching_symbols (struct objfile *objfile,
-			       const char *name, domain_enum domain,
-			       int global,
-			       int (*callback) (const struct block *,
-						struct symbol *, void *),
-			       void *data,
-			       symbol_name_match_type match,
-			       symbol_compare_ftype *ordered_compare)
+debug_qf_map_matching_symbols
+  (struct objfile *objfile,
+   const char *name, domain_enum domain,
+   int global,
+   gdb::function_view<symbol_found_callback_ftype> callback,
+   symbol_name_match_type match,
+   symbol_compare_ftype *ordered_compare)
 {
   const struct debug_sym_fns_data *debug_data
     = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog,
-		    "qf->map_matching_symbols (%s, \"%s\", %s, %d, %s, %s, %s, %s)\n",
+		    "qf->map_matching_symbols (%s, \"%s\", %s, %d, %s, %s)\n",
 		    objfile_debug_name (objfile), name,
 		    domain_name (domain), global,
-		    host_address_to_string (callback),
-		    host_address_to_string (data),
 		    plongest ((LONGEST) match),
 		    host_address_to_string (ordered_compare));
 
   debug_data->real_sf->qf->map_matching_symbols (objfile, name,
 						 domain, global,
-						 callback, data,
+						 callback,
 						 match,
 						 ordered_compare);
 }
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 741b085e0c4..9121d883ee0 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -211,7 +211,7 @@ struct quick_symbol_functions
      and for which MATCH (symbol name, NAME) == 0, passing each to 
      CALLBACK, reading in partial symbol tables as needed.  Look
      through global symbols if GLOBAL and otherwise static symbols.
-     Passes NAME, NAMESPACE, and DATA to CALLBACK with each symbol
+     Passes NAME and NAMESPACE to CALLBACK with each symbol
      found.  After each block is processed, passes NULL to CALLBACK.
      MATCH must be weaker than strcmp_iw_ordered in the sense that
      strcmp_iw_ordered(x,y) == 0 --> MATCH(x,y) == 0.  ORDERED_COMPARE,
@@ -221,17 +221,16 @@ struct quick_symbol_functions
      and 
             strcmp_iw_ordered(x,y) <= 0 --> ORDERED_COMPARE(x,y) <= 0
      (allowing strcmp_iw_ordered(x,y) < 0 while ORDERED_COMPARE(x, y) == 0).
-     CALLBACK returns 0 to indicate that the scan should continue, or
-     non-zero to indicate that the scan should be terminated.  */
-
-  void (*map_matching_symbols) (struct objfile *,
-				const char *name, domain_enum domain,
-				int global,
-				int (*callback) (const struct block *,
-						 struct symbol *, void *),
-				void *data,
-				symbol_name_match_type match,
-				symbol_compare_ftype *ordered_compare);
+     CALLBACK returns true to indicate that the scan should continue, or
+     false to indicate that the scan should be terminated.  */
+
+  void (*map_matching_symbols)
+    (struct objfile *,
+     const char *name, domain_enum domain,
+     int global,
+     gdb::function_view<symbol_found_callback_ftype> callback,
+     symbol_name_match_type match,
+     symbol_compare_ftype *ordered_compare);
 
   /* Expand all symbol tables in OBJFILE matching some criteria.
 
