From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 8DD5C385702E for ; Mon, 29 Mar 2021 14:36:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8DD5C385702E Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 12TEaS78002916 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 29 Mar 2021 10:36:32 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 12TEaS78002916 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 07BC51E590; Mon, 29 Mar 2021 10:36:28 -0400 (EDT) Subject: Re: [PATCH] testsuite, mi: avoid a clang bug in 'user-selected-context-sync.exp' To: Tankut Baris Aktemur , gdb-patches@sourceware.org References: <1617026615-4257-1-git-send-email-tankut.baris.aktemur@intel.com> From: Simon Marchi Message-ID: <0f65522b-5985-b00c-0bf1-af8300099bff@polymtl.ca> Date: Mon, 29 Mar 2021 10:36:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <1617026615-4257-1-git-send-email-tankut.baris.aktemur@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 29 Mar 2021 14:36:28 +0000 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Mar 2021 14:36:38 -0000 On 2021-03-29 10:03 a.m., Tankut Baris Aktemur via Gdb-patches wrote:> This test causes several timeouts for Clang, taking too long time to > finish. The reason is, for an infinite loop of the form > > while(1); /* suppose this is line 30. */ > > Clang generates code that looks like > > 0x00000000004004d4 <+4>: jmp 0x4004d9 > 0x00000000004004d9 <+9>: jmp 0x4004d9 > > So, the real loop is the instruction at address 0x4004d9. But a > breakpoint that's defined at the loop line (assume line 30 in this > case) is inserted at address 0x4004d4. > > (gdb) break 30 > Breakpoint 1 at 0x4004d4: file test.c, line 30. > > Therefore, continuing a thread that was spinning on the loop does not hit > the breakpoint. The bug is reported at > > https://bugs.llvm.org/show_bug.cgi?id=49614 > > Tweak the infinite loop to spin on a variable to avoid this bug. The > test is unrelated to the bug. > > gdb/testsuite/ChangeLog: > 2021-03-29 Tankut Baris Aktemur > > * gdb.mi/user-selected-context-sync.exp: Spin on a variable in > the infinite loop to avoid a Clang bug. > --- > gdb/testsuite/gdb.mi/user-selected-context-sync.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.c b/gdb/testsuite/gdb.mi/user-selected-context-sync.c > index 500a118a2dc..0f8a966f69d 100644 > --- a/gdb/testsuite/gdb.mi/user-selected-context-sync.c > +++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.c > @@ -27,7 +27,8 @@ static pthread_barrier_t barrier; > static void > child_sub_function (void) > { > - while (1); /* thread loop line */ > + int spin = 1; > + while (spin); /* thread loop line */ > } > > static void * > @@ -57,7 +58,8 @@ main (void) > > pthread_barrier_wait (&barrier); > > - while (1); /* main break line */ > + int spin = 1; > + while (spin); /* main break line */ > > return 0; > } > Thanks, this is OK. Maybe just add a comment in the code, otherwise someone might be tempted to "optimize" it. If they see the comment, they'll be able to "git blame" and get the full story. Simon