From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 From: "aleksandar.paunovic" 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-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Mon, 07 Jun 2021 08:43:16 -0000 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