From patchwork Wed Mar 25 13:43:23 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Gerlicher X-Patchwork-Id: 132277 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id D7E584BB58F9 for ; Wed, 25 Mar 2026 13:45:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7E584BB58F9 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=SOTgDNUU X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by sourceware.org (Postfix) with ESMTPS id B8BCD4BB58C0 for ; Wed, 25 Mar 2026 13:43:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8BCD4BB58C0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B8BCD4BB58C0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774446231; cv=none; b=dUaFL5YRXPaF9lojQ9w++ioFlQtxQvi0r0TNMFw1LyX9f3ov5j4xYhb902PNxLU75WbqBHkhKIaSTEmNp08VjMhCBtTugdyWIK0zHlMbqHz2AZ9x+nMddyeHbKo42hzgEUlRoBWvVeBbL00813DjsDQ5Qd6felm/1rNc9hbDBHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774446231; c=relaxed/simple; bh=jygu2VMu/zZgdg9F5wgnKj5fGpNP3X3P+6Gw95VwjH8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=U24ji3cYAZ/n1WlNlbbkaRWzRHyWO9QDV/E2ObyjtWumUh3uhGY7ox/lZMgz7CMol/Q9rpeCb8r6HbJWX7ywbA0jhQ5LxRNeExgfiNyTWVjS53YmOirmspI3ZABgT/Badgyofq8HckmXz7HUGwq/cS5AGZd55Evku2PEoM/L4sc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8BCD4BB58C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774446231; x=1805982231; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=jygu2VMu/zZgdg9F5wgnKj5fGpNP3X3P+6Gw95VwjH8=; b=SOTgDNUUqkiboOFA1nOjXsg87HTlJYCWzT4mMYFG68MDKoD3nrFLqxgW jouVbOGJDNNwMoAzHjZiZA0tDuCcGDJQncvyb60DlCRLLXJMMG+v6Fsob fZOlzmoy2TWfH+UrPlqV6B0lBSOEPX6T/b5UWAVZtZ/0nzKLN3LdCqiss vd7uB9fcKculooFQ9Nn3KtE6o9LSwgD+6Er3Y/+mxmE8v/VlIXY4rsqr/ hC2izlchpZt6IJX8swJ/+v227AIHxK3xYu991oOAyvHHiScQov6564R2C 5R8B+ngD5J3imMF3TUdJCxGVWc6q7QcP5OzyN5RSZha365xXAetL31t3i g==; X-CSE-ConnectionGUID: opM/XnILR1GO2QLfSsixhA== X-CSE-MsgGUID: ZPgh5s+/SBW3meAA7BS6Fg== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="78080411" X-IronPort-AV: E=Sophos;i="6.23,140,1770624000"; d="scan'208";a="78080411" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2026 06:43:50 -0700 X-CSE-ConnectionGUID: XixieNQISZW/qVmrdSXySg== X-CSE-MsgGUID: adUC4V9TTVWMbc1vORekvw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,140,1770624000"; d="scan'208";a="223887687" Received: from dut1465dg2mrb.igk.intel.com (HELO localhost) ([10.211.180.13]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2026 06:43:49 -0700 From: Klaus Gerlicher To: gdb-patches@sourceware.org Subject: [PATCH v7 1/6] gdb: use schedlock_applies in user_visible_resume_ptid. Date: Wed, 25 Mar 2026 13:43:23 +0000 Message-Id: <20260325134328.550990-2-klaus.gerlicher@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260325134328.550990-1-klaus.gerlicher@intel.com> References: <20260325134328.550990-1-klaus.gerlicher@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_NONE, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org From: Natalia Saiapova This is a refactoring. The logic in user_visible_resume_ptid is very similar to schedlock_applies, but uses `step` and `record_will_replay` parameter instead of `tp->control.stepping_command`. Refactor schedlock_applies logic into the following two overloaded methods: bool schedlock_applies (thread_info *tp) and bool schedlock_applies (bool step, bool record_will_replay) such that they share the logic. Update the call-sites accordingly, where we have only the thread, use the former, and where we have the bool step or record_will_replay use the latter. Approved-By: Tom Tromey --- gdb/infrun.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 9864b5bbdec..ba57a82c83e 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -108,6 +108,7 @@ static bool start_step_over (void); static bool step_over_info_valid_p (void); static bool schedlock_applies (struct thread_info *tp); +static bool schedlock_applies (bool step, bool record_will_replay); /* Asynchronous signal handler registered as event loop source for when we have pending events ready to be passed to the core. */ @@ -2391,20 +2392,14 @@ user_visible_resume_ptid (int step) individually. */ resume_ptid = inferior_ptid; } - else if ((scheduler_mode == schedlock_on) - || (scheduler_mode == schedlock_step && step)) + else if (schedlock_applies (step, + target_record_will_replay (inferior_ptid, + execution_direction))) { /* User-settable 'scheduler' mode requires solo thread resume. */ resume_ptid = inferior_ptid; } - else if ((scheduler_mode == schedlock_replay) - && target_record_will_replay (inferior_ptid, execution_direction)) - { - /* User-settable 'scheduler' mode requires solo thread resume in replay - mode. */ - resume_ptid = inferior_ptid; - } else if (inferior_ptid != null_ptid && inferior_thread ()->control.in_cond_eval) { @@ -3193,17 +3188,32 @@ thread_still_needs_step_over (struct thread_info *tp) return what; } +/* Returns true if scheduler locking applies to TP. */ + +static bool +schedlock_applies (thread_info *tp) +{ + bool step = false; + bool record_will_replay = false; + if (tp != nullptr) + { + step = tp->control.stepping_command; + record_will_replay + = target_record_will_replay (tp->ptid, execution_direction); + } + return schedlock_applies (step, record_will_replay); +} + /* Returns true if scheduler locking applies. STEP indicates whether - we're about to do a step/next-like command to a thread. */ + we're about to do a step/next-like command and RECORD_WILL_REPLAY + indicates whether we're about to replay. */ static bool -schedlock_applies (struct thread_info *tp) +schedlock_applies (bool step, bool record_will_replay) { return (scheduler_mode == schedlock_on - || (scheduler_mode == schedlock_step - && tp->control.stepping_command) - || (scheduler_mode == schedlock_replay - && target_record_will_replay (tp->ptid, execution_direction))); + || (scheduler_mode == schedlock_step && step) + || (scheduler_mode == schedlock_replay && record_will_replay)); } /* When FORCE_P is false, set process_stratum_target::COMMIT_RESUMED_STATE