From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69216 invoked by alias); 19 Sep 2019 21:28:32 -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 69137 invoked by uid 89); 19 Sep 2019 21:28:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.46.113) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Sep 2019 21:28:30 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 8E675400CECEA for ; Thu, 19 Sep 2019 16:28:29 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id B3yXixdnrdnCeB3yXiH8ay; 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=0TxS0TI9WlkD7hY8LyhkHa02K5WxjC25W3o0K/1+CNE=; b=VUIThH6qsD2yrmd8AmvMw/QM7L KO3AzccQZSMK5xXXUkhMeXfxEmn2uuvcCCKVDqcHnKxN4G6IHPADqTySFinFHwSOXWipQudX8pr0i T6WyS9nk9C/nOYgNdv3F1/xNF; 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 1iB3yX-001n6D-BE; Thu, 19 Sep 2019 16:28:29 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/4] Remove a use of iterate_over_threads from mi-main.c Date: Thu, 19 Sep 2019 21:28:00 -0000 Message-Id: <20190919212825.7586-5-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/msg00380.txt.bz2 This removes one use of iterate_over_threads from mi-main.c. gdb/ChangeLog 2019-09-19 Tom Tromey * mi/mi-main.c (run_inferiors): Rename from run_one_inferior. Change type. (mi_cmd_exec_run): Update. Use bool. --- gdb/ChangeLog | 6 +++++ gdb/mi/mi-main.c | 57 +++++++++++++++++++++++------------------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 2ece3602056..30cc79ce27c 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -391,44 +391,41 @@ 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 all inferiors. - 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). */ + RUN_CMD is the run command to use, either "run" or "start". */ -static int -run_one_inferior (struct inferior *inf, void *arg) +static void +run_inferiors (const char *run_cmd) { - 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 (); - - if (inf->pid != 0) + for (inferior *inf : all_inferiors_safe ()) { - thread_info *tp = any_thread_of_inferior (inf); - if (tp == NULL) - error (_("Inferior has no threads.")); + struct target_ops *run_target = find_run_target (); + int async_p = mi_async && run_target->can_async_p (); - switch_to_thread (tp); - } - else - { - set_current_inferior (inf); - switch_to_no_thread (); - set_current_program_space (inf->pspace); + if (inf->pid != 0) + { + thread_info *tp = any_thread_of_inferior (inf); + if (tp == NULL) + error (_("Inferior has no threads.")); + + switch_to_thread (tp); + } + else + { + set_current_inferior (inf); + switch_to_no_thread (); + set_current_program_space (inf->pspace); + } + mi_execute_cli_command (run_cmd, async_p, + async_p ? "&" : NULL); } - mi_execute_cli_command (run_cmd, async_p, - async_p ? "&" : NULL); - return 0; } void mi_cmd_exec_run (const char *command, char **argv, int argc) { - int start_p = 0; + bool start_p = false; /* Parse the command options. */ enum opt @@ -453,7 +450,7 @@ mi_cmd_exec_run (const char *command, char **argv, int argc) switch ((enum opt) opt) { case START_OPT: - start_p = 1; + start_p = true; break; } } @@ -463,15 +460,15 @@ mi_cmd_exec_run (const char *command, char **argv, int argc) if (oind != argc) error (_("Invalid argument: %s"), argv[oind]); + const char *run_cmd = start_p ? "start" : "run"; if (current_context->all) { scoped_restore_current_pspace_and_thread restore_pspace_thread; - iterate_over_inferiors (run_one_inferior, &start_p); + run_inferiors (run_cmd); } else { - 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 (); -- 2.17.2