From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Vtt0BaIUYWpxkyYAWB0awg (envelope-from ) for ; Wed, 22 Jul 2026 15:06:10 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bB51OvdN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 01D1A1E09E; Wed, 22 Jul 2026 15:06:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 62DB01E033 for ; Wed, 22 Jul 2026 15:06:09 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53F2A4BA2E3A for ; Wed, 22 Jul 2026 19:06:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53F2A4BA2E3A Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bB51OvdN Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 1402E4BA2E0B for ; Wed, 22 Jul 2026 19:05:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1402E4BA2E0B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1402E4BA2E0B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784747142; cv=none; b=cRN1kc1Qgbh+UnEhCzTVXnA+6WH0Y5UwORcJZ53Wo5P8TDHo36mJIewFe74nmXPp2hJJzHiucM227ZJg0VUe3ioRaRwbNkWg4UHlJn+BUoyyY4H1ftCkgGbfRyfK13j64vDDcjOqc8A/CuupFaRobPJ8whtnowdbnP23eb+ibXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784747142; c=relaxed/simple; bh=NTdibmH/BGdG8GEwmsYAEPbvu6KUK9VupRTQ1FadUEg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t43Dk8kib8i6duG32ME9nEXR4tdUbfYODhli/WNzDz/Y/0hkJrVJQmd06G43f635mF5+M/owpTNimANujv0Vemtz2ONAXR97YczHGjeI0O+q8B7nNaqaKk5uQrcuXVU0jTLUfcBDsKjNptqizoluQSgi/hWcWH1e1b+PzigTUTM= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bB51OvdN DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1402E4BA2E0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784747141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ag3nMP3++ZWdmtSIkyp0ToYtBqLg7itEqLtWHzcQ2eE=; b=bB51OvdNbRosXKUiMiPsv8y0c7Kf+/rQ0113WU0uSAAI/QuvbNwrWYWaBzYuADndwXdtQz juEDcVWdY3F4M9S5lOGnxdSmoDyV5JDLAiugU7BHPFz5c3VmpYeAWsg+ygGzKncDwFgcWq Y00Qp86YaYGwXwlr+iIHLomUQi4etvQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-70-jiuRqObmP6asLUCQITnsog-1; Wed, 22 Jul 2026 15:05:40 -0400 X-MC-Unique: jiuRqObmP6asLUCQITnsog-1 X-Mimecast-MFC-AGG-ID: jiuRqObmP6asLUCQITnsog_1784747139 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4954c2d4081so55844545e9.2 for ; Wed, 22 Jul 2026 12:05:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784747139; x=1785351939; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Ag3nMP3++ZWdmtSIkyp0ToYtBqLg7itEqLtWHzcQ2eE=; b=SMaArPM+OA1scIPpQou7XVNPTfCOth+sG9thwYo459xPt+dDI+6eqB+uS8bflNgSgx 6gjvtLzB7xzXI4bXTmvj6ZyJZeVrZpa/vY5uxYuE3cNTwDBS9gKHZchxwOj7OpB3yFzT +gs2CbWRirIi2Q4LDUcEHP+eMT9h3EA7TEwUIy5ghFwTIydJ7RFO59JQqLPNtmBt7EaX uXMhWGyo6kWaBV5+MvXkZOXJi5hQoglWI8ovzSSbrrKCCEW3+Ht9rQiudaLrcGpOizh1 kPMizicSZEiG/LyvLP82H6aM1YvA6+7L2P3qLuqUAO2GZOx72yWZOHAGhfP0HpgCDUmM rXkA== X-Forwarded-Encrypted: i=1; AHgh+RpSbGeuPm61DwxONQ1QaKWoO4Y2073V3//s3UezDtuih3QtoA4nmmVQMCsZk9539ru7eNBUczpdo3aUfg==@sourceware.org X-Gm-Message-State: AOJu0Yy69qgnv9Q6SWpgV+ajPfe+QalCOs9TJqH9hs2CW+2GDwJ12KxO KCywDlx4sHdu3nsMJWacsRm6jyU/naH2MLYblWnah1eOnBln9bg8AONgd3dceBmehI/n+cPFcPn dLdzpmrrtjdLio8a9EuUZ7c7XxAIrnY86NNJwu8jNdFS0OaN9eZ7pWU+TYKCdvls= X-Gm-Gg: AR+sD11ORE3CtIhDnJ62o8e/1xpmUZ1Dd+TsKw0usSI9j4tS4Uz3mmyFIxfwkLNHGDK cMoQdBlr7cioVpSCJ3cyK0LtKqbnFBUfDNOECCT1Nsh0DhCK1eFl2LOql7xNIibaJvn2CtV3XZh qa1q6rQVNrv4lkRlznUN234IXvNWv8s4WAHBAE1oeua19U5H/DP6D3oVPBGatH7hZEM+cRQslQf 4OsTDK0dtmIjY9Ba9bhqF76ai4en/tQhlqGxyQk4splECtAfqeUpkkH7KneBSTplvem5XNdu6u1 zujffAraxVI9Nvi7MNxt3Riyz8Ne+DYiIS8tAzHZSQvKWD/WZFL2gyLxbfl+1lLWfIMgNI1ESBi hAWA8sibk7NiliqhikkVtm0MH X-Received: by 2002:a05:600c:310d:b0:495:3f84:a792 with SMTP id 5b1f17b1804b1-49573cc703bmr72775e9.12.1784747139087; Wed, 22 Jul 2026 12:05:39 -0700 (PDT) X-Received: by 2002:a05:600c:310d:b0:495:3f84:a792 with SMTP id 5b1f17b1804b1-49573cc703bmr72355e9.12.1784747138649; Wed, 22 Jul 2026 12:05:38 -0700 (PDT) Received: from localhost (92.40.185.176.threembb.co.uk. [92.40.185.176]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4956b5c2108sm132571705e9.2.2026.07.22.12.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 12:05:38 -0700 (PDT) From: Andrew Burgess To: Klaus Gerlicher , gdb-patches@sourceware.org Cc: tom@tromey.com, guinevere@redhat.com, eliz@gnu.org Subject: Re: [PATCH v8 1/6] gdb: use schedlock_applies in user_visible_resume_ptid. In-Reply-To: <20260722102746.131536-2-klaus.gerlicher@intel.com> References: <20260722102746.131536-1-klaus.gerlicher@intel.com> <20260722102746.131536-2-klaus.gerlicher@intel.com> Date: Wed, 22 Jul 2026 20:05:35 +0100 Message-ID: <875x26q1z4.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zIVw0kYDA3CxSc7RZaoiovJW9s-Sg7A9rZTWCDq29Aw_1784747139 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Klaus Gerlicher writes: > 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 c0767e7f764..ace34507cfe 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); You dropped the 'struct' from the definition of this function. As you're changing the next line anyway, maybe drop the 'struct' here too? > +static bool schedlock_applies (bool step, bool record_will_replay); > > static void handle_process_exited (struct execution_control_state *ecs); > > @@ -2442,20 +2443,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) > { > @@ -3246,17 +3241,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); > +} As far as I can tell the old code didn't have the 'tp != nullptr' check, and I think every call site already makes the assumption that tp is not NULL (i.e. if it was NULL GDB would have already crashed). I think you should just update the comment on this function to say: "...applies to non-NULL thread TP." and add 'gdb_assert (tp != nullptr);' to the function body. With that, it looks good. Approved-By: Andrew Burgess Thanks, Andrew