From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KAgjLzPMi2KG5wcAWB0awg (envelope-from ) for ; Mon, 23 May 2022 14:02:27 -0400 Received: by simark.ca (Postfix, from userid 112) id BE20A1E220; Mon, 23 May 2022 14:02:27 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=R6GDzJvH; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 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 529301E143 for ; Mon, 23 May 2022 14:02:27 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 03BDA38425BC for ; Mon, 23 May 2022 18:02:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03BDA38425BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1653328947; bh=GOkZBZRf5ga5PykWrbQItypVnUbyeXZsQz42AKjBcps=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=R6GDzJvH5nqCx8G2Damytfd2Y7OYz+lHYX9g3jJ0BrBQwYMX+VPD1hkKCWdy/hboU ASJNiV9lzpioBz7xTx2NN3ma/7vtDi9jpahgEelYy/p+dm1YRGorldRf6PHvra6SXe +1CwSd4qB+AFlGaN+br0AdVSQJ8DNsNCfZCBrQmY= Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 1D21A385801E for ; Mon, 23 May 2022 18:01:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D21A385801E X-IronPort-AV: E=McAfee;i="6400,9594,10356"; a="359704111" X-IronPort-AV: E=Sophos;i="5.91,246,1647327600"; d="scan'208";a="359704111" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2022 11:01:31 -0700 X-IronPort-AV: E=Sophos;i="5.91,246,1647327600"; d="scan'208";a="744859026" Received: from labpcdell3650-001.iul.intel.com (HELO localhost) ([172.28.50.74]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2022 11:01:30 -0700 To: gdb-patches@sourceware.org Subject: [PATCH 2/2] gdb: Improve the resuming of the stepped thread Date: Mon, 23 May 2022 20:00:56 +0200 Message-Id: <20220523180056.1415229-3-eduard.sargsyan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220523180056.1415229-1-eduard.sargsyan@intel.com> References: <20220523180056.1415229-1-eduard.sargsyan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: Eduard Sargsyan via Gdb-patches Reply-To: Eduard Sargsyan Cc: 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. Signed-off-by: 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 d794f135219..2d777610a37 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -7472,7 +7472,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) @@ -7509,6 +7509,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 bb0406bc659..b95f2ec0122 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.25.1