From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 2FD9B38582A2 for ; Wed, 24 Jan 2024 11:02:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2FD9B38582A2 Authentication-Results: sourceware.org; dmarc=pass (p=none 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 2FD9B38582A2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706094127; cv=none; b=bYTXsY0/ESbVvH6HwSCnCJ7yWeahSrUviKls1JME9Z0xifhP214lRZkIZzmpeGgQSe+n56+EXdxF4OEx6aptBak7MtTkg0Kwv4gxNyu3PhqO9hV44sP5As7mFElKDbxOGCswn7BlPWWTgHZ9MEnVwEkI15cWtY6WeWqIwSZVt9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706094127; c=relaxed/simple; bh=qxcWUIhVZBMTsvTO//f1Y97HS1npjH6XyT/0zhBGwTU=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=IfVEVLLHpe5pOOicE/4e+vvt+k+wS9Ux+uji+RP1UsF5D+v+lTwp4egfqbET/xSOEI1uJacL6LphXL4YpCzmChV+/9EyHrQbH30jE9USuk8IamNTphBas/l5v6zVxaBktnDqDZN0F3YeNNBknnhfmTK+4Fwx16w9RS7m/vs/6qs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706094123; 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=CTyF7Q6sycSlj1x4gH3cwAY8UIUiVtnJP4C4ZnYoBC0=; b=XOywRfYEIzEbHCx5cyN8Jl7wm3BsOxyyLgTKcqxJI5pVWlZGvfLSa2sybkIKu2LGu/wic2 K1B5k2J88erTsQTangOSQ2pujxdw56J/9ZP8ICrbNsfulOPX1Bfo+Z8+6YL5pzHXdhg12L Wcof0WdZeS3XQGR8l6fyzCfeh41ArFo= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-526-eHMY-b1cNLSiabtSea35KA-1; Wed, 24 Jan 2024 06:02:02 -0500 X-MC-Unique: eHMY-b1cNLSiabtSea35KA-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-5ee22efe5eeso64946677b3.3 for ; Wed, 24 Jan 2024 03:02:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706094121; x=1706698921; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CTyF7Q6sycSlj1x4gH3cwAY8UIUiVtnJP4C4ZnYoBC0=; b=bEz7aTbjyz0mlAlMS5dmbau85isWTriIXvlhsdQZRMnnDkz65T3c4+G+/V1lUdWXdI mMgq8H7B3KohDxn4elra7xUPYoxAqRcwnVrMAG/LDcfS6Phe4rl9yJv2a445TgCTfrbN FgofFZHZR7HcoOCzQ6oLEPcNkSeGk8BdqXq/XPPAOL5/kMN2mHfnPfaLDHZ2BhJj2uDO 0N+Si1Sq+vps2wA0zIPxublVUrfL6mLFrA/BvkS+H3rO1XQ1D0rvoirmxSVuXs4HPUFy 6TqG8ow5B9nH7uorHXxtssTIarXn8ET90NpaGZXqwJKHMu+T3KAfWlUscJszvFV2nkv4 Gm+g== X-Gm-Message-State: AOJu0YxjANQXGOCTmyf/gYqGI84czuHWRoTVTWuN4cGdWdiRk4FBFQO6 vhgeTNAjvafRyoriFv13V4SoCB+jnEbuCkJcmaot0s85zMAFPYJDfwpehQg+IymaIhM6fyqF+1V 4y363KLn4u+m655IGK2C/FFq1Sul65bjsllPG/kBK0THitdl+oekHnLwOmLFr356VZv/Rjkri40 /I8AvSRgGOVsp8bgw5qL2Ph7qDcBA= X-Received: by 2002:a0d:e0c5:0:b0:5ff:9342:f8a5 with SMTP id j188-20020a0de0c5000000b005ff9342f8a5mr403222ywe.50.1706094121600; Wed, 24 Jan 2024 03:02:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBQW1CiC880jcpIA+X2aD0chsF38mr2eQoMWe+Qq77enAJ5kPITtRbDcUhY8q8ob7KYIx4I/okKXvylo8ZBqo= X-Received: by 2002:a0d:e0c5:0:b0:5ff:9342:f8a5 with SMTP id j188-20020a0de0c5000000b005ff9342f8a5mr403213ywe.50.1706094121336; Wed, 24 Jan 2024 03:02:01 -0800 (PST) MIME-Version: 1.0 References: <20240124104750.1024129-1-christophe.lyon@linaro.org> In-Reply-To: <20240124104750.1024129-1-christophe.lyon@linaro.org> From: Jonathan Wakely Date: Wed, 24 Jan 2024 11:01:45 +0000 Message-ID: Subject: Re: [PATCH] [testsuite] Fix pretty printers regexps for GDB output To: Christophe Lyon Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, tom@tromey.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 Wed, 24 Jan 2024 at 10:48, Christophe Lyon wrote: > > GDB emits end of lines as \r\n, we currently match the reverse \n\r, We currently match [\n\r]+ which should match any of \n, \r, \n\r or \r\n > possibly leading to mismatches under racy conditions. What do we incorrectly match? Is the problem that a \r\n sequence might be incompletely printed, due to buffering, and so the regex only sees (and matches) the \r which then leaves an unwanted \n in the stream, which then interferes with the next match? I don't understand why that problem wouldn't just result in a failed match with your new regex though. > > I noticed this while running the GCC testsuite using the equivalent of > GDB's READ1 feature [1] which helps detecting bufferization issues. > > Adjusting the first regexp to match the right order implied fixing the > second one, to skip the empty lines. At the very least, this part of the description is misleading. The existing regex matches "the right order" already. The change is to match *exactly* \r\n instead of any mix of CR and LF characters. That's not about matching "the right order", it's being more precise in what we match. But I'm still confused about what the failure scenario is and how the change fixes it. > > Tested on aarch64-linux-gnu. > > [1] https//github.com/bminor/binutils-gdb/blob/master/gdb/testsuite/README#L269 > > 2024-01-24 Christophe Lyon > > libstdc++-v3/ > * testsuite/lib/gdb-test.exp (gdb-test): Fix regexps. > --- > libstdc++-v3/testsuite/lib/gdb-test.exp | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libstdc++-v3/testsuite/lib/gdb-test.exp b/libstdc++-v3/testsuite/lib/gdb-test.exp > index 31206f2fc32..0de8d9ee153 100644 > --- a/libstdc++-v3/testsuite/lib/gdb-test.exp > +++ b/libstdc++-v3/testsuite/lib/gdb-test.exp > @@ -194,7 +194,7 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } { > > set test_counter 0 > remote_expect target [timeout_value] { > - -re {^(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} { > + -re {^(type|\$([0-9]+)) = ([^\n\r]*)\r\n} { > send_log "got: $expect_out(buffer)" > > incr test_counter > @@ -250,7 +250,7 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } { > return > } > > - -re {^[^$][^\n\r]*[\n\r]+} { > + -re {^[\r\n]*[^$][^\n\r]*\r\n} { > send_log "skipping: $expect_out(buffer)" > exp_continue > } > -- > 2.34.1 >