Message ID | 20221114151416.372074-1-simon.marchi@polymtl.ca |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4975C3885C34 for <patchwork@sourceware.org>; Mon, 14 Nov 2022 15:14:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4975C3885C34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668438886; bh=0pzGTOF0ohb2NHx9G8xQ5KfdmEq4bEVRBF/hUmfFRoY=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=pMOrT0KaWhUJe4Z+3VVAV3t/ASvTA/WrpTXw8YT4LE7L/TKYIzaS/1YCg9mSXMOTX pCy9sDAYOU1lCM8qrdFoCdpxgQjvXp4Bc3NjzU69uoEiKVDc3HM/L5iHrP4SjCK1+i 9c4wwBCAGxmhdlMMiG2We61NHvMwNHrQjcUB5cCI= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id DE695382E52F for <gdb-patches@sourceware.org>; Mon, 14 Nov 2022 15:14:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DE695382E52F 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 2AEFEHFb025178 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Nov 2022 10:14:21 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 2AEFEHFb025178 Received: from simark.localdomain (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 04CE81E0D3; Mon, 14 Nov 2022 10:14:16 -0500 (EST) To: gdb-patches@sourceware.org Cc: Simon Marchi <simon.marchi@polymtl.ca> Subject: [PATCH] gdb/testsuite: get_set_option_choices: expect \r\n after each item Date: Mon, 14 Nov 2022 10:14:16 -0500 Message-Id: <20221114151416.372074-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 14 Nov 2022 15:14:17 +0000 X-Spam-Status: No, score=-3189.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Simon Marchi <simon.marchi@polymtl.ca> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
gdb/testsuite: get_set_option_choices: expect \r\n after each item
|
|
Commit Message
Simon Marchi
Nov. 14, 2022, 3:14 p.m. UTC
I get some random failures since commit 8d45c3a82a0e ("[gdb/testsuite] Set completions to unlimited in get_set_option_choices"), which can be reproduced with: $ make check-read1 TESTS="gdb.base/parse_number.exp" For instance: set architecture A^M Ambiguous item "A".^M (gdb) FAIL: gdb.base/parse_number.exp: arch=A: set architecture A The problem is the regexp in get_set_option_choices, it can match only part of a completion result. With check-read1, that is alwasy one letter. Fix this by expecting the \r\n at the end of the line, so we only match entire results. Change-Id: Ib1733737feab7dde0f7095866e089081a891054e --- gdb/testsuite/lib/gdb.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: a5b6e43669b78729d2ef78d668e19bac2b11197d
Comments
On 11/14/22 16:14, Simon Marchi via Gdb-patches wrote: > I get some random failures since commit 8d45c3a82a0e ("[gdb/testsuite] > Set completions to unlimited in get_set_option_choices"), which can be > reproduced with: > > $ make check-read1 TESTS="gdb.base/parse_number.exp" > Hi, sorry, that's my fault. I can reproduce this. > For instance: > > set architecture A^M > Ambiguous item "A".^M > (gdb) FAIL: gdb.base/parse_number.exp: arch=A: set architecture A > > The problem is the regexp in get_set_option_choices, it can match only > part of a completion result. With check-read1, that is alwasy one > letter. Fix this by expecting the \r\n at the end of the line, so we > only match entire results. > Now, with --enable-targets=all I have 364 architectures: ... $ gdb -q -batch -ex "set max-completions unlimited" -ex "complete set architecture " 2>&1 | grep -v -c "set architecture" 0 $ gdb -q -batch -ex "set max-completions unlimited" -ex "complete set architecture " 2>&1 | grep -c "set architecture" 364 ... And using this: ... @@ -9156,6 +9156,7 @@ proc get_set_option_choices {set_cmd} { } } + verbose -log "Found [llength $values] choices for $set_cmd" return $values } ... we can see how many choices get_set_option_choices finds. Without this patch I get: ... (gdb) Found 364 choices for set architecture ... but with the patch: ... (gdb) Found 182 choices for set architecture ... The problem is that by consuming \r\n both at the start and the end of the line, we drop about half of the choices. I usually solve this by using positive lookahead: ... - -re "\r\n$set_cmd (\[^\r\n\]+)\r\n" { + -re "\r\n$set_cmd (\[^\r\n\]+)(?=\r\n)" { ... This fixes the number of choices for me, and still passes with check-read1. Note that in the original patch I did: ... - -re "$set_cmd (\[^\r\n\]+)\r\n" { + -re "\r\n$set_cmd (\[^\r\n\]+)" { ... in order to be able to use -wrap (which requires a leading \r\n) instead of gdb_prompt. I remember typing that up in the commit message, but it seems to have gone missing. Thanks, - Tom
On 11/15/22 02:01, Tom de Vries wrote: > On 11/14/22 16:14, Simon Marchi via Gdb-patches wrote: >> I get some random failures since commit 8d45c3a82a0e ("[gdb/testsuite] >> Set completions to unlimited in get_set_option_choices"), which can be >> reproduced with: >> >> $ make check-read1 TESTS="gdb.base/parse_number.exp" >> > > Hi, > > sorry, that's my fault. I can reproduce this. > >> For instance: >> >> set architecture A^M >> Ambiguous item "A".^M >> (gdb) FAIL: gdb.base/parse_number.exp: arch=A: set architecture A >> >> The problem is the regexp in get_set_option_choices, it can match only >> part of a completion result. With check-read1, that is alwasy one >> letter. Fix this by expecting the \r\n at the end of the line, so we >> only match entire results. >> > > Now, with --enable-targets=all I have 364 architectures: > ... > $ gdb -q -batch -ex "set max-completions unlimited" -ex "complete set architecture " 2>&1 | grep -v -c "set architecture" > 0 > $ gdb -q -batch -ex "set max-completions unlimited" -ex "complete set architecture " 2>&1 | grep -c "set architecture" > 364 > ... > > And using this: > ... > @@ -9156,6 +9156,7 @@ proc get_set_option_choices {set_cmd} { > } > } > > + verbose -log "Found [llength $values] choices for $set_cmd" > return $values > } > > ... > we can see how many choices get_set_option_choices finds. > > Without this patch I get: > ... > (gdb) Found 364 choices for set architecture > ... > but with the patch: > ... > (gdb) Found 182 choices for set architecture > ... > > The problem is that by consuming \r\n both at the start and the end of the line, we drop about half of the choices. Ah, noob mistake, thanks for catching, it would have been bad. > > I usually solve this by using positive lookahead: > ... > - -re "\r\n$set_cmd (\[^\r\n\]+)\r\n" { > + -re "\r\n$set_cmd (\[^\r\n\]+)(?=\r\n)" { I had to look up what ?= does (positive lookahead), but that looks good to me. > ... > This fixes the number of choices for me, and still passes with check-read1. > > Note that in the original patch I did: > ... > - -re "$set_cmd (\[^\r\n\]+)\r\n" { > + -re "\r\n$set_cmd (\[^\r\n\]+)" { > ... > in order to be able to use -wrap (which requires a leading \r\n) instead of gdb_prompt. I remember typing that up in the commit message, but it seems to have gone missing. Since this let me make a mistake, I'm thinking that we could be a bit more paranoid in the match patterns, ensuring that we match at the beginning of the expect buffer, and that no output is left behind. Something like: with_set max-completions unlimited { gdb_test_multiple $cmd $test { -re "^[string_to_regexp $cmd]" { exp_continue } -re "^\r\n$set_cmd (\[^\r\n\]+)(?=\r\n)" { lappend values $expect_out(1,string) exp_continue } -re "^\r\n$::gdb_prompt $" { pass $gdb_test_name } } } Simon
On 11/15/22 15:59, Simon Marchi wrote: > On 11/15/22 02:01, Tom de Vries wrote: >> On 11/14/22 16:14, Simon Marchi via Gdb-patches wrote: >>> I get some random failures since commit 8d45c3a82a0e ("[gdb/testsuite] >>> Set completions to unlimited in get_set_option_choices"), which can be >>> reproduced with: >>> >>> $ make check-read1 TESTS="gdb.base/parse_number.exp" >>> >> >> Hi, >> >> sorry, that's my fault. I can reproduce this. >> >>> For instance: >>> >>> set architecture A^M >>> Ambiguous item "A".^M >>> (gdb) FAIL: gdb.base/parse_number.exp: arch=A: set architecture A >>> >>> The problem is the regexp in get_set_option_choices, it can match only >>> part of a completion result. With check-read1, that is alwasy one >>> letter. Fix this by expecting the \r\n at the end of the line, so we >>> only match entire results. >>> >> >> Now, with --enable-targets=all I have 364 architectures: >> ... >> $ gdb -q -batch -ex "set max-completions unlimited" -ex "complete set architecture " 2>&1 | grep -v -c "set architecture" >> 0 >> $ gdb -q -batch -ex "set max-completions unlimited" -ex "complete set architecture " 2>&1 | grep -c "set architecture" >> 364 >> ... >> >> And using this: >> ... >> @@ -9156,6 +9156,7 @@ proc get_set_option_choices {set_cmd} { >> } >> } >> >> + verbose -log "Found [llength $values] choices for $set_cmd" >> return $values >> } >> >> ... >> we can see how many choices get_set_option_choices finds. >> >> Without this patch I get: >> ... >> (gdb) Found 364 choices for set architecture >> ... >> but with the patch: >> ... >> (gdb) Found 182 choices for set architecture >> ... >> >> The problem is that by consuming \r\n both at the start and the end of the line, we drop about half of the choices. > > Ah, noob mistake, thanks for catching, it would have been bad. > >> >> I usually solve this by using positive lookahead: >> ... >> - -re "\r\n$set_cmd (\[^\r\n\]+)\r\n" { >> + -re "\r\n$set_cmd (\[^\r\n\]+)(?=\r\n)" { > > I had to look up what ?= does (positive lookahead), but that looks good > to me. > >> ... >> This fixes the number of choices for me, and still passes with check-read1. >> >> Note that in the original patch I did: >> ... >> - -re "$set_cmd (\[^\r\n\]+)\r\n" { >> + -re "\r\n$set_cmd (\[^\r\n\]+)" { >> ... >> in order to be able to use -wrap (which requires a leading \r\n) instead of gdb_prompt. I remember typing that up in the commit message, but it seems to have gone missing. > > Since this let me make a mistake, I'm thinking that we could be a bit > more paranoid in the match patterns, ensuring that we match at the > beginning of the expect buffer, and that no output is left behind. > Something like: > > > with_set max-completions unlimited { > gdb_test_multiple $cmd $test { > -re "^[string_to_regexp $cmd]" { > exp_continue > } > > -re "^\r\n$set_cmd (\[^\r\n\]+)(?=\r\n)" { > lappend values $expect_out(1,string) > exp_continue > } > > -re "^\r\n$::gdb_prompt $" { > pass $gdb_test_name > } > } > } Yep, more strict matching is ok. LGTM. Thanks, - Tom
> Yep, more strict matching is ok. > > LGTM. Thanks. I pushed it, but actually I went with this, since we're not using -wrap anyway. I think it's a bit less cryptic than the lookahead version: with_set max-completions unlimited { gdb_test_multiple $cmd $test { -re "^[string_to_regexp $cmd]\r\n" { exp_continue } -re "^$set_cmd (\[^\r\n\]+)\r\n" { lappend values $expect_out(1,string) exp_continue } -re "^$::gdb_prompt $" { pass $gdb_test_name } } } Simon
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index bdb8da9daf98..abc67fb2b9e2 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9138,7 +9138,7 @@ proc get_set_option_choices {set_cmd} { with_set max-completions unlimited { gdb_test_multiple $cmd $test { - -re "\r\n$set_cmd (\[^\r\n\]+)" { + -re "\r\n$set_cmd (\[^\r\n\]+)\r\n" { lappend values $expect_out(1,string) exp_continue }