From patchwork Fri Feb 7 12:04:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aktemur, Tankut Baris" X-Patchwork-Id: 37724 Received: (qmail 121193 invoked by alias); 7 Feb 2020 12:04:33 -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 121180 invoked by uid 89); 7 Feb 2020 12:04:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=H*i:sk:cover.1, H*MI:sk:cover.1, H*r:LOCAL X-HELO: mga06.intel.com Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Feb 2020 12:04:31 +0000 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Feb 2020 04:04:29 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga005.fm.intel.com with ESMTP; 07 Feb 2020 04:04:28 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 017C4RL7021927; Fri, 7 Feb 2020 12:04:27 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 017C4Rm9006487; Fri, 7 Feb 2020 13:04:27 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 017C4R1t006483; Fri, 7 Feb 2020 13:04:27 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Cc: palves@redhat.com, tdevries@suse.de Subject: [PATCH v4 1/2] gdb/infrun: extract out a code piece into 'mark_non_executing_threads' function Date: Fri, 7 Feb 2020 13:04:11 +0100 Message-Id: <045986ee4a5dc229807a5c6a4fe574467e2f0d91.1581065751.git.tankut.baris.aktemur@intel.com> In-Reply-To: <9512ee17-66dc-3463-4735-b1907bca34c6@redhat.com> References: <9512ee17-66dc-3463-4735-b1907bca34c6@redhat.com> In-Reply-To: References: X-IsSubscribed: yes This is a refactoring. The extracted function is placed deliberately before 'stop_all_threads' because the function will be re-used there in a subsequent patch for handling an exit status kind received from a thread that GDB attempted to stop. gdb/ChangeLog: 2019-11-04 Tankut Baris Aktemur * infrun.c (handle_inferior_event): Extract out a piece of code into... (mark_non_executing_threads): ...this new function. Change-Id: I2b088f4a724f4260cb37068264964525cf62a118 --- gdb/infrun.c | 77 ++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index fd72a744339..9224376d05e 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -4673,6 +4673,47 @@ save_waitstatus (struct thread_info *tp, const target_waitstatus *ws) } } +/* Mark the non-executing threads accordingly. In all-stop, all + threads of all processes are stopped when we get any event + reported. In non-stop mode, only the event thread stops. */ + +static void +mark_non_executing_threads (process_stratum_target *target, + ptid_t event_ptid, + struct target_waitstatus ws) +{ + ptid_t mark_ptid; + + if (!target_is_non_stop_p ()) + mark_ptid = minus_one_ptid; + else if (ws.kind == TARGET_WAITKIND_SIGNALLED + || ws.kind == TARGET_WAITKIND_EXITED) + { + /* If we're handling a process exit in non-stop mode, even + though threads haven't been deleted yet, one would think + that there is nothing to do, as threads of the dead process + will be soon deleted, and threads of any other process were + left running. However, on some targets, threads survive a + process exit event. E.g., for the "checkpoint" command, + when the current checkpoint/fork exits, linux-fork.c + automatically switches to another fork from within + target_mourn_inferior, by associating the same + inferior/thread to another fork. We haven't mourned yet at + this point, but we must mark any threads left in the + process as not-executing so that finish_thread_state marks + them stopped (in the user's perspective) if/when we present + the stop to the user. */ + mark_ptid = ptid_t (event_ptid.pid ()); + } + else + mark_ptid = event_ptid; + + set_executing (target, mark_ptid, false); + + /* Likewise the resumed flag. */ + set_resumed (target, mark_ptid, false); +} + /* See infrun.h. */ void @@ -5107,41 +5148,7 @@ handle_inferior_event (struct execution_control_state *ecs) } } - /* Mark the non-executing threads accordingly. In all-stop, all - threads of all processes are stopped when we get any event - reported. In non-stop mode, only the event thread stops. */ - { - ptid_t mark_ptid; - - if (!target_is_non_stop_p ()) - mark_ptid = minus_one_ptid; - else if (ecs->ws.kind == TARGET_WAITKIND_SIGNALLED - || ecs->ws.kind == TARGET_WAITKIND_EXITED) - { - /* If we're handling a process exit in non-stop mode, even - though threads haven't been deleted yet, one would think - that there is nothing to do, as threads of the dead process - will be soon deleted, and threads of any other process were - left running. However, on some targets, threads survive a - process exit event. E.g., for the "checkpoint" command, - when the current checkpoint/fork exits, linux-fork.c - automatically switches to another fork from within - target_mourn_inferior, by associating the same - inferior/thread to another fork. We haven't mourned yet at - this point, but we must mark any threads left in the - process as not-executing so that finish_thread_state marks - them stopped (in the user's perspective) if/when we present - the stop to the user. */ - mark_ptid = ptid_t (ecs->ptid.pid ()); - } - else - mark_ptid = ecs->ptid; - - set_executing (ecs->target, mark_ptid, false); - - /* Likewise the resumed flag. */ - set_resumed (ecs->target, mark_ptid, false); - } + mark_non_executing_threads (ecs->target, ecs->ptid, ecs->ws); switch (ecs->ws.kind) {