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 501AF3858016 for ; Wed, 24 Jan 2024 11:02:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 501AF3858016 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 501AF3858016 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=LpUrVaQYzA+VFK+Vq0zw7XOAFKACMFIg8tJMevz9Qace+mbEhi3pxB7cr3v2rMNqxBCiaT+qthmTgwiw8wyNj4H6tleJyvRqkW8vCMc8ZDOMK5QgKevxvM4yKDH0fd/i1WYgD9Tdxa0a6BMriNuI9EwddmaEiGx0QKgXsDNv2AY= 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=HjMjAcLz2ck0qHP9J6bOwtS/z0/fuduUQs1zQ+2PVIp1cQ/93LTuZFfuiOIaBpZOCFXL/5dFsk8nq0jBG8c6e0oGa3kJm9u72QNrwLqV0lqGXzpk7wy5xcHjJXpZ9cwBHIBkuNPu14Lh1dfM/2Qxxe4LqnBjiSYjT1tgPTiMjFs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706094124; 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=NaGpDqNqTDdi8YvtUR0rVO7yz62AO25uXKquCyrqyp4ULsuxzVfjiZ0YgMz8pw7i0p5rsw fe3FGpIg33aNEr5GoTaG/EGer+DkBDPO3asCQi8zuxXqNTnc31FXxgCQAaXxz/fecYqEJL wlxZNSCyH+EX8818kx5SGtnxN2XHhJk= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-312-ndyc7q6zPAidMmRNc6_apA-1; Wed, 24 Jan 2024 06:02:02 -0500 X-MC-Unique: ndyc7q6zPAidMmRNc6_apA-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-5efb07ddb0fso63948837b3.0 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=h1Jj0+LlXs+sqBQJpHaVDtXNJozIck1lJBbM88uHqG04DAmVMJbMpOfNgBjAYKxWGh 8PycjvtO3y4rastgO21qEYGd2mb14+DaqVt33kklFIRmedyheViBzLyu8jtuMGqoeyom IWHMbQRU/hgFUsYQV9rMiQ53I4uH2X6AJoTj2V5RSvKNoB9ohGSZupONGlRvh+11itDH 89zjUYRTgtGdF5e+kgk7r4YZnHnqLgzHYJ3x39bJhua0NybSiz7bk2osACP+PF2eDbdy HN5r0NXChaDGgPvu/LuQWLKOMZukxrPg0raBcjiA0olZd4jvsl9xQx98t+PPxnyFaGSu zAkw== X-Gm-Message-State: AOJu0Yz9mwUXvLqmiYJfTJXbPND3mTB5d1SmtcmstBETPXFM0OsHAP+d Oxq99IRnIgePm+taaH/Q592j9msi1tEyQRc6nn4fZgsVJwTCCeb9sAze/dB8cSB5Ls5AShsM3+9 utOvl1jGz3hFFjBcOMpVzBrhab1j3sSNRr/Tj+NvCIdZ/YcyqWYZG/3WJcz8MIE839wIE0LgfY8 gE5cuWRkWong50GD3pbXl0rGKA9VcACw== X-Received: by 2002:a0d:e0c5:0:b0:5ff:9342:f8a5 with SMTP id j188-20020a0de0c5000000b005ff9342f8a5mr403221ywe.50.1706094121599; 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.2 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 >