From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ZaKnHIQxK2hNNioAWB0awg (envelope-from ) for ; Mon, 19 May 2025 09:26:28 -0400 Received: by simark.ca (Postfix, from userid 112) id 348461E11C; Mon, 19 May 2025 09:26:28 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4E2921E11B for ; Mon, 19 May 2025 09:26:26 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6B1DA3858C2C for ; Mon, 19 May 2025 13:26:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B1DA3858C2C Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by sourceware.org (Postfix) with ESMTPS id 76D7E385842C for ; Mon, 19 May 2025 13:23:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 76D7E385842C 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 76D7E385842C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747660998; cv=none; b=OZjgwo4jk7DmkQCf04Lw20VzLi04GLKJjQNodvYHH4r6+Bkfuj63EWgRHN+FKEuFL1H02WWIIrkcm8lxQ3Xrotk5TlDf+qp9oNMapmabq5BCUl3Lk5E1Xw2yHS9sxEuonohKL0rov213+cyFKQuI+LqSXjnMl3gAxRVmgq53A6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747660998; c=relaxed/simple; bh=po3ah0yFUXN79Wxbz5BG4+mNLAx1mz7vJNmFIg8o4So=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=yGLN7WnBhTPp1yEWRhBm2SBHJ5taPzuleu7Xuk9gWNSAe7+7bNLhYiPU/DLgUliPAzU6mbzD4k8Vd+8shCJuVlBmPe8Uy/F/u0UdKCGKuAUYnPFG8965Q3j0F8hbtRKNqn62VdssfWZshlhJzaSEQrtaq7jsB+h1lS0l62KCXI4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76D7E385842C Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3a1fb18420aso4507063f8f.1 for ; Mon, 19 May 2025 06:23:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747660997; x=1748265797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h8rj+EJfuq9mf8uYZ87hdlOK0Hum/FRgcH/Myf2lDHg=; b=ZWxByVUYiWtkcKAzTPAHzXS3ykevoVe2eY7NWGNG/o+xsBbIIWLlRGxGYr1wBDAGBA F/1iWsKok1CDIzyprEI3Jc+U1e68Ve45XeFqkur21la6+5EUSOvcCzn5UKcQigKxd+bg iNmwiHQ72uRRyIUdZE6SMLM2sy/4C/uXHCZeiEA+oGBzWjaJ9aMzGqRuUXsB6w4YQz1G iMUo11Xi/+I6eNDmlZQPgMpzXa+Yf2NBQsnlInw33IycfOOw06Yj6TUvkJuLPvXn901L OZ44JR1JtoW8dCq9Q2Sxbu46i6V2a35nQLlrnqiXYNK1J0kfHfJDjQk+HxLT0YBABf2F wmKQ== X-Gm-Message-State: AOJu0YyJwTM1XXrXp7arxD0WJQDOphawC+3mB1Y0m4GNXg9xsK1l1+pl 78+z0T/dy0KJl/UqJWYaRkLLE04ki4zckuTVBCeyheO6NJFaPgu3hJ4h1uiiI+0r X-Gm-Gg: ASbGncvmZgl5NV1w2H8Ffld19T2kgzJ+9DPV0iLC11uUB7HX1h7n9yUIFubI4UQYYeG tS1RatOoo+Q2Gz+jkAwPCBk17e1o2+e9jNKV84ketKeX2pwmHYnvNG2Kx8H/kAh5pcNoGvdlwoV 5q2LfD8DzRWzhOnHc8pqW7bI7D/13wwqpNXPL/OJg/FX7rreSTUtn4Ppm2OaddTLaKIktLG5ftn jaTBt55GcBMO2C/u9wzXlro1DecUXU9K3fXy9KJbrb5lfw7f1m6l/dxKueRVSa4UFuRF8iI3Dcb 20yugOtz2MKtgJ4HjZ0+fKM00CFomWvIRvIkWFVHC00xaw+Famw= X-Google-Smtp-Source: AGHT+IGu4kdYakmvZIpoPMPS5W3LqmpUcgaGPURmPg2Ywo5SJ2CZ/HO4LHGnAsc1/MIrSOrC/f3B3g== X-Received: by 2002:a05:6000:2af:b0:39d:724f:a8ae with SMTP id ffacd0b85a97d-3a35c8355admr12448236f8f.33.1747660996816; Mon, 19 May 2025 06:23:16 -0700 (PDT) Received: from localhost ([2001:8a0:4fe9:b400:8d90:6f0d:36bf:32df]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a35ca4d263sm12652495f8f.3.2025.05.19.06.23.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 May 2025 06:23:16 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 02/47] Add test for continuing with some threads running Date: Mon, 19 May 2025 14:22:23 +0100 Message-ID: <20250519132308.3553663-3-pedro@palves.net> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519132308.3553663-1-pedro@palves.net> References: <20250519132308.3553663-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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. Change-Id: Ie8cd5c67502aed3c3b159d5eb5eeedee2f84eeef --- .../gdb.threads/continue-some-running.c | 76 +++++++++++++++++++ .../gdb.threads/continue-some-running.exp | 52 +++++++++++++ 2 files changed, 128 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..9e0d73e08a0 --- /dev/null +++ b/gdb/testsuite/gdb.threads/continue-some-running.c @@ -0,0 +1,76 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2025 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 + +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; + + alarm (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..144aad1fd2e --- /dev/null +++ b/gdb/testsuite/gdb.threads/continue-some-running.exp @@ -0,0 +1,52 @@ +# Copyright 2025 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 {} { + clean_restart $::binfile + + 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.49.0