From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46780 invoked by alias); 17 Jan 2020 16:37:54 -0000 Mailing-List: contact gdb-testers-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-testers-owner@sourceware.org Received: (qmail 46772 invoked by uid 89); 17 Jan 2020 16:37:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: kwanyin.sergiodj.net Received: from kwanyin.sergiodj.net (HELO kwanyin.sergiodj.net) (158.69.185.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Jan 2020 16:37:44 +0000 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [binutils-gdb] gdb: remove use of iterate_over_inferiors in mi/mi-interp.c From: gdb-buildbot@sergiodj.net To: gdb-testers@sourceware.org Message-Id: <788eca4949d08494109249d35cd599971ce6ec51@gdb-build> Date: Fri, 17 Jan 2020 16:40:00 -0000 X-SW-Source: 2020-q1/txt/msg01857.txt *** TEST RESULTS FOR COMMIT 788eca4949d08494109249d35cd599971ce6ec51 *** commit 788eca4949d08494109249d35cd599971ce6ec51 Author: Simon Marchi AuthorDate: Fri Jan 17 09:57:07 2020 -0500 Commit: Simon Marchi CommitDate: Fri Jan 17 09:57:08 2020 -0500 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. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2de025dd63..c68bc990d0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-01-17 Simon Marchi + + * mi/mi-interp.c (report_initial_inferior): Remove. + (mi_interp::init): Use range-based for to iterate over inferiors. + 2020-01-17 Simon Marchi * python/py-inferior.c (build_inferior_list): Remove. diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 2ac4c11996..e77093cfa2 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 () {