diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2020-01-17 09:57:07 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-01-17 09:57:08 -0500 |
commit | 788eca4949d08494109249d35cd599971ce6ec51 (patch) | |
tree | 3c4d9c4a10316577278301145062f906922c5069 /gdb/mi | |
parent | d9bc85b65b3daab0c3579be0efc3b33c1ef24620 (diff) | |
download | gdb-788eca4949d08494109249d35cd599971ce6ec51.zip gdb-788eca4949d08494109249d35cd599971ce6ec51.tar.gz gdb-788eca4949d08494109249d35cd599971ce6ec51.tar.bz2 |
gdb: remove use of iterate_over_inferiors in mi/mi-interp.c
Replace it with a range-based for. I've updated the comment in
mi_interp::init, which was a bit stale.
gdb/ChangeLog:
* mi/mi-interp.c (report_initial_inferior): Remove.
(mi_interp::init): Use range-based for to iterate over inferiors.
Diffstat (limited to 'gdb/mi')
-rw-r--r-- | gdb/mi/mi-interp.c | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 2ac4c11..e77093c 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -91,8 +91,6 @@ static void mi_memory_changed (struct inferior *inf, CORE_ADDR memaddr, ssize_t len, const bfd_byte *myaddr); static void mi_on_sync_execution_done (void); -static int report_initial_inferior (struct inferior *inf, void *closure); - /* Display the MI prompt. */ static void @@ -137,12 +135,27 @@ mi_interp::init (bool top_level) if (top_level) { - /* The initial inferior is created before this function is - called, so we need to report it explicitly. Use iteration in - case future version of GDB creates more than one inferior - up-front. */ - iterate_over_inferiors (report_initial_inferior, mi); - } + /* The initial inferior is created before this function is called, so we + need to report it explicitly when initializing the top-level MI + interpreter. + + This is also called when additional MI interpreters are added (using + the new-ui command), when multiple inferiors possibly exist, so we need + to use iteration to report all the inferiors. mi_inferior_added can't + be used, because it would print the event on all the other MI UIs. */ + + for (inferior *inf : all_inferiors ()) + { + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); + + fprintf_unfiltered (mi->event_channel, + "thread-group-added,id=\"i%d\"", + inf->num); + + gdb_flush (mi->event_channel); + } + } } void @@ -1253,26 +1266,6 @@ mi_user_selected_context_changed (user_selected_what selection) } } -static int -report_initial_inferior (struct inferior *inf, void *closure) -{ - /* This function is called from mi_interpreter_init, and since - mi_inferior_added assumes that inferior is fully initialized - and top_level_interpreter_data is set, we cannot call - it here. */ - struct mi_interp *mi = (struct mi_interp *) closure; - - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); - - fprintf_unfiltered (mi->event_channel, - "thread-group-added,id=\"i%d\"", - inf->num); - gdb_flush (mi->event_channel); - - return 0; -} - ui_out * mi_interp::interp_ui_out () { |