From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id B4C463858D33 for ; Tue, 6 Feb 2024 09:26:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4C463858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B4C463858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::132 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707211597; cv=none; b=H2N7fjriTMSZnXrYTsvMOTXDH9vjsXTg6wJfNHvbx9nFewnKpGGRUYfVVJxfAV7TB9fsCHfXeQqdr/gmpQFYPi/jvNPtBjOvXY8falmV+MoEZ4ttKiud5/0DdS+y7Z2d4fstiKtsc1Vs8fWHItP/I+hhejfvmILmhRlsbBUpl2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707211597; c=relaxed/simple; bh=DRnDqGgW2rrJPk9AohSt6NVkQsoHj+prTW0nJ3Q08/Q=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=NkA1h+XP1rxvRDPnBnrdibs2GFUsxH9fLZMha8qEBYd83RYsJJjVNI2MAQb2tiRCtfdByE806OjjqPrKaM5UZsZvxaZT5Nzv8A/Vrxrp83hv1YMTu5gA5yOou+Vq7h6dWnwdh6wq7GeN9/K34vrnpWBY0scMcT0/MBr6ajqamWw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-51032058f17so777811e87.3 for ; Tue, 06 Feb 2024 01:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707211593; x=1707816393; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LjQyCDcZKvFz0cLOe+7N7LcyBYyXddjQmf0e1Dwzx4I=; b=vhxIcgJ45J6hyK31KOpOGAlJ22+Ktxy/AxI95i2TRFnXCMys8yYBlOw1yfKT0NegUS L0FvIxs3n+jcX3KEbCjD8Z4U8LceV5A+uk25+tzdk0xK5rlpCh7QQD1wLxALwmaD6JCN eZ31QzYtzYn4d4RoANbSxMrLdCOe+6qbtaerFJ7jcETZP6FtUMmj+6kGxWeMUFy9ojoq 3uWY07GILc5NGDUlPErzKTz8m1oHrsFXEzyMbndvCaO+818F1qOPo3+fc/n9AwkIHA3W c/WmeggBzi7MHYGrwJC8Zl8JBMD8CS8TEnjkmDhyBbK9T/8QA7HqTYS6Hwvevp+BVeK8 YrQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707211593; x=1707816393; 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=LjQyCDcZKvFz0cLOe+7N7LcyBYyXddjQmf0e1Dwzx4I=; b=oOLp5iv34sVfX3cEK9D+VVs2B5nxCFkw9wVJO3QJuRQSDxuFARW5C05fFoAmufu7M8 3WqGWb9Xls3nJjbTpZrya/Gb5Q1zIGCODwYl45pxyzbDVd/Uuky52FQ9/AQ2ah5S36/n /kfeXQyEaRsu8cj+2ufalon7FGg2PTGtHKr3qI7LenWn1wgN/g4BddcFpGWi4pHJ+dQX lmQuQdpckt5MoFfu7LZv2zNq/f4WuCNJaJUo8myVNqYlGZ5JZP3U038SlpFwAHJ6oDQR JXQlnMXRAVC4nxKWs4x89A1VcxdmsZmJyz98Q1OT3Z1yzLFzyjgNLaiGgR81VCwRVQMt 1Ngg== X-Gm-Message-State: AOJu0Yyt/PJDELjVPk2gfeSAO19E11V+/t1H0aRSIM9AdeVCwzSFqzeE BeS84rA6csVoeAxHsU5WpdMxsjgEnBsVUsqLRdZ+YfDN7SbpRL1JwZ5qWQLdvCeCHC/zPNon/jO hwCkQjFNe1hYkmnN41np/SADWjr0drxBwjjdENZPEhh0CZWruYNNWqw== X-Google-Smtp-Source: AGHT+IF16EVL7tvVtnW0Rk6b89awcDAgPAAkWKWvt1yH9Uoxco8s3rgu4zkYZ92e2brNSMn4vkrp2k4u19kI0xIH2O4= X-Received: by 2002:ac2:4d88:0:b0:511:52fb:cb1e with SMTP id g8-20020ac24d88000000b0051152fbcb1emr1435563lfe.36.1707211593224; Tue, 06 Feb 2024 01:26:33 -0800 (PST) MIME-Version: 1.0 References: <20240124104750.1024129-1-christophe.lyon@linaro.org> In-Reply-To: From: Christophe Lyon Date: Tue, 6 Feb 2024 10:26:25 +0100 Message-ID: Subject: Re: [PATCH] [testsuite] Fix pretty printers regexps for GDB output To: Jonathan Wakely Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, tom@tromey.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: ping? On Thu, 25 Jan 2024 at 16:54, Christophe Lyon wrote: > > On Wed, 24 Jan 2024 at 12:02, Jonathan Wakely wrote: > > > > 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 > > > > Hmm, right, sorry I had this patch in my tree for quite some time, but > wrote the description just now, so I read a bit too quickly. > > > > > > 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. > > > Exactly: READ1 forces read() to return 1 byte at a time, so we leave > an unwanted \r in front of a string that should otherwise match the > "got" case. > > > > > > > > > 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. > > > > I followed what the GDB testsuite does (it matches \r\n at the end of > many regexps), but in fact it seems it's not needed: > it works if I update the "got" regexp like this (ie. accept any number > of leading \r or \n): > - -re {^(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} { > + -re {^[\n\r]*(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} { > and leave the "skipping" regexp as it is currently. > > Is the new attached version OK? > > Thanks, > > Christophe > > > > > > > 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 > > > > >