From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iX35GSdMg2l6ICgAWB0awg (envelope-from ) for ; Wed, 04 Feb 2026 08:39:51 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Xa6zNC8p; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 60E6A1E0BA; Wed, 04 Feb 2026 08:39:51 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED,RDNS_NONE autolearn=no autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (unknown [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A44BF1E08D for ; Wed, 04 Feb 2026 08:39:50 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 357AD4BA23C0 for ; Wed, 4 Feb 2026 13:39:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 357AD4BA23C0 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Xa6zNC8p Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by sourceware.org (Postfix) with ESMTPS id 5BED94BA2E24 for ; Wed, 4 Feb 2026 13:38:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5BED94BA2E24 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 5BED94BA2E24 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770212316; cv=none; b=NN8qnLhqtOoKjP9SrnFaOaBBsi97eDwfbSjSsvNYLsLMEE6LMfsbo49leEmt8qP2pqAZ7TEEDjX3KyAMCPIprrdgjAvvljPYKi+XmXszGYyOCJljEt/tTH5LDOJURIO1Sj1FmnN+wDkpNrEgn6C9WfQi5arpZGzk+h1yzX/mHVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770212316; c=relaxed/simple; bh=HvbRBcYTsgkR8A51qoqtmzgpnsJMM8ampL9BestqB8U=; h=DKIM-Signature:MIME-Version:From:To:Subject:Date:Message-Id: MIME-Version; b=tJVfUOwZPINK7hZo6eIAPzDidwrgxPRZQkDmYluew9T3+TCBw90wGNgTEjto+60jrciaxz+tTR0q5ERVMysQJvOh20wmr+OUqhRiMpfCKnd51QntULtsSya5Zw8XiCbj23la7ofZLanDRvnJPgY89F092Be5qVOx6RAsWdXei+Q= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5BED94BA2E24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770212316; x=1801748316; h=from:to:subject:date:message-id:in-reply-to:references; bh=HvbRBcYTsgkR8A51qoqtmzgpnsJMM8ampL9BestqB8U=; b=Xa6zNC8p1XRcJiJWBTXvl512XOXgye2Vcz11KyrpNTUKsiWzfSUNk5Pe VgWnLZIqOyNAY3bofY+o7GRg/3kyJNgB6VvBUZZdApvdipzGz78OW32XM SuQ/jDp0t9wfw71Wlkn1CmIt0whI0YiIKS6z56wWz4Su5RL57vVYdAUQH 1U1JX2Kizdpc3JuaA7AcieAxroJkZj8Ty0C6zvMB2nV/OAds4X9vCGBdQ nuIOlooDPEmcTnL39agalMsD11SKvK11wPj4AhwMukrnl4q75WW5BxRv8 U7ZVaBf9ia99Gg8EUSpkr4Pd4TuyM1Bxx26mvmAtRGmEApYzOmL6ffV+P w==; X-CSE-ConnectionGUID: PhFrqkfxTgKMGWTFwfoqpw== X-CSE-MsgGUID: sje5CIRwRBajIhLZywUCsA== X-IronPort-AV: E=McAfee;i="6800,10657,11691"; a="82831924" X-IronPort-AV: E=Sophos;i="6.21,272,1763452800"; d="scan'208";a="82831924" Content-Type: multipart/mixed; boundary="===============8392640710663515492==" MIME-Version: 1.0 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Feb 2026 05:38:36 -0800 X-CSE-ConnectionGUID: lgt0yWyDSS6K2rYvqrd/uQ== X-CSE-MsgGUID: Z9praVsETLWJhcc73MAzQw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,272,1763452800"; d="scan'208";a="209460510" Received: from dut1865dg2frd.igk.intel.com (HELO localhost) ([10.211.179.243]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Feb 2026 05:38:36 -0800 From: Klaus Gerlicher To: gdb-patches@sourceware.org Subject: [PATCH v6 4/6] gdb: change the internal representation of scheduler locking. Date: Wed, 4 Feb 2026 13:37:51 +0000 Message-Id: <20260204133753.547281-5-klaus.gerlicher@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260204133753.547281-1-klaus.gerlicher@intel.com> References: <20260204133753.547281-1-klaus.gerlicher@intel.com> MIME-Version: 1.0 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~public-inbox=simark.ca@sourceware.org --===============8392640710663515492== Content-Transfer-Encoding: 8bit From: Natalia Saiapova Introduce a new structure to manage different options of the scheduler locking. The options can coexist together and be set individually. In the next patch gdb: refine commands to control scheduler locking. we introduce the commands to control these options. In this patch we do not introduce new commands and keep the previous API. New scheduler locking options are: replay continue -- control continuing commands during replay mode. replay step -- control stepping commands during replay mode. continue -- control continuing commands during normal execution. step -- control stepping commands during normal execution. Internally they hold a bool value, when true the locking is enabled. Mapping to the old settings Old Settings | New settings ----------------------------------- off | all are false | replay | continue = false, step = false, | replay continue = true, replay step = true | step | continue = false, step = true, | replay continue = false, replay step = true | on | all are true --- gdb/infrun.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 134 insertions(+), 13 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index ba360570d48..f449b222fc3 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -106,8 +106,12 @@ 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); +struct schedlock_options; +static bool schedlock_applies (thread_info *tp); +static bool schedlock_applies (bool step, + bool record_will_replay, + thread_info *tp = nullptr); +static bool schedlock_applies_to_opts (const schedlock_options &, bool step); /* Asynchronous signal handler registered as event loop source for when we have pending events ready to be passed to the core. */ @@ -2321,7 +2325,69 @@ infrun_thread_ptid_changed (process_stratum_target *target, inferior_ptid = new_ptid; } - +/* A structure to hold scheduler locking settings for + a mode, replay or normal. */ +struct schedlock_options +{ + struct option { + const std::string name; + bool value; + + option () = delete; + option (std::string name, bool value) + : name (std::move (name)), value (value) + {} + + /* Forbid accidential copying. */ + option (const option &) = delete; + option operator= (const option &) = delete; + option (option &&) = default; + option &operator= (option &&) = default; + + operator bool () const { return value; } + const char *c_str () const { return value ? "on" : "off"; } + /* Set new value. Return true, if the value has changed. */ + bool set (bool new_value); + }; + + schedlock_options () = delete; + schedlock_options (option cont, option step) + : cont (std::move (cont)), step (std::move (step)) + {} + + /* Forbid accidential copying. */ + schedlock_options (const schedlock_options &) = delete; + schedlock_options operator= (const schedlock_options &) = delete; + schedlock_options (schedlock_options &&) = default; + schedlock_options &operator= (schedlock_options &&) = default; + + /* If true, the scheduler is locked during continuing. */ + option cont; + /* If true, the scheduler is locked during stepping. */ + option step; +}; + +bool +schedlock_options::option::set (bool new_value) +{ + if (value != new_value) + { + value = new_value; + return true; + } + + return false; +} + +struct schedlock +{ + schedlock (schedlock_options opt, schedlock_options replay_opt) + : normal (std::move (opt)), replay (std::move (replay_opt)) + {} + + schedlock_options normal; + schedlock_options replay; +}; static const char schedlock_off[] = "off"; static const char schedlock_on[] = "on"; @@ -2334,7 +2400,42 @@ static const char *const scheduler_enums[] = { schedlock_replay, nullptr }; + static const char *scheduler_mode = schedlock_replay; + +schedlock schedlock { + { + {"cont", false}, + {"step", false} + }, + { + {"replay cont", true}, + {"replay step", true} + } +}; + +/* A helper function to set scheduler locking shortcuts: + set scheduler-locking on: all options are on. + set scheduler-locking off: all options are off. + set scheduler-locking replay: only replay options are on. + set scheduler-locking step: only "step" and "replay step" are on. */ + +static void +set_schedlock_shortcut_option (const char *shortcut) +{ + bool is_on = (shortcut == schedlock_on); + bool is_step = (shortcut == schedlock_step); + bool is_replay = (shortcut == schedlock_replay); + bool is_off = (shortcut == schedlock_off); + /* Check that we got a valid shortcut option. */ + gdb_assert (is_on || is_step || is_replay || is_off); + + schedlock.normal.cont.set (is_on); + schedlock.normal.step.set (is_on || is_step); + schedlock.replay.cont.set (is_on || is_replay); + schedlock.replay.step.set (is_on || is_replay || is_step); +} + static void show_scheduler_mode (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) @@ -2351,9 +2452,13 @@ set_schedlock_func (const char *args, int from_tty, struct cmd_list_element *c) if (!target_can_lock_scheduler ()) { scheduler_mode = schedlock_off; + /* Set scheduler locking off. */ + set_schedlock_shortcut_option (schedlock_off); error (_("Target '%s' cannot support this command."), target_shortname ()); } + + set_schedlock_shortcut_option (scheduler_mode); } /* True if execution commands resume all threads of all processes by @@ -2384,6 +2489,10 @@ ptid_t user_visible_resume_ptid (int step) { ptid_t resume_ptid; + thread_info *tp = nullptr; + + if (inferior_ptid != null_ptid) + tp = inferior_thread (); if (non_stop) { @@ -2393,14 +2502,14 @@ user_visible_resume_ptid (int step) } else if (schedlock_applies (step, target_record_will_replay (inferior_ptid, - execution_direction))) + execution_direction), + tp)) { /* User-settable 'scheduler' mode requires solo thread resume. */ resume_ptid = inferior_ptid; } - else if (inferior_ptid != null_ptid - && inferior_thread ()->control.in_cond_eval) + else if (tp != nullptr && tp->control.in_cond_eval) { /* The inferior thread is evaluating a BP condition. Other threads might be stopped or running and we do not want to change their @@ -3111,8 +3220,9 @@ clear_proceed_status (int step) This is a convenience feature to not require the user to explicitly stop replaying the other threads. We're assuming that the user's intent is to resume tracing the recorded process. */ - if (!non_stop && scheduler_mode == schedlock_replay - && !target_record_will_replay (inferior_ptid, execution_direction)) + if (!non_stop && schedlock_applies_to_opts (schedlock.replay, step) + && !target_record_will_replay (inferior_ptid, + execution_direction)) target_record_stop_replaying (); if (!non_stop && inferior_ptid != null_ptid) @@ -3186,6 +3296,17 @@ thread_still_needs_step_over (struct thread_info *tp) return what; } +/* Return true if OPTS lock the scheduler. + STEP indicates whether a thread is about to step. + Note, this does not take into the account the mode (replay or + normal execution). */ + +static bool +schedlock_applies_to_opts (const schedlock_options &opts, bool step) +{ + return ((opts.cont && !step) || (opts.step && step)); +} + /* Returns true if scheduler locking applies to TP. */ static bool @@ -3199,7 +3320,7 @@ schedlock_applies (thread_info *tp) record_will_replay = target_record_will_replay (tp->ptid, execution_direction); } - return schedlock_applies (step, record_will_replay); + return schedlock_applies (step, record_will_replay, tp); } /* Returns true if scheduler locking applies. STEP indicates whether @@ -3207,11 +3328,11 @@ schedlock_applies (thread_info *tp) indicates whether we're about to replay. */ static bool -schedlock_applies (bool step, bool record_will_replay) +schedlock_applies (bool step, bool record_will_replay, thread_info *tp) { - return (scheduler_mode == schedlock_on - || (scheduler_mode == schedlock_step && step) - || (scheduler_mode == schedlock_replay && record_will_replay)); + schedlock_options &opts + = record_will_replay ? schedlock.replay : schedlock.normal; + return schedlock_applies_to_opts (opts, step); } /* When FORCE_P is false, set process_stratum_target::COMMIT_RESUMED_STATE -- 2.34.1 --===============8392640710663515492== Content-Type: multipart/alternative; boundary="===============2424779150997889930==" MIME-Version: 1.0 Content-Disposition: inline --===============2424779150997889930== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Intel Deutschland GmbH Registered Address: Dornacher Stra=C3=9Fe 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht M=C3=BCnchen HRB 186928 --===============2424779150997889930== Content-Type: text/html; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable

Intel Deutschland GmbH

Registered Ad= dress: Dornacher Stra=C3=9Fe 1, 85622 Feldkirchen, Germany
Tel: +49 89 = 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneide= rman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole La= u
Registered Seat: Munich
Commercial Register: Amtsgericht M=C3=BCn= chen HRB 186928

--===============2424779150997889930==-- --===============8392640710663515492==--