From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UnTIIBVqzml8+QMAWB0awg (envelope-from ) for ; Thu, 02 Apr 2026 09:07:33 -0400 Received: by simark.ca (Postfix, from userid 112) id 705D81E0BC; Thu, 02 Apr 2026 09:07:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [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 9FA0C1E04F for ; Thu, 02 Apr 2026 09:07:32 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 52F594BA2E23 for ; Thu, 2 Apr 2026 13:07:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52F594BA2E23 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by sourceware.org (Postfix) with ESMTPS id 46CAD4BA2E23 for ; Thu, 2 Apr 2026 13:07:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46CAD4BA2E23 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 46CAD4BA2E23 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775135226; cv=none; b=JJMyuw8ErV7BkZ3jwr/IFEcQ27nNZ1Jq4c/xhDU3gxPF7rvDcQiQ+cGTPac6erHodm6xR7iI8nq+/cDlhYUUaRQqwdIDsKQY80wSckOlu0p17C+Aha0WVvwMSdKNXQ5XZEQCJld0GJJdY9+kaRH/Bn7Cdk6919VqIZNIxQRiVn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775135226; c=relaxed/simple; bh=a1zFyNb6SXPVK/ZWG/PYuFh1UUES2XJ+STpOijaGmmk=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=VUrbcLRdesMC4O8OuQr3r1IV9YXgsKHi6DyUwzXNArRU5USQQMJSxSDumon3TFaTV2eGBz9KvtHZ84pnIDVaEVNuzmxy3vQdsTZMdoK7uGWfzLg/F0jriZw4mOZMsAcbo9lLEgfytizOo/vhAmyGHCSmkihp8/Sr2vOCzFSu4ms= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46CAD4BA2E23 Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-43cfa33a983so580183f8f.1 for ; Thu, 02 Apr 2026 06:07:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775135225; x=1775740025; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0Osue6OGwkOYtD3vA7vmLZcDJZ7z+tkWg2H645nSqsA=; b=UX6wimbX0BY+BCJ6726L3f9Ow6LdvdvkUfjlFAHAtkQITe6Ufoqmly+8HHryW/06Ud mdFlBJHiCf8dOXgsWbV9I90753YIKwItGqMvvNTwp6IWTyGSMcMYFRFS3Bpg9HAZzZhQ 1j2Aje+ryLBbY8c7WlJiUzROOxQn5q4iLv1hEIwZkt3lX9zpVsYo740KfNaX0OT24/ZE cgnBarPOQsLFmgCZFq8rgD7LAs9eq23LrHSJZKjpJzM8de6bBb6rToswwmmn2Pd0hggJ jNEuFSoBLx7ylykVrgUZbkVlnIKUHrPhaQrFufb/SC3r5cjkEhqh4RwUoP08kAHhio2n cr3A== X-Gm-Message-State: AOJu0YwaktSY0ADlvkfKy9qepJpm6MOaECgC4vK8wj3fdFU5qCY6zyA1 QMFLWP7VAe6NMWGrEedTSSuTj4BCGp8KyE+MeB0b0M97kDy9/BDdVvsIUzGZ804i X-Gm-Gg: AeBDiessyBIaIvzrW49FbDii4LOFJIFJiYJR+vPKDyQ3j/6WPYcwGYYeEx91qepBKAt kYMrlEX4X5IUYYTiI7jBTDDDBb9KOgsOy+NqHyrDoWs3vlc7mcRwP7n3D2xqVYr8ij6P0qLSrB+ a62izVjQLf9CC3UmsLC9G1dVIWJX8RRFnLO3rb3QyRHi90OKyhbU69Q+3uCsytsizqhFe/HKHA2 e4YM41X/BYxRcoffrAnDd8t8n8w3E28g482WW0y/tJORsakS6YxrOiGrQ1aFg69odcD46c6ZIKg wNymUTQoDMrUkyUFM/mL0UnGEBXgwPZZtLBqcAHaTkkoNJvmMzoOopikkXkOVECqzCyUkCKarUO GRtgLq9Q2L4u/UAqk7LS4KB9pZH/TUFjlM6AXospurw4GuPKI0ACRs7I3ahfOVr8vBBcDTiKTXY 4N88o01Dmd+OfnXh0r2LxRO2VUH14fPQ5icOihaQbpZiUWN8rUr8lDFO/poUx9St0DuQ== X-Received: by 2002:a05:6000:24ca:b0:43b:4703:9de5 with SMTP id ffacd0b85a97d-43d150e3528mr13738625f8f.44.1775135224778; Thu, 02 Apr 2026 06:07:04 -0700 (PDT) Received: from ?IPV6:2001:8a0:fac8:3000:6330:d983:4e81:3a5e? ([2001:8a0:fac8:3000:6330:d983:4e81:3a5e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e2a7223sm7263931f8f.5.2026.04.02.06.07.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Apr 2026 06:07:04 -0700 (PDT) Message-ID: <2a58781c-6a88-4ab4-8727-90c19669cfca@palves.net> Date: Thu, 2 Apr 2026 14:07:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 02/47] Add test for continuing with some threads running To: Kevin Buettner Cc: gdb-patches@sourceware.org References: <20250519132308.3553663-1-pedro@palves.net> <20250519132308.3553663-3-pedro@palves.net> <20250521123619.31894499@f41-zbm-amd> From: Pedro Alves Content-Language: en-US In-Reply-To: <20250521123619.31894499@f41-zbm-amd> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 Hi! On 2025-05-21 20:36, Kevin Buettner wrote: > On Mon, 19 May 2025 14:22:23 +0100 Wow, another year passed... :-/ > Pedro Alves wrote: > >> This testcase would have helped catch some issues I ran into while >> working on the Windows non-stop support. >> >> It tests continuing all threads in all-stop mode when at least one >> thread is already running. > > LGTM. > > Approved-by: Kevin Buettner > Thank you. I've merged this, as below, with minor tweaks to adjust to modern times: - copyright year - "maint set target-non-stop on" for gdbserver - gdb_watchdog instead of alarm - tcl formatting to please pre-commit - pass testfile instead of binfile to clean_restart >From f0fab4d2e5ff01cd81534eb64b43f8ab3da5a82a Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 24 Jan 2025 18:10:50 +0000 Subject: [PATCH] Add test for continuing with some threads running This testcase would have helped catch some issues I ran into while working on the Windows non-stop support. It tests continuing all threads in all-stop mode when at least one thread is already running. Approved-by: Kevin Buettner Change-Id: Ie8cd5c67502aed3c3b159d5eb5eeedee2f84eeef commit-id:f4f07192 --- .../gdb.threads/continue-some-running.c | 77 +++++++++++++++++++ .../gdb.threads/continue-some-running.exp | 57 ++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 gdb/testsuite/gdb.threads/continue-some-running.c create mode 100644 gdb/testsuite/gdb.threads/continue-some-running.exp diff --git a/gdb/testsuite/gdb.threads/continue-some-running.c b/gdb/testsuite/gdb.threads/continue-some-running.c new file mode 100644 index 00000000000..fd77af3cefa --- /dev/null +++ b/gdb/testsuite/gdb.threads/continue-some-running.c @@ -0,0 +1,77 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2025-2026 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include +#include +#include +#include "gdb_watchdog.h" + +volatile int wait_for_gdb = 1; + +#define NUM_THREADS 3 + +static pthread_barrier_t threads_started_barrier; + +static pthread_barrier_t may_exit_barrier; + +static void * +thread_func (void *arg) +{ + /* Wait until all threads have started. */ + pthread_barrier_wait (&threads_started_barrier); + + /* Wait until the main thread lets us exit. */ + pthread_barrier_wait (&may_exit_barrier); + + return NULL; +} + +static void +threads_started (void) +{ +} + +int +main (void) +{ + pthread_t thread[NUM_THREADS]; + int i; + + gdb_watchdog (30); + + pthread_barrier_init (&threads_started_barrier, NULL, NUM_THREADS + 1); + pthread_barrier_init (&may_exit_barrier, NULL, NUM_THREADS + 1); + + for (i = 0; i < NUM_THREADS; i++) + { + int ret; + + ret = pthread_create (&thread[i], NULL, thread_func, NULL); + assert (ret == 0); + } + + pthread_barrier_wait (&threads_started_barrier); + + threads_started (); + + pthread_barrier_wait (&may_exit_barrier); + + for (i = 0; i < NUM_THREADS; i++) + pthread_join (thread[i], NULL); + + return 0; +} diff --git a/gdb/testsuite/gdb.threads/continue-some-running.exp b/gdb/testsuite/gdb.threads/continue-some-running.exp new file mode 100644 index 00000000000..d6716e8ff16 --- /dev/null +++ b/gdb/testsuite/gdb.threads/continue-some-running.exp @@ -0,0 +1,57 @@ +# Copyright 2025-2026 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test continuing in all-stop mode when one thread is already running. + +standard_testfile .c + +if { [build_executable "failed to prepare" $testfile $srcfile \ + {debug pthreads}] \ + == -1 } { + return +} + +proc test {} { + # This test requires background execution, which relies on + # non-stop mode. + save_vars { ::GDBFLAGS } { + append ::GDBFLAGS " -ex \"maint set target-non-stop on\"" + clean_restart $::testfile + } + + if {![runto threads_started]} { + return + } + + delete_breakpoints + + # Set a non-main thread running, while everything else is left + # stopped. + gdb_test_no_output "set scheduler-locking on" + + gdb_test "thread 2" ".*" "switch to secondary thread" + + gdb_test -no-prompt-anchor "continue &" "Continuing\\." + + # Now resume all threads, while there is already one thread + # running. + gdb_test "thread 1" ".*" "switch to main thread" + + gdb_test_no_output "set scheduler-locking off" + + gdb_continue_to_end "" continue 1 +} + +test -- 2.53.0