From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120168 invoked by alias); 21 Jan 2020 02:13:30 -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 120160 invoked by uid 89); 21 Jan 2020 02:13:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.2 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=Inferior 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; Tue, 21 Jan 2020 02:13:28 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 69B5124D3D1 for ; Mon, 20 Jan 2020 21:13:26 -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 qssTMawnuMvJ; Mon, 20 Jan 2020 21:13:26 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 0C13724D4A2; Mon, 20 Jan 2020 21:13:26 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 0C13724D4A2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1579572806; bh=HX4Rxf2G0YEus+t1Khz6yEpRDRLjA6AOuaiwl6QJgJY=; h=From:To:Date:Message-Id:MIME-Version; b=UgY5sdepr3QS1tXXGHQaKMz5K4DEaQJx6EgeUwA17mkhCgD+227xWx2dEI5eJXkjc 75dTEl8EYGA9MLkD4y8RPc649AwtrcVoJ77shNxj5R+EEB6gMxTf9x1ZtC3MUKFF23 /YzB8czp/1HAJKz3uYq4p3jmgZjVQCgGPTmwRkIOhoTIOg2M0bSSkdRWX0w5X22mQe SxouzmMpYUaZxrZQHYnMAjc9q2VwPJMT2SSCfA/qcTpvCVfmOQUQEbJvK7N68nH/02 A1gksOnC9nW4Y0iA8/DH2k0xfNdZRuleWH71B+p4FCGgKjD5OhLcycLH0FBn9HZfVr YKfG+bfywJuNA== 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 ixS0i6n5UQFu; Mon, 20 Jan 2020 21:13:25 -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 65A6424D4A1; Mon, 20 Jan 2020 21:13:25 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] gdb: remove uses of iterate_over_inferiors in remote-sim.c Date: Tue, 21 Jan 2020 02:14:00 -0000 Message-Id: <20200121021306.19200-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2020-01/txt/msg00619.txt.bz2 This removes the two uses of iterate_over_inferiors, in favor of range-based loops. gdb/ChangeLog: * remote-sim.c (check_for_duplicate_sim_descriptor): Remove. (get_sim_inferior_data): Remove use of iterate_over_inferiors, replace with range-based for. (gdbsim_interrupt_inferior): Change return type to void, remove unused parameter. (gdbsim_target::interrupt): Replace iterate_over_inferiors use with a range-based for. --- gdb/remote-sim.c | 69 +++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index caa94464e1eb..69fdabcb8bc5 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -189,21 +189,6 @@ static char **sim_argv =3D NULL; static host_callback gdb_callback; static int callbacks_initialized =3D 0; =20 -/* Callback for iterate_over_inferiors. It checks to see if the sim - descriptor passed via ARG is the same as that for the inferior - designated by INF. Return true if so; false otherwise. */ - -static int -check_for_duplicate_sim_descriptor (struct inferior *inf, void *arg) -{ - struct sim_inferior_data *sim_data; - SIM_DESC new_sim_desc =3D (SIM_DESC) arg; - - sim_data =3D sim_inferior_data_key.get (inf); - - return (sim_data !=3D NULL && sim_data->gdbsim_desc =3D=3D new_sim_desc); -} - /* Flags indicating whether or not a sim instance is needed. One of these flags should be passed to get_sim_inferior_data(). */ =20 @@ -225,27 +210,33 @@ get_sim_inferior_data (struct inferior *inf, int sim_= instance_needed) if (sim_instance_needed =3D=3D SIM_INSTANCE_NEEDED && (sim_data =3D=3D NULL || sim_data->gdbsim_desc =3D=3D NULL)) { - struct inferior *idup; sim_desc =3D sim_open (SIM_OPEN_DEBUG, &gdb_callback, exec_bfd, sim_= argv); if (sim_desc =3D=3D NULL) error (_("Unable to create simulator instance for inferior %d."), inf->num); =20 - idup =3D iterate_over_inferiors (check_for_duplicate_sim_descriptor, - sim_desc); - if (idup !=3D NULL) + /* Check if the sim descriptor is the same as that of another + inferior. */ + for (inferior *other_inf : all_inferiors ()) { - /* We don't close the descriptor due to the fact that it's - shared with some other inferior. If we were to close it, - that might needlessly muck up the other inferior. Of - course, it's possible that the damage has already been - done... Note that it *will* ultimately be closed during - cleanup of the other inferior. */ - sim_desc =3D NULL; - error ( - _("Inferior %d and inferior %d would have identical simulator state.\n" - "(This simulator does not support the running of more than one inferior= .)"), - inf->num, idup->num); + sim_inferior_data *other_sim_data + =3D sim_inferior_data_key.get (other_inf); + + if (other_sim_data !=3D NULL + && other_sim_data->gdbsim_desc =3D=3D sim_desc) + { + /* We don't close the descriptor due to the fact that it's + shared with some other inferior. If we were to close it, + that might needlessly muck up the other inferior. Of + course, it's possible that the damage has already been + done... Note that it *will* ultimately be closed during + cleanup of the other inferior. */ + sim_desc =3D NULL; + error ( +_("Inferior %d and inferior %d would have identical simulator state.\n" + "(This simulator does not support the running of more than one inferior.)= "), + inf->num, other_inf->num); + } } } =20 @@ -896,30 +887,24 @@ gdbsim_target::resume (ptid_t ptid, int step, enum gd= b_signal siggnal) =20 For simulators that do not support this operation, just abort. */ =20 -static int -gdbsim_interrupt_inferior (struct inferior *inf, void *arg) +static void +gdbsim_interrupt_inferior (struct inferior *inf) { struct sim_inferior_data *sim_data =3D get_sim_inferior_data (inf, SIM_INSTANCE_NEEDED); =20 - if (sim_data) + if (sim_data !=3D nullptr) { if (!sim_stop (sim_data->gdbsim_desc)) - { - quit (); - } + quit (); } - - /* When called from iterate_over_inferiors, a zero return causes the - iteration process to proceed until there are no more inferiors to - consider. */ - return 0; } =20 void gdbsim_target::interrupt () { - iterate_over_inferiors (gdbsim_interrupt_inferior, NULL); + for (inferior *inf : all_inferiors ()) + gdbsim_interrupt_inferior (inf); } =20 /* GDB version of os_poll_quit callback. --=20 2.25.0