From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id 53B54385E02C for ; Thu, 25 Jan 2024 15:54:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53B54385E02C 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 53B54385E02C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::631 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706198053; cv=none; b=rR3sN/fPdtI3Wo8ATV3srwVmUMaSl3IUUfCDeNO8MgjZ3+1BlxPuGXQnGgl95o0f81dkPz5epNvk6HW5j8j5Tay+st2/RT8pbVGYsBnB3R0IvRy5LrCTMTIpYUa7lO6JGKsL4dxBShECUDgct0ShOa47YxwK8wX9ni5viCHi528= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706198053; c=relaxed/simple; bh=ZfyK76/tTOAZmtkRBEQk1RG9DYNTshrc4VxjwZbrFQc=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=StpMsmmf+fOo1Gij0E8EOavTqKvasiJHNhGHErGSUbDO7QOiNUgzn2+6LIvxe9qhzA57Jas34Aooo1d8Da2Gj6akkzm5wsVfEnu7o30wlMzn07dKnfwO+/RTrVqwUg++B/Re9yJouml4GjE3N8+m2RqRrKZ3dL4comPOc4Z4PSE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a2f22bfb4e6so745686766b.0 for ; Thu, 25 Jan 2024 07:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706198049; x=1706802849; 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=nL2bCmxQH7kBUxAi7cfIsxDiugTf9gzL6KCfgyeHAFY=; b=PhUNI/frA9JLduNuGKYDNtLR21nza3y+VbxNTUwBQ4nn1Yxs9TBWt+EKpuUxavvbtR R6wZFnQMpqkomcWEfS/nV0fg+BxuwcfLVuMl+MnoCMJ2mr9vfS6c2yUITLIeaZKm03DA wty8q4XLtsQwgLBi7qRvFkJEM0o/dKwG2zzhFMPV3UUiceJKfbleqibLSQdQypflzEOl z9qntOK3i61aE1TJF75w1t4MIgtQjPXyQKc211LuS4pmFTYBxA6sxdaayz9jdr11o2We nNmMULJPu0LMkFjPA/XO9kB5D3x9YuRJqBvtS5x6FVnCUXzu6OOuD5K97Lex5mZv4Nzc f0uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706198049; x=1706802849; 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=nL2bCmxQH7kBUxAi7cfIsxDiugTf9gzL6KCfgyeHAFY=; b=TzfUrxFxEncOL6v8HJhBnuv5omL5B4ZmqJk8cxBQjvOPomRh8S5gxfGhjh5OVKClXN F5oWIRjjn/xVuYHVKgSQhvTa/t/gwmN081rIp862yy08PHWTmJKbEU549iyyQ1YF0gEK wqx1nUqK++P3I2hMxWoJHPNwnPotNY86MXjmWiQ7CrCqvDROTZF6H24KeA4DhouEVtYl cbbKvQIEeS40TKs56w/TOKtK2La0pZLFKVN3CU1gwt1d0ysWjyP81V9By488dL3+WJW+ 8Qo/1gDV/Kj5DxMN1kuNIJRaL7oQ5MvsZrM+rzTASb8AehvSzS5sDPUMAIOV7Ek5Q4iH QNUw== X-Gm-Message-State: AOJu0YyrmjNd5RnaYLH1VCi8ugb0UAN1bTzobPncxg/+g1hQb5cU2ShJ 1w6Lqgc8fBKZ9A1ScSWN5qcD0yNef93Y5zhXAG8JgQoCX+3P3oxEU+sObDKEIoDaOXahU8XdMvB FGkeHK1g5cSqMehRuCtiNZx6Rph3E0YfPp1ZHLQ== X-Google-Smtp-Source: AGHT+IG/gmtAbb+tFz5Iytv2Ss1Yd45pi//mT4RE4eHD/Hxtc7jT7iqMHFse6ZBbJG30At3s1q9ngp/NOLeXHtWiHsQ= X-Received: by 2002:a17:906:2516:b0:a31:2993:9b69 with SMTP id i22-20020a170906251600b00a3129939b69mr1047536ejb.52.1706198048972; Thu, 25 Jan 2024 07:54:08 -0800 (PST) MIME-Version: 1.0 References: <20240124104750.1024129-1-christophe.lyon@linaro.org> In-Reply-To: From: Christophe Lyon Date: Thu, 25 Jan 2024 16:54:00 +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: multipart/mixed; boundary="000000000000a04812060fc73024" X-Spam-Status: No, score=-10.3 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: --000000000000a04812060fc73024 Content-Type: text/plain; charset="UTF-8" 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 > > > --000000000000a04812060fc73024 Content-Type: text/x-patch; charset="US-ASCII"; name="v2-0001-testsuite-Fix-pretty-printers-regexp-for-GDB-outp.patch" Content-Disposition: attachment; filename="v2-0001-testsuite-Fix-pretty-printers-regexp-for-GDB-outp.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lrte9av30 RnJvbSBlN2NkMDQ3NTE0MTkyMTI4MmQ1YzkwNDRiMjQ1MGFlOGUxOTZlZmM0IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBDaHJpc3RvcGhlIEx5b24gPGNocmlzdG9waGUubHlvbkBsaW5h cm8ub3JnPgpEYXRlOiBUaHUsIDI1IEphbiAyMDI0IDE1OjQzOjU2ICswMDAwClN1YmplY3Q6IFtQ QVRDSCB2Ml0gW3Rlc3RzdWl0ZV0gRml4IHByZXR0eSBwcmludGVycyByZWdleHAgZm9yIEdEQiBv dXRwdXQKCkdEQiBlbWl0cyBlbmQgb2YgbGluZXMgYXMgXHJcbiwgd2UgY3VycmVudGx5IG1hdGNo IGFueSA+MCBudW1iZXIgb2YKZWl0aGVyIFxuIG9yIFxyLCBwb3NzaWJseSBsZWFkaW5nIHRvIG1p c21hdGNoZXMgdW5kZXIgcmFjeSBjb25kaXRpb25zLgoKSSBub3RpY2VkIHRoaXMgd2hpbGUgcnVu bmluZyB0aGUgR0NDIHRlc3RzdWl0ZSB1c2luZyB0aGUgZXF1aXZhbGVudCBvZgpHREIncyBSRUFE MSBmZWF0dXJlIFsxXSB3aGljaCBoZWxwcyBkZXRlY3RpbmcgYnVmZmVyaXphdGlvbiBpc3N1ZXMu C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