From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 1666A3858C2C for ; Wed, 28 Jun 2023 08:47:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1666A3858C2C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687942071; x=1719478071; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=1uKSOZ/98nFang/fjn7421jjXHe2vjlwwTypLnTo27g=; b=cJfwMq+5LsWpADa8mqFBxrhgXjgM4Rzmjj6p1onitAmOLHvuXLR065jv 4GNZ7M42+DbrzyYxxPI3MxU9j/7BAAKVnmeKfg+xp62Bn/roVqul8UBhy 2/w28Dhgmk2XAdn6Wl5Bi6jcG3Yeu3hrwweXEbC+AD7bQJcgUOdc0KmB9 ibB8hytEyTjJCX/LTVc8qAfmxGqDtSK+Difj7R93T2F9WLQDf2t9ceRmc zTCv/f3oD1SpjXDUl0C9UcWI6u9NSyW7rPpdmYn9H2x3qZJ1pCfNQXDpb MQUTdbo3LYhWZJ20qKgauvtj1pSAE9y0ZjXjPDsd0CRBWLEg01AdHUFit Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10754"; a="448174986" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="448174986" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 01:47:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10754"; a="1047310401" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="1047310401" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga005.fm.intel.com with ESMTP; 28 Jun 2023 01:47:50 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 28 Jun 2023 01:47:49 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 28 Jun 2023 01:47:48 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Wed, 28 Jun 2023 01:47:48 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.105) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Wed, 28 Jun 2023 01:47:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FnvX9Rg7Houwye6JY7DaNGSqu/0XNNaSF7rzdd9cKOrTkhwkHcnt4apMb6KtaC7QIVpTE9tnsd4d9QRUg2/VnPIdpuy5S9FeVjoZ4/NiN6eb8/lRHuIYEaYwuHJObntkz9Q3tEunmScB9oT/k6r7xzUnosMji7WDrSDNM2r21sXnnaIVU+GIgGhe6DzAMo2Y+gq5cQ+rC1L+yciPiQ4rv51w8dUhFMinbTcAC1AHTJT7rqUaHMHrAWkRW7o2P5eyM8Ba0jSG4l7kgriCHi4paRGkxgbfmUJRnJwbw0vv9AP27cXecacUd4mQb6HjofOyKg70Y/93yZ7a5Yu5zWBOdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KnQk9yEkvBtK9sNmZPEM/RXuFH1kmK9MVD1f9ZWK1+Q=; b=Cy92z5UJJU5asQBkKEBeZkjVL4ykRhrHxHmOGzLb9YvFM/k3TMOuuvFA0umS1KDpsVnHL5JOAih2pne0vmDZ+0MPN8p2Yvm6JchVqug8uOPwcZvZVyXQTC1ODK22aiwJQB6TC1iEFXc/Camu8pfDiKtyvzRY4I12MlqI7cMzwOvuuZZpt4uK2wUzWhsDf1hHZqL1P9Be/InIFygjp8ifTuyRQG3o7mFA9tCWKit/L6ecqYVVlcnRj/3TLlysvaBuWDus5I6J6bjbyObOVVqm+eeGnmeCdq9ufrNBYxiTrzN7V0FfrdU1y0/Ievms18lak/tL6E4WsEuIL5vJVwBYvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM4PR11MB7303.namprd11.prod.outlook.com (2603:10b6:8:108::21) by MW4PR11MB6787.namprd11.prod.outlook.com (2603:10b6:303:209::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Wed, 28 Jun 2023 08:47:46 +0000 Received: from DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::e57e:3584:99ad:d384]) by DM4PR11MB7303.namprd11.prod.outlook.com ([fe80::e57e:3584:99ad:d384%7]) with mapi id 15.20.6521.023; Wed, 28 Jun 2023 08:47:46 +0000 From: "Aktemur, Tankut Baris" To: Andrew Burgess , "gdb-patches@sourceware.org" CC: Mihails Strasuns , "Schimpe, Christina" Subject: RE: [PATCH 4/8] gdb, infrun: refactor part of `proceed` into separate function Thread-Topic: [PATCH 4/8] gdb, infrun: refactor part of `proceed` into separate function Thread-Index: AQHZpQwPopUqutVe80KGeJ8ZFJBkx6+f76vw Date: Wed, 28 Jun 2023 08:47:46 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR11MB7303:EE_|MW4PR11MB6787:EE_ x-ms-office365-filtering-correlation-id: b1cb758b-2916-46f8-030e-08db77b45852 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: q94Q2DNPJ67GtXQiFPfSpPCS/4K389RLwXIGlcPZAzznfbJqT8LEx4mXHnlMM7vULOI9AKNde2ZemO0sn7nSX79dkh379claBJE+RBxkAhh3c5fjZwR08CdGvvBQIpoBaaQ5YgAPaQWUUsvpwVrbW8M6azJT2jewSUPoh+bYGc+sPlQpkqInuIOjEl9J3FXTDXZ5i7yH2kE4becjfxLsIQgJ3QW9s/UjYTy1tk5u3OGmcocg9caPNdN+loWsMV4RKxJFfd0rfZ133B60lBKFsK9DJ93VBLWj9RThkNgroULLBcAczovC7N2y/mEnGVwHic37Qw1QaI9VbhD204+YyqBt9X5Xl46yQBPq7n+yJvB3gNNE4UAn38a1o5gggOeTFHxAxVodMQq5ij8m4ryfAk1fvPQMuc4tFzKGb6ivdzvjG1s1uUEWcC1jaAgzk7ggO1ZjI9YpEx5dgay7ZkrF6627vVWbdV4rMKdihcPgI6MvnofXoMM5H2nzim13vubT0Gqo3WdG9mdhiePQqov/XlpXQAuLrf2yVway3lWPZAqIKfi41NLoYJN4bdo7qF9pBbG+PewvcUritrIcKrPCI/k5oZ5DlEm+zWsm+DD6l82DQ/FS7eolszAtJMVXHninDFthXefSfGSIGTmhkgtTpQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB7303.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(376002)(136003)(366004)(39860400002)(396003)(451199021)(5660300002)(8676002)(110136005)(54906003)(38100700002)(82960400001)(122000001)(316002)(52536014)(41300700001)(107886003)(7696005)(8936002)(66476007)(71200400001)(64756008)(53546011)(26005)(9686003)(6506007)(186003)(66556008)(66946007)(76116006)(4326008)(66446008)(478600001)(2906002)(86362001)(83380400001)(33656002)(38070700005)(55016003)(81973001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Mg8u4HEV0tojpWh+xQD1MDlnZOVVl0JmDccFtL8AKe+tXrqPm7lzYIW7a6eD?= =?us-ascii?Q?NwGxinPNkKbE4fGZVR0Qh7Vp9ZFzeopqED7P51ECc79W3sxzpPQFSIp8DM1o?= =?us-ascii?Q?ZBj2I9ZRx25mfyCDVsaLFK07xHb5ZGE8Gxav+1Xh0TMmNxKk+JN7fY8E0CQ/?= =?us-ascii?Q?f51F3jOPxwa3cYGgwrxdHHStXyOT1Yz+VPitCqsq82bxdpxvVA2DqQd16sg1?= =?us-ascii?Q?bfmVgkeUpUjFwEGhQUWO/XFmbQ+t2G/3U0q+hh9WIo96I/NpZ/xHqeUdFJt7?= =?us-ascii?Q?cht+BxUPoxDl66EiLSkHvavsJw/jee1KUDSqulLQjHplOEK+/BVLg+X1gMhp?= =?us-ascii?Q?iLIb0aHcd09m7IY8THe+n9yaL43S5CbaOeacXv4feAFMIZPjCDOavYz60Hb0?= =?us-ascii?Q?6utTKGIVQ29ualgXenf+TXzYHAjt1MFV7fWsASoXcQ9t4Pvn3f5YxkgWaoD/?= =?us-ascii?Q?U235nVoEKA5iOJ71LJdTAaQhrj79lg0V94MocirmkLqua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VbZVTvMhIx62ywQNt7gqA2g0MFpgy1VJOmIUfJrYZn2xfaf5xA7?= =?us-ascii?Q?8GD+Glu+25gEfV8A7nrqsHlE0+w8pXTJWC1hSb3/dETiqFsuqFwNDbk3N3LW?= =?us-ascii?Q?qMyvHyYquILsptDdFE0pswvAk6Bz9vfm4WwWiT+gROwT0+jtrbaEQ4HiEz7E?= =?us-ascii?Q?y0MvZosmBa6Jm6/R4V/my2V/zmbd62D+MoMIBFruZ1tAUvnp1zw+wgM8Kylw?= =?us-ascii?Q?lA=3D=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB7303.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1cb758b-2916-46f8-030e-08db77b45852 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jun 2023 08:47:46.2047 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: vJc31WKG0bE0MaTmH4+lVCGDoKW9vxpTLOd9IqUGDyQG9MwpNzFjPuZROWk6IdMiIhGUeG59Y3ZTwsnbc0jbshBDpELOLV52qxbMeliqSzA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB6787 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thursday, June 22, 2023 3:17 PM, Andrew Burgess wrote: > From: Mihails Strasuns > = > Split the thread resuming code from proceed into new function > proceed_resume_thread_checked. > = > Co-Authored-By: Christina Schimpe > --- > gdb/infrun.c | 148 +++++++++++++++++++++++++++------------------------ > 1 file changed, 79 insertions(+), 69 deletions(-) > = > diff --git a/gdb/infrun.c b/gdb/infrun.c > index 5b0257076f0..b10b7c59652 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -3268,6 +3268,82 @@ check_multi_target_resumption (process_stratum_tar= get *resume_target) > } > } > = > +/* Helper function for `proceed`. Check if thread TP is suitable for > + resuming, and, if it is, switch to the thread and call > + `keep_going_pass_signal`. If TP is not suitable for resuming then th= is > + function will just return without switching threads. */ > + > +static void > +proceed_resume_thread_checked (thread_info *tp) > +{ > + if (!tp->inf->has_execution ()) > + { > + infrun_debug_printf ("[%s] target has no execution", > + tp->ptid.to_string ().c_str ()); > + return; > + } > + > + if (tp->resumed ()) > + { > + infrun_debug_printf ("[%s] resumed", > + tp->ptid.to_string ().c_str ()); > + gdb_assert (tp->executing () || tp->has_pending_waitstatus ()); > + return; > + } > + > + if (thread_is_in_step_over_chain (tp)) > + { > + infrun_debug_printf ("[%s] needs step-over", > + tp->ptid.to_string ().c_str ()); > + return; > + } > + > + /* When handling a vfork GDB removes all breakpoints from the program > + space in which the vfork is being handled, as such we must take care > + not to resume any thread other than the vfork parent -- resuming the > + vfork parent allows GDB to receive and handle the 'vfork done' > + event. */ > + if (tp->inf->thread_waiting_for_vfork_done !=3D nullptr) > + { > + if (target_is_non_stop_p ()) > + { > + /* For non-stop targets, regardless of whether GDB is using > + all-stop or non-stop mode, threads are controlled > + individually. > + > + When a thread is handling a vfork, breakpoints are removed > + from the inferior (well, program space in fact), so it is > + critical that we don't try to resume any thread other than the > + vfork parent. */ > + if (tp !=3D tp->inf->thread_waiting_for_vfork_done) > + { > + infrun_debug_printf ("[%s] thread %s of this inferior is " > + "waiting for vfork-done", > + tp->ptid.to_string ().c_str (), > + tp->inf->thread_waiting_for_vfork_done > + ->ptid.to_string ().c_str ()); > + return; > + } > + } > + else > + { > + /* For all-stop targets, when we attempt to resume the inferior, > + we will in fact only resume the vfork parent thread, this is > + handled in internal_resume_ptid, as such, there is nothing > + more that needs doing here. */ I wonder if here we should do gdb_assert (tp =3D=3D tp->inf->thread_waiting_for_vfork_done); -Baris > + } > + } > + > + infrun_debug_printf ("resuming %s", > + tp->ptid.to_string ().c_str ()); > + > + execution_control_state ecs (tp); > + switch_to_thread (tp); > + keep_going_pass_signal (&ecs); > + if (!ecs.wait_some_more) > + error (_("Command aborted.")); > +} > + > /* Basic routine for continuing the program in various fashions. > = > ADDR is the address to resume at, or -1 for resume where stopped. > @@ -3456,77 +3532,11 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) > resume_ptid)) > { > switch_to_thread_no_regs (tp); > - > - if (!tp->inf->has_execution ()) > - { > - infrun_debug_printf ("[%s] target has no execution", > - tp->ptid.to_string ().c_str ()); > - continue; > - } > - > - if (tp->resumed ()) > - { > - infrun_debug_printf ("[%s] resumed", > - tp->ptid.to_string ().c_str ()); > - gdb_assert (tp->executing () || tp->has_pending_waitstatus ()); > - continue; > - } > - > - if (thread_is_in_step_over_chain (tp)) > - { > - infrun_debug_printf ("[%s] needs step-over", > - tp->ptid.to_string ().c_str ()); > - continue; > - } > - > - /* If a thread of that inferior is waiting for a vfork-done > - (for a detached vfork child to exec or exit), breakpoints are > - removed. We must not resume any thread of that inferior, other > - than the one waiting for the vfork-done. */ > - if (tp->inf->thread_waiting_for_vfork_done !=3D nullptr > - && tp !=3D tp->inf->thread_waiting_for_vfork_done) > - { > - infrun_debug_printf ("[%s] another thread of this inferior is " > - "waiting for vfork-done", > - tp->ptid.to_string ().c_str ()); > - continue; > - } > - > - infrun_debug_printf ("resuming %s", > - tp->ptid.to_string ().c_str ()); > - > - execution_control_state ecs (tp); > - switch_to_thread (tp); > - keep_going_pass_signal (&ecs); > - if (!ecs.wait_some_more) > - error (_("Command aborted.")); > - } > - } > - else if (!cur_thr->resumed () > - && !thread_is_in_step_over_chain (cur_thr)) > - { > - /* In non-stop mode, if a there exists a thread waiting for a vfork > - then only allow that thread to resume (breakpoints are removed > - from an inferior when handling a vfork). > - > - We check target_is_non_stop_p here rather than just checking the > - non-stop flag, though these are equivalent (all-stop on a > - non-stop target was handled in a previous block, so at this > - point, if target_is_non_stop_p then GDB must be running on > - non-stop mode). By using target_is_non_stop_p it will be easier > - to merge this block with the previous in a later commit. */ > - if (!(target_is_non_stop_p () > - && cur_thr->inf->thread_waiting_for_vfork_done !=3D nullptr > - && cur_thr->inf->thread_waiting_for_vfork_done !=3D cur_thr)) > - { > - /* The thread wasn't started, and isn't queued, run it now. */ > - execution_control_state ecs (cur_thr); > - switch_to_thread (cur_thr); > - keep_going_pass_signal (&ecs); > - if (!ecs.wait_some_more) > - error (_("Command aborted.")); > + proceed_resume_thread_checked (tp); > } > } > + else > + proceed_resume_thread_checked (cur_thr); > = > disable_commit_resumed.reset_and_commit (); > } > -- > 2.25.4 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva = Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928