From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69486 invoked by alias); 19 Sep 2019 21:28:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 69405 invoked by uid 89); 19 Sep 2019 21:28:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (50.116.126.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Sep 2019 21:28:31 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 28C1432AE for ; Thu, 19 Sep 2019 16:28:29 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id B3yXiemmn90onB3yXiMT2G; Thu, 19 Sep 2019 16:28:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YJs2IXcrsX4mmAF8hQCL6y1V/N8dV4RT4Tsv1PIn+4k=; b=FFEUDnS2oFEm5+w7V2VMgLaYPp fwNZjRXdE2BP8+V4H1Oc+SFmw3XYQpf0Y3CSyNUb42kW4VNqTnuEw+04E8+OqadT11RqUNHtAyxr5 q2oGtjaE4SoaLipvPCkH3Fqa6; Received: from 71-218-73-27.hlrn.qwest.net ([71.218.73.27]:35244 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iB3yW-001n6D-TD; Thu, 19 Sep 2019 16:28:29 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/4] Don't use iterate_over_inferiors in target.c Date: Thu, 19 Sep 2019 21:28:00 -0000 Message-Id: <20190919212825.7586-4-tom@tromey.com> In-Reply-To: <20190919212825.7586-1-tom@tromey.com> References: <20190919212825.7586-1-tom@tromey.com> X-SW-Source: 2019-09/txt/msg00383.txt.bz2 This changes target.c to use C++ iterators rather than iterate_over_inferiors. gdb/ChangeLog 2019-09-19 Tom Tromey * target.c (dispose_inferiors): Rename from dispose_inferior. Change type. (target_preopen): Update. --- gdb/ChangeLog | 6 ++++++ gdb/target.c | 43 ++++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/gdb/target.c b/gdb/target.c index 78bdfeb49a4..c414c022c75 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1951,31 +1951,32 @@ target_pre_inferior (int from_tty) agent_capability_invalidate (); } -/* Callback for iterate_over_inferiors. Gets rid of the given - inferior. */ +/* Gets rid of all inferiors. */ -static int -dispose_inferior (struct inferior *inf, void *args) +static void +dispose_inferiors () { - /* Not all killed inferiors can, or will ever be, removed from the - inferior list. Killed inferiors clearly don't need to be killed - again, so, we're done. */ - if (inf->pid == 0) - return 0; - - thread_info *thread = any_thread_of_inferior (inf); - if (thread != NULL) + for (inferior *inf : all_inferiors_safe ()) { - switch_to_thread (thread); + /* Not all killed inferiors can, or will ever be, removed from + the inferior list. Killed inferiors clearly don't need to be + killed again, so, we're done. */ + if (inf->pid == 0) + continue; - /* Core inferiors actually should be detached, not killed. */ - if (target_has_execution) - target_kill (); - else - target_detach (inf, 0); - } + thread_info *thread = any_thread_of_inferior (inf); + if (thread != NULL) + { + switch_to_thread (thread); - return 0; + /* Core inferiors actually should be detached, not + killed. */ + if (target_has_execution) + target_kill (); + else + target_detach (inf, 0); + } + } } /* This is to be called by the open routine before it does @@ -1991,7 +1992,7 @@ target_preopen (int from_tty) if (!from_tty || !have_live_inferiors () || query (_("A program is being debugged already. Kill it? "))) - iterate_over_inferiors (dispose_inferior, NULL); + dispose_inferiors (); else error (_("Program not killed.")); } -- 2.17.2