From patchwork Wed Jan 15 19:12:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 37394 Received: (qmail 79056 invoked by alias); 15 Jan 2020 19:12:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 79024 invoked by uid 89); 15 Jan 2020 19:12:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=Display, sk:mi_inte X-HELO: mail.efficios.com Received: from mail.efficios.com (HELO mail.efficios.com) (167.114.26.124) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Jan 2020 19:12:30 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 0AD0823D11B for ; Wed, 15 Jan 2020 14:12:29 -0500 (EST) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Rr4yEoZyFqMB; Wed, 15 Jan 2020 14:12:28 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 79D3923CDDB; Wed, 15 Jan 2020 14:12:28 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 79D3923CDDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1579115548; bh=HaBzxkUSMfFpv4xzSDDx0pc89AK/+jkeVRwXnlqMr24=; h=From:To:Date:Message-Id:MIME-Version; b=SYSRPbE0QFSMCrPWtYbISn2+2/eLnYjbXD6fu4QkM+cKEjM8aBnANkH0iPNVl0eYn HDix1rU10L0DsZantNCajX+LwghGjMowMt3krGWNNUliHffEx8WsrAcrytk308RflA yzGqof/bAHZwinIKB2DzSU2n0HmMF6xBEALY6lspgb5eYaa4c+RzSHnEPZ/MIlXh6z XYiST8/NKVSrET3RpengznkUYvFYkYiQptL9d106HxLwNlm5hZF1EyM7utpti3uoPC QRB/kLIRUdJeWRqFUrrUwoLmsdZt0D03ybE5ggq/y/4XFV4lvAo7CQc62k9o75wZuj fZLWLYf2owqCw== Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id JvhHjSZF7521; Wed, 15 Jan 2020 14:12:28 -0500 (EST) Received: from smarchi-efficios.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by mail.efficios.com (Postfix) with ESMTPSA id 4FF4123CDD9; Wed, 15 Jan 2020 14:12:28 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/4] gdb: remove use of iterate_over_inferiors in mi/mi-interp.c Date: Wed, 15 Jan 2020 14:12:20 -0500 Message-Id: <20200115191222.28208-3-simon.marchi@efficios.com> In-Reply-To: <20200115191222.28208-1-simon.marchi@efficios.com> References: <20200115191222.28208-1-simon.marchi@efficios.com> MIME-Version: 1.0 Replace it with a range-based for. I figured that in the hypothetical case where there are multiple inferiors, we only need to configure the terminal and flush the output once, so I have moved these out of the loop. gdb/ChangeLog: * mi/mi-interp.c (report_initial_inferior): Remove. (mi_interp::init): Use range-based for to iterate over inferiors. --- gdb/mi/mi-interp.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 2ac4c119961c..6f4f56849611 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 @@ -140,8 +138,22 @@ mi_interp::init (bool 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); + up-front. + + 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. */ + + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); + + for (inferior *inf : all_inferiors ()) + fprintf_unfiltered (mi->event_channel, + "thread-group-added,id=\"i%d\"", + inf->num); + + gdb_flush (mi->event_channel); } } @@ -1253,26 +1265,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 () {