From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +GRPDVXcvWD1GwAAWB0awg (envelope-from ) for ; Mon, 07 Jun 2021 04:44:05 -0400 Received: by simark.ca (Postfix, from userid 112) id 345961F163; Mon, 7 Jun 2021 04:44:05 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 73D231E813 for ; Mon, 7 Jun 2021 04:44:04 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 31CCC383B83B for ; Mon, 7 Jun 2021 08:44:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31CCC383B83B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623055444; bh=Zs8fowKOLgkiPFK6Pm0JtUG+XPjdMgWR6y3XO130bJQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=aA4DlxXU30LcTkEb63RLfnk+vSlzJJUqsHjWqVumDN/8eAFta/PSJXqwd3W3Q/wmK X0crtWDLTKkt1nP4gX12mrBPTZNC6cQ3QUnuziUCGl69oRZpIqzPmGSpMwvFMpGOEP +yjOPMqfy05aEQRaXi1q9s/+9/uotiHH2qYV3q9k= Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id 5FC89383B42D for ; Mon, 7 Jun 2021 08:43:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5FC89383B42D IronPort-SDR: /Ko945FacOpewXtBrJZbkMGjY2spB8UUQeL3Vbpl6tiVANd27xhvH5V6PESyfy+cvMBWLFZr9Z TxmddW/GkREQ== X-IronPort-AV: E=McAfee;i="6200,9189,10007"; a="268441354" X-IronPort-AV: E=Sophos;i="5.83,254,1616482800"; d="scan'208";a="268441354" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2021 01:43:03 -0700 IronPort-SDR: t9x2nWYl9IjQSZW31lVCHRNbIGdCMRwR+IethSNqcuwwGFWD6wOEz0PKITnLszTv8IyoE67ak/ vsZlE1wpF42A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,254,1616482800"; d="scan'208";a="447408821" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga008.jf.intel.com with ESMTP; 07 Jun 2021 01:43:02 -0700 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 1578h2sW027318; Mon, 7 Jun 2021 09:43:02 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 1578h2tS003634; Mon, 7 Jun 2021 10:43:02 +0200 Received: (from apaunovi@localhost) by ulvlx001.iul.intel.com with LOCAL id 1578h1R8003630; Mon, 7 Jun 2021 10:43:01 +0200 To: gdb-patches@sourceware.org Subject: [PATCH 2/2] gdb: Improve the resuming of the stepped thread Date: Mon, 7 Jun 2021 10:42:03 +0200 Message-Id: <1623055323-3331-3-git-send-email-aleksandar.paunovic@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1623055323-3331-1-git-send-email-aleksandar.paunovic@intel.com> References: <1623055323-3331-1-git-send-email-aleksandar.paunovic@intel.com> X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: "aleksandar.paunovic via Gdb-patches" Reply-To: "aleksandar.paunovic" Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" From: Aleksandar Paunovic Stepped thread should not be resumed (again) if the next stopping point (next stopping PC) cannot be determined. Do not resume the stepped thread in this case. Resuming would lead to an inconsistent state where the stepped thread would be running forever and GDB would never get to breakpoints of the other threads. */ gdb/ChangeLog: 2021-04-30 Aleksandar Paunovic * infrun.c (keep_going_stepped_thread): Do not resume an already executing thread. gdb/testsuite/ChangeLog: 2021-04-30 Aleksandar Paunovic * gdb.base/breakpoint-running-inferior.exp: Add a start_step function check. 2021-06-07 Aleksandar Paunovic --- gdb/infrun.c | 15 ++++++++++++++- .../gdb.base/breakpoint-running-inferior.exp | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 78da1f0e72..459a679ee6 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -7529,7 +7529,7 @@ restart_after_all_stop_detach (process_stratum_target *proc_target) /* Set a previously stepped thread back to stepping. Returns true on success, false if the resume is not possible (e.g., the thread - vanished). */ + vanished, or the thread breakpoint position cannot be determined). */ static bool keep_going_stepped_thread (struct thread_info *tp) @@ -7566,6 +7566,19 @@ keep_going_stepped_thread (struct thread_info *tp) delete_thread (tp); return false; } + /* Step start function determines the location of the next stopping + point (next PC where the stepped thread should stop). In case that + this position cannot be determined the step_start_function will not + be set. Do not resume the stepped thread in this case. Resuming + would lead to an inconsistent state where the stepped thread would be + running forever and GDB would never get to breakpoints of the other + threads. */ + if (tp->control.step_start_function == nullptr) + { + infrun_debug_printf ("not resuming previously stepped thread, it is " + "already executing"); + return 0; + } infrun_debug_printf ("resuming previously stepped thread"); diff --git a/gdb/testsuite/gdb.base/breakpoint-running-inferior.exp b/gdb/testsuite/gdb.base/breakpoint-running-inferior.exp index bb0406bc65..b95f2ec012 100644 --- a/gdb/testsuite/gdb.base/breakpoint-running-inferior.exp +++ b/gdb/testsuite/gdb.base/breakpoint-running-inferior.exp @@ -74,10 +74,15 @@ gdb_test "next" ".*Thread 2.*hit Breakpoint.*" "next while in inferior 1" # We should be able to normally switch to thread 1.1. # In case of a bad GDB flow the GDB was losing the thread. +# The thread should also not be in a "running" state because it is +# stopped. gdb_test_multiple "thread 1.1" "Switching to thread 1.1" { -re "\\\[Switching to thread 1.1 \\(Thread .*\\)\\\]" { pass $gdb_test_name } + -re "\\\[Switching to thread 1.1.*\\(running\\)" { + fail $gdb_test_name + } -re ".*Thread ID 1.1 has terminated.*" { fail $gdb_test_name } -- 2.17.1