@@ -4991,11 +4991,11 @@ ada_lookup_simple_minsym (const char *name, struct objfile *objfile)
{
result.minsym = msymbol;
result.objfile = obj;
- return true;
+ return iteration_status::stop;
}
}
- return false;
+ return iteration_status::keep_going;
}, objfile);
return result;
@@ -1500,7 +1500,7 @@ add_symbol_overload_list_qualified (const char *func_name,
SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
SEARCH_FUNCTION_DOMAIN);
- return false;
+ return iteration_status::keep_going;
}, current_objfile);
}
@@ -757,7 +757,7 @@ static int
elf_gnu_ifunc_resolve_by_cache (const char *name, CORE_ADDR *addr_p)
{
gnu_ifunc_debug_printf ("resolving \"%s\" by cache", name);
- int found = 0;
+ bool found = false;
const char *func = __func__;
/* FIXME: we only search the initial namespace.
@@ -770,11 +770,11 @@ elf_gnu_ifunc_resolve_by_cache (const char *name, CORE_ADDR *addr_p)
elf_gnu_ifunc_cache *cache
= elf_objfile_gnu_ifunc_cache_data.get (objfile);
if (cache == nullptr)
- return false;
+ return iteration_status::keep_going;
auto it = cache->find (name);
if (it == cache->end ())
- return false;
+ return iteration_status::keep_going;
if (addr_p != nullptr)
*addr_p = it->second;
@@ -782,8 +782,8 @@ elf_gnu_ifunc_resolve_by_cache (const char *name, CORE_ADDR *addr_p)
gnu_ifunc_debug_printf_func
(func, "cache hit for \"%s\" -> %s in objfile %s", name,
paddress (objfile->arch (), it->second), objfile_name (objfile));
- found = 1;
- return true;
+ found = true;
+ return iteration_status::stop;
}, nullptr);
if (!found)
@@ -806,7 +806,7 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p)
gnu_ifunc_debug_printf ("resolving \"%s\" by GOT", name);
char *name_got_plt;
const size_t got_suffix_len = strlen (SYMBOL_GOT_PLT_SUFFIX);
- int found = 0;
+ bool found = false;
const char *func = __func__;
name_got_plt = (char *) alloca (strlen (name) + got_suffix_len + 1);
@@ -831,19 +831,19 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p)
= lookup_minimal_symbol (current_program_space, name_got_plt,
objfile);
if (msym.minsym == NULL)
- return 0;
+ return iteration_status::keep_going;
if (msym.minsym->type () != mst_slot_got_plt)
- return 0;
+ return iteration_status::keep_going;
pointer_address = msym.value_address ();
plt = bfd_get_section_by_name (obfd, ".plt");
if (plt == NULL)
- return 0;
+ return iteration_status::keep_going;
if (msym.minsym->size () != ptr_size)
- return 0;
+ return iteration_status::keep_going;
if (target_read_memory (pointer_address, buf, ptr_size) != 0)
- return 0;
+ return iteration_status::keep_going;
addr = extract_typed_address (buf, ptr_type);
addr = gdbarch_convert_from_func_ptr_addr
(gdbarch, addr, current_inferior ()->top_target ());
@@ -860,11 +860,11 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p)
gnu_ifunc_debug_printf_func (func,
"resolved \"%s\" via GOT to %s",
name, paddress (gdbarch, addr));
- found = 1;
- return 1;
+ found = true;
+ return iteration_status::stop;
}
- return 0;
+ return iteration_status::keep_going;
}, nullptr);
if (!found)
@@ -455,7 +455,9 @@ language_defn::read_var_value (struct symbol *var,
var->linkage_name (), objfile);
/* Stop if a match is found. */
- return bmsym.minsym != nullptr;
+ if (bmsym.minsym != nullptr)
+ return iteration_status::stop;
+ return iteration_status::keep_going;
},
var->objfile ());
@@ -129,7 +129,7 @@ program_space::iterate_over_objfiles_in_search_order
(cb, current_objfile);
for (auto &objfile : this->objfiles ())
- if (cb (&objfile))
+ if (cb (&objfile) == iteration_status::stop)
return;
}
@@ -207,8 +207,9 @@ struct program_space
/* Iterate over all objfiles of the program space in the order that makes the
most sense to make global symbol searches.
- CB is a callback function passed an objfile to be searched. The iteration stops
- if this function returns true.
+ CB is a callback function passed an objfile to be searched. It
+ returns an iteration_status to indicate whether the search should
+ continue.
If not nullptr, CURRENT_OBJFILE corresponds to the objfile being
inspected when the symbol search was requested. */
@@ -609,21 +609,21 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
{
/* Don't return separate debug files. */
if (obj->separate_debug_objfile_backlink != nullptr)
- return false;
+ return iteration_status::keep_going;
bfd *obfd = obj->obfd.get ();
if (obfd == nullptr)
- return false;
+ return iteration_status::keep_going;
const bfd_build_id *obfd_build_id = build_id_bfd_get (obfd);
if (obfd_build_id == nullptr)
- return false;
+ return iteration_status::keep_going;
if (!objfpy_build_id_matches (obfd_build_id, name))
- return false;
+ return iteration_status::keep_going;
objfile = obj;
- return true;
+ return iteration_status::stop;
}, gdbpy_current_objfile);
else
current_program_space->iterate_over_objfiles_in_search_order
@@ -631,26 +631,26 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
{
/* Don't return separate debug files. */
if (obj->separate_debug_objfile_backlink != nullptr)
- return false;
+ return iteration_status::keep_going;
if ((obj->flags & OBJF_NOT_FILENAME) != 0)
- return false;
+ return iteration_status::keep_going;
const char *filename = objfile_filename (obj);
if (filename != NULL
&& compare_filenames_for_search (filename, name))
{
objfile = obj;
- return true;
+ return iteration_status::keep_going;
}
if (compare_filenames_for_search (obj->original_name, name))
{
objfile = obj;
- return true;
+ return iteration_status::keep_going;
}
- return false;
+ return iteration_status::keep_going;
}, gdbpy_current_objfile);
if (objfile != NULL)
@@ -3664,7 +3664,7 @@ svr4_solib_ops::iterate_over_objfiles_in_search_order
&& gdb_bfd_scan_elf_dyntag (DT_SYMBOLIC, abfd, nullptr, nullptr) == 1)
{
checked_current_objfile = true;
- if (cb (current_objfile))
+ if (cb (current_objfile) == iteration_status::stop)
return;
}
}
@@ -3700,7 +3700,7 @@ svr4_solib_ops::iterate_over_objfiles_in_search_order
if (solib_base != debug_base)
continue;
- if (cb (&objfile))
+ if (cb (&objfile) == iteration_status::stop)
return;
}
}
@@ -451,7 +451,7 @@ solib_ops::iterate_over_objfiles_in_search_order
objfile *current_objfile) const
{
for (objfile &objfile : m_pspace->objfiles ())
- if (cb (&objfile))
+ if (cb (&objfile) == iteration_status::stop)
return;
}
@@ -23,6 +23,7 @@
#include "gdb_bfd.h"
#include "gdbsupport/function-view.h"
#include "gdbsupport/intrusive_list.h"
+#include "gdbsupport/iteration-status.h"
#include "gdbsupport/owning_intrusive_list.h"
#include "symfile-add-flags.h"
#include "target-section.h"
@@ -141,7 +142,7 @@ using solib_up = std::unique_ptr<solib>;
methods. */
using iterate_over_objfiles_in_search_order_cb_ftype
- = gdb::function_view<bool (objfile *)>;
+ = gdb::function_view<iteration_status (objfile *)>;
struct solib_ops
{
@@ -2564,7 +2564,9 @@ lookup_global_or_static_symbol (const char *name,
{
result = lookup_symbol_in_objfile (objfile_iter, block_index,
name, domain);
- return result.symbol != nullptr;
+ if (result.symbol != nullptr)
+ return iteration_status::stop;
+ return iteration_status::keep_going;
},
objfile);
@@ -6407,10 +6409,10 @@ find_main_name (void)
if (symbol_found_p)
{
set_main_name (pspace, "main", lang);
- return true;
+ return iteration_status::stop;
}
- return false;
+ return iteration_status::keep_going;
}, nullptr);
if (symbol_found_p)
@@ -915,14 +915,14 @@ windows_solib_ops::iterate_over_objfiles_in_search_order
{
if (current_objfile)
{
- if (cb (current_objfile))
+ if (cb (current_objfile) == iteration_status::stop)
return;
}
for (objfile &objfile : m_pspace->objfiles ())
if (&objfile != current_objfile)
{
- if (cb (&objfile))
+ if (cb (&objfile) == iteration_status::stop)
return;
}
}