From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by sourceware.org (Postfix) with ESMTPS id 6D953384E78F for ; Mon, 12 Dec 2022 20:19:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D953384E78F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id f18so13402675wrj.5 for ; Mon, 12 Dec 2022 12:19:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:to:subject:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/ebM03/Q5lzsfvaIKgQxh0BUCPxGK96Apgp0I92xGco=; b=0DSmxHYxWhStiEwO5MJPI0IZQBVXewM5eV7FixBByjcN+5Gtxfzz4xzRFi/cj/iuxC yTN0X3LdM8xE3y/7MNI7v1tuhXQPada3nMrAY2xLkPF26/qqIIpBb+nTKkQ18ek0M0J+ 2pyFGnZ+SPHAu38n9SqY1+yETfMH7itDEHlkRzcEOlYXYs/mNpMVO/wujSIKHKhMQ1x3 9J5vxQjAaTGT/c6j0fHjM+OwzDSrOcihU+Mt63kr0gzkC+PRql8ZXN501yBVhSAxeLG0 WtcDaG4WX1yLCFXUpTkIWcKRbkG8xZi4t7fsKX59Plo+cHCMuS0+Jqj2oaEk/6PJ0h/+ uHbQ== X-Gm-Message-State: ANoB5pnCU3gciMdPgqhKfWfb1vOidXJ57G/Ts8zc/rdJPHt5kF1TEMRl P48JhkHxvid2euczL8N2nqd9jkvVQSFZzQ== X-Google-Smtp-Source: AA0mqf6R7vvEEbOkvB8Ipd5a9ApCvvzKw5MxpekwmF+f1TRvsL8MxwcsN2HcbKBgqn6pJlmWsuJObA== X-Received: by 2002:adf:df07:0:b0:249:fb22:4e7f with SMTP id y7-20020adfdf07000000b00249fb224e7fmr9304890wrl.36.1670876377238; Mon, 12 Dec 2022 12:19:37 -0800 (PST) Received: from ?IPv6:2001:8a0:f912:6700:afd9:8b6d:223f:6170? ([2001:8a0:f912:6700:afd9:8b6d:223f:6170]) by smtp.gmail.com with ESMTPSA id cl6-20020a5d5f06000000b0024274a5db0asm10073072wrb.2.2022.12.12.12.19.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Dec 2022 12:19:36 -0800 (PST) From: Pedro Alves Subject: Re: [PATCH v2 21/29] Don't resume new threads if scheduler-locking is in effect To: Simon Marchi , gdb-patches@sourceware.org References: <20220713222433.374898-1-pedro@palves.net> <20220713222433.374898-22-pedro@palves.net> Message-ID: Date: Mon, 12 Dec 2022 20:19:41 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2022-07-21 7:49 p.m., Simon Marchi wrote: >> diff --git a/gdb/testsuite/gdb.threads/schedlock-new-thread.exp b/gdb/testsuite/gdb.threads/schedlock-new-thread.exp >> new file mode 100644 >> index 00000000000..8952cb7531c >> --- /dev/null >> +++ b/gdb/testsuite/gdb.threads/schedlock-new-thread.exp >> @@ -0,0 +1,63 @@ >> +# Copyright 2021-2022 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 over a thread spawn with scheduler-locking on. >> + >> +standard_testfile .c >> + >> +set syscalls_src $srcdir/lib/my-syscalls.S > > Is this needed? > Eh. Copy/pasto. I've removed it. >> + >> +if { [build_executable "failed to prepare" $testfile \ >> + [list $srcfile $syscalls_src] {debug pthreads}] == -1 } { >> + return >> +} >> + >> +proc test {non-stop schedlock} { >> + save_vars ::GDBFLAGS { >> + append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" >> + clean_restart $::binfile >> + } >> + >> + set linenum1 [gdb_get_line_number "set break 1 here"] >> + >> + if { ![runto $::srcfile:$linenum1] } { >> + return >> + } >> + >> + delete_breakpoints >> + >> + set linenum2 [gdb_get_line_number "set break 2 here"] >> + gdb_breakpoint $linenum2 >> + >> + gdb_breakpoint "thread_func" >> + >> + gdb_test_no_output "set scheduler-locking $schedlock" >> + >> + if {$schedlock} { >> + gdb_test "continue" \ >> + "return 0.*set break 2 here .*" \ >> + "continue does not stop in new thread" >> + } else { >> + gdb_test "continue" \ >> + "thread_func .*" \ >> + "continue stops in new thread" >> + } > > In the non-schedlock case, if you imagine a scheduler that messes with > you on purpose, wouldn't it be possible for main to hit its breakpoint > before the thread hits thread_func? If so, any idea how to change the > test to avoid that? Maybe main can join the thread in that case, > instead of doing a sleep. The thread would have to not be an infinite > loop, but I don't see why it needs to be. Yeah, I assume it would have to be a really nasty scheduler, to not schedule the other thread for 3 seconds. I mean, since we already had a sleep for the schedlock case, I had just gone from simplicity and relied on it for the non-schedlock case too. But I can tweak it with a join, for sure. I just means that we have to compile two different programs (or use #ifdef). It's not that bad, actually. Done. Pedro Alves