public inbox for gdb-testers@sourceware.org help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net To: gdb-testers@sourceware.org Subject: [binutils-gdb] gdb: remove uses of iterate_over_inferiors in mi/mi-main.c Date: Fri, 17 Jan 2020 16:50:00 -0000 [thread overview] Message-ID: <a9ac81b1a7902a4c41f5653032e2971a767accc4@gdb-build> (raw) *** TEST RESULTS FOR COMMIT a9ac81b1a7902a4c41f5653032e2971a767accc4 *** commit a9ac81b1a7902a4c41f5653032e2971a767accc4 Author: Simon Marchi <simon.marchi@efficios.com> AuthorDate: Fri Jan 17 09:57:58 2020 -0500 Commit: Simon Marchi <simon.marchi@efficios.com> CommitDate: Fri Jan 17 09:57:58 2020 -0500 gdb: remove uses of iterate_over_inferiors in mi/mi-main.c Replace with range-based loops. gdb/ChangeLog: * mi/mi-main.c (run_one_inferior): Change return type to void, replace `void *` parameter with proper parameters. (mi_cmd_exec_run): Use range-based loop to iterate over inferiors. (print_one_inferior): Change return type to void, replace `void *` parameter with proper parameters. (mi_cmd_list_thread_groups): Use range-based loop to iterate over inferiors. (get_other_inferior): Remove. (mi_cmd_remove_inferior): Use range-based loop to iterate over inferiors. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c68bc990d0..0d3660249f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2020-01-17 Simon Marchi <simon.marchi@efficios.com> + + * mi/mi-main.c (run_one_inferior): Change return type to void, replace + `void *` parameter with proper parameters. + (mi_cmd_exec_run): Use range-based loop to iterate over inferiors. + (print_one_inferior): Change return type to void, replace `void *` + parameter with proper parameters. + (mi_cmd_list_thread_groups): Use range-based loop to iterate over + inferiors. + (get_other_inferior): Remove. + (mi_cmd_remove_inferior): Use range-based loop to iterate over + inferiors. + 2020-01-17 Simon Marchi <simon.marchi@efficios.com> * mi/mi-interp.c (report_initial_inferior): Remove. diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 014feaf649..d0a3b28874 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -390,17 +390,14 @@ mi_cmd_exec_interrupt (const char *command, char **argv, int argc) } } -/* Callback for iterate_over_inferiors which starts the execution - of the given inferior. +/* Start the execution of the given inferior. - ARG is a pointer to an integer whose value, if non-zero, indicates - that the program should be stopped when reaching the main subprogram - (similar to what the CLI "start" command does). */ + START_P indicates whether the program should be stopped when reaching the + main subprogram (similar to what the CLI "start" command does). */ -static int -run_one_inferior (struct inferior *inf, void *arg) +static void +run_one_inferior (inferior *inf, bool start_p) { - int start_p = *(int *) arg; const char *run_cmd = start_p ? "start" : "run"; struct target_ops *run_target = find_run_target (); int async_p = mi_async && run_target->can_async_p (); @@ -417,7 +414,6 @@ run_one_inferior (struct inferior *inf, void *arg) switch_to_inferior_no_thread (inf); mi_execute_cli_command (run_cmd, async_p, async_p ? "&" : NULL); - return 0; } void @@ -462,7 +458,8 @@ mi_cmd_exec_run (const char *command, char **argv, int argc) { scoped_restore_current_pspace_and_thread restore_pspace_thread; - iterate_over_inferiors (run_one_inferior, &start_p); + for (inferior *inf : all_inferiors ()) + run_one_inferior (inf, start_p); } else { @@ -633,16 +630,13 @@ struct print_one_inferior_data const std::set<int> *inferiors; }; -static int -print_one_inferior (struct inferior *inferior, void *xdata) +static void +print_one_inferior (struct inferior *inferior, bool recurse, + const std::set<int> &ids) { - struct print_one_inferior_data *top_data - = (struct print_one_inferior_data *) xdata; struct ui_out *uiout = current_uiout; - if (top_data->inferiors->empty () - || (top_data->inferiors->find (inferior->pid) - != top_data->inferiors->end ())) + if (ids.empty () || (ids.find (inferior->pid) != ids.end ())) { struct collect_cores_data data; ui_out_emit_tuple tuple_emitter (uiout, NULL); @@ -675,11 +669,9 @@ print_one_inferior (struct inferior *inferior, void *xdata) uiout->field_signed (NULL, b); } - if (top_data->recurse) + if (recurse) print_thread_info (uiout, NULL, inferior->pid); } - - return 0; } /* Output a field named 'cores' with a list as the value. The @@ -853,18 +845,14 @@ mi_cmd_list_thread_groups (const char *command, char **argv, int argc) } else { - struct print_one_inferior_data data; - - data.recurse = recurse; - data.inferiors = &ids; - /* Local thread groups. Either no explicit ids -- and we print everything, or several explicit ids. In both cases, we print more than one group, and have to use 'groups' as the top-level element. */ ui_out_emit_list list_emitter (uiout, "groups"); update_thread_list (); - iterate_over_inferiors (print_one_inferior, &data); + for (inferior *inf : all_inferiors ()) + print_one_inferior (inf, recurse, ids); } } @@ -1719,23 +1707,11 @@ mi_cmd_add_inferior (const char *command, char **argv, int argc) current_uiout->field_fmt ("inferior", "i%d", inf->num); } -/* Callback used to find the first inferior other than the current - one. */ - -static int -get_other_inferior (struct inferior *inf, void *arg) -{ - if (inf == current_inferior ()) - return 0; - - return 1; -} - void mi_cmd_remove_inferior (const char *command, char **argv, int argc) { int id; - struct inferior *inf; + struct inferior *inf_to_remove; if (argc != 1) error (_("-remove-inferior should be passed a single argument")); @@ -1743,18 +1719,23 @@ mi_cmd_remove_inferior (const char *command, char **argv, int argc) if (sscanf (argv[0], "i%d", &id) != 1) error (_("the thread group id is syntactically invalid")); - inf = find_inferior_id (id); - if (!inf) + inf_to_remove = find_inferior_id (id); + if (inf_to_remove == NULL) error (_("the specified thread group does not exist")); - if (inf->pid != 0) + if (inf_to_remove->pid != 0) error (_("cannot remove an active inferior")); - if (inf == current_inferior ()) + if (inf_to_remove == current_inferior ()) { struct thread_info *tp = 0; - struct inferior *new_inferior - = iterate_over_inferiors (get_other_inferior, NULL); + struct inferior *new_inferior = NULL; + + for (inferior *inf : all_inferiors ()) + { + if (inf != inf_to_remove) + new_inferior = inf; + } if (new_inferior == NULL) error (_("Cannot remove last inferior")); @@ -1769,7 +1750,7 @@ mi_cmd_remove_inferior (const char *command, char **argv, int argc) set_current_program_space (new_inferior->pspace); } - delete_inferior (inf); + delete_inferior (inf_to_remove); } \f
next reply other threads:[~2020-01-17 16:40 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-01-17 16:50 gdb-buildbot [this message] 2020-01-17 16:50 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-w64-mingw32, branch master *** BREAKAGE *** gdb-buildbot 2020-01-17 18:33 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, branch master gdb-buildbot 2020-01-17 19:44 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
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=a9ac81b1a7902a4c41f5653032e2971a767accc4@gdb-build \ --to=gdb-buildbot@sergiodj.net \ --cc=gdb-testers@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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).