mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 04:24:43 +00:00
gdb, gdbserver: use structured bindings in a few places
I wanted to change one of these, so I searched for more similar instances, while at it. I think this looks a bit tidier, over unpacking the pairs by hand. Change-Id: Ife4b678f7a6aed01803434197c564d2ab93532a7 Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
@@ -451,11 +451,8 @@ core_target::build_file_mappings ()
|
||||
const bfd_build_id *core_build_id
|
||||
= build_id_bfd_get (current_program_space->core_bfd ());
|
||||
|
||||
for (const auto &iter : mapped_files)
|
||||
for (const auto &[filename, file_data] : mapped_files)
|
||||
{
|
||||
const std::string &filename = iter.first;
|
||||
const mapped_file &file_data = iter.second;
|
||||
|
||||
/* If this mapped file has the same build-id as was discovered for
|
||||
the core-file itself, then we assume this is the main
|
||||
executable. Record the filename as we can use this later. */
|
||||
|
||||
@@ -952,14 +952,9 @@ mdict_create_hashed (struct obstack *obstack,
|
||||
retval->n_allocated_dictionaries = nsyms.size ();
|
||||
|
||||
int idx = 0;
|
||||
for (const auto &pair : nsyms)
|
||||
{
|
||||
enum language language = pair.first;
|
||||
std::vector<symbol *> symlist = pair.second;
|
||||
|
||||
retval->dictionaries[idx++]
|
||||
= dict_create_hashed (obstack, language, symlist);
|
||||
}
|
||||
for (const auto &[language, symlist] : nsyms)
|
||||
retval->dictionaries[idx++] = dict_create_hashed (obstack, language,
|
||||
symlist);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -997,14 +992,9 @@ mdict_create_linear (struct obstack *obstack,
|
||||
retval->n_allocated_dictionaries = nsyms.size ();
|
||||
|
||||
int idx = 0;
|
||||
for (const auto &pair : nsyms)
|
||||
{
|
||||
enum language language = pair.first;
|
||||
std::vector<symbol *> symlist = pair.second;
|
||||
|
||||
retval->dictionaries[idx++]
|
||||
= dict_create_linear (obstack, language, symlist);
|
||||
}
|
||||
for (const auto &[language, symlist] : nsyms)
|
||||
retval->dictionaries[idx++] = dict_create_linear (obstack, language,
|
||||
symlist);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -1135,10 +1125,8 @@ mdict_add_pending (struct multidictionary *mdict,
|
||||
gdb::unordered_map<enum language, std::vector<symbol *>> nsyms
|
||||
= collate_pending_symbols_by_language (symbol_list);
|
||||
|
||||
for (const auto &pair : nsyms)
|
||||
for (const auto &[language, symlist] : nsyms)
|
||||
{
|
||||
enum language language = pair.first;
|
||||
std::vector<symbol *> symlist = pair.second;
|
||||
struct dictionary *dict = find_language_dictionary (mdict, language);
|
||||
|
||||
if (dict == nullptr)
|
||||
|
||||
@@ -3591,16 +3591,11 @@ find_debug_base_for_solib (const solib *solib)
|
||||
auto *lm_info
|
||||
= gdb::checked_static_cast<const lm_info_svr4 *> (solib->lm_info.get ());
|
||||
|
||||
for (const auto &tuple : info->solib_lists)
|
||||
{
|
||||
CORE_ADDR debug_base = tuple.first;
|
||||
const std::vector<svr4_so> &sos = tuple.second;
|
||||
|
||||
for (const svr4_so &so : sos)
|
||||
if (svr4_same (solib->original_name.c_str (), so.name.c_str (),
|
||||
*lm_info, *so.lm_info))
|
||||
return debug_base;
|
||||
}
|
||||
for (const auto &[debug_base, sos] : info->solib_lists)
|
||||
for (const svr4_so &so : sos)
|
||||
if (svr4_same (solib->original_name.c_str (), so.name.c_str (), *lm_info,
|
||||
*so.lm_info))
|
||||
return debug_base;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1210,14 +1210,13 @@ info_linker_namespace_command (const char *pattern, int from_tty)
|
||||
|
||||
bool ns_separator = false;
|
||||
|
||||
for (auto &solibs_pair : all_solibs_to_print)
|
||||
for (const auto &[ns, solibs_to_print] : all_solibs_to_print)
|
||||
{
|
||||
if (ns_separator)
|
||||
uiout->message ("\n\n");
|
||||
else
|
||||
ns_separator = true;
|
||||
int ns = solibs_pair.first;
|
||||
std::vector<const solib *> solibs_to_print = solibs_pair.second;
|
||||
|
||||
if (solibs_to_print.size () == 0)
|
||||
{
|
||||
uiout->message (_("Linker namespace [[%d]] is not active.\n"), ns);
|
||||
|
||||
@@ -6986,11 +6986,8 @@ info_module_subcommand (bool quiet, const char *module_regexp,
|
||||
|
||||
const char *last_filename = "";
|
||||
const symbol *last_module_symbol = nullptr;
|
||||
for (const module_symbol_search &ms : module_symbols)
|
||||
for (const auto &[p, q] : module_symbols)
|
||||
{
|
||||
const symbol_search &p = ms.first;
|
||||
const symbol_search &q = ms.second;
|
||||
|
||||
gdb_assert (q.symbol != nullptr);
|
||||
|
||||
if (last_module_symbol != p.symbol)
|
||||
|
||||
@@ -1018,20 +1018,15 @@ handle_general_set (char *own_buf)
|
||||
});
|
||||
}
|
||||
|
||||
for (const auto &iter : set_options)
|
||||
{
|
||||
thread_info *thread = iter.first;
|
||||
gdb_thread_options options = iter.second;
|
||||
for (const auto [thread, options] : set_options)
|
||||
if (thread->thread_options != options)
|
||||
{
|
||||
threads_debug_printf ("[options for %s are now %s]\n",
|
||||
target_pid_to_str (thread->id).c_str (),
|
||||
to_string (options).c_str ());
|
||||
|
||||
if (thread->thread_options != options)
|
||||
{
|
||||
threads_debug_printf ("[options for %s are now %s]\n",
|
||||
target_pid_to_str (thread->id).c_str (),
|
||||
to_string (options).c_str ());
|
||||
|
||||
thread->thread_options = options;
|
||||
}
|
||||
}
|
||||
thread->thread_options = options;
|
||||
}
|
||||
|
||||
write_ok (own_buf);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user