From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OQ+cMrykrmjwQg0AWB0awg (envelope-from ) for ; Wed, 27 Aug 2025 02:25:00 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Kj/UYoyg; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vAGFdFWx; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Kj/UYoyg; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vAGFdFWx; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B48391E048; Wed, 27 Aug 2025 02:25:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9DE441E043 for ; Wed, 27 Aug 2025 02:24:59 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D7EF1386075E for ; Wed, 27 Aug 2025 06:24:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7EF1386075E Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Kj/UYoyg; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vAGFdFWx; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Kj/UYoyg; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vAGFdFWx Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 7FF153853833 for ; Wed, 27 Aug 2025 06:24:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FF153853833 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7FF153853833 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1756275853; cv=none; b=PfZXAvKuqG/TI/+haGVCJJYCpRzNolHhCk3xcRXKbGUfnoAeZBR7Ssfa5aPnIZv/5uarTuZKLugTZTGon1nmguEb9b7s6GlBl/yBOrTg54yjoAqy0S2mPxDofdKPCM6KyiK18UqPa48VvahNrKQ8dFkipwRWylwJtOzadjYOq2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1756275853; c=relaxed/simple; bh=RdKr/FwDe3kK5hTcXvXAozpv3ETX2R3DduF7ra9x+ic=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=tIrBS3Q5/H9VL4QHkDvPr/Ml+s/yNfTNe8iUVi9RiAsZ1FOHR1oxmbTK5JEv+eg9yLItoYAO70d79r050s5/SJtnNrU8mftcA4hAmox0vxO4lPJkOshhREys+vCijZmOkI55BkBhRMF1lR9FYT+vo11r7NFxAC8pe3SP+ZDkX1g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FF153853833 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 383771FE50; Wed, 27 Aug 2025 06:24:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1756275852; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CZx+4b3Q2uCkVRstGAiAbRPjGOCTlxg2OCXbR51HZ4g=; b=Kj/UYoygVBw41C5oZj3hX7UgKpk6xQnrfueobpRFxT0zaNHjwdYyoKfUgZYZ1JRlMnaPYA qfz62vhUfpOPmDcORgvgiYaID7VWo5phuXyCOt1xc8A3CGrOFuQtc2ltAGv+OeQQ9QzzNe sCbHkidZ3Ost3jLfrrIuEFNn1EPVe2o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1756275852; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CZx+4b3Q2uCkVRstGAiAbRPjGOCTlxg2OCXbR51HZ4g=; b=vAGFdFWxk+Vvqe/SQD/bomgyrOydZ9XH8Jl3nuFuN2CQ5lKHqyG2e02XXaNsUUUzJc8gIu VRPJWi1aPRCHKMCA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1756275852; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CZx+4b3Q2uCkVRstGAiAbRPjGOCTlxg2OCXbR51HZ4g=; b=Kj/UYoygVBw41C5oZj3hX7UgKpk6xQnrfueobpRFxT0zaNHjwdYyoKfUgZYZ1JRlMnaPYA qfz62vhUfpOPmDcORgvgiYaID7VWo5phuXyCOt1xc8A3CGrOFuQtc2ltAGv+OeQQ9QzzNe sCbHkidZ3Ost3jLfrrIuEFNn1EPVe2o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1756275852; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CZx+4b3Q2uCkVRstGAiAbRPjGOCTlxg2OCXbR51HZ4g=; b=vAGFdFWxk+Vvqe/SQD/bomgyrOydZ9XH8Jl3nuFuN2CQ5lKHqyG2e02XXaNsUUUzJc8gIu VRPJWi1aPRCHKMCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 13EE213310; Wed, 27 Aug 2025 06:24:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YncDA4ykrmh/VwAAD6G6ig (envelope-from ); Wed, 27 Aug 2025 06:24:12 +0000 Message-ID: Date: Wed, 27 Aug 2025 08:24:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb/testsuite: work around empty substring bug in expect To: Andrew Burgess , gdb-patches@sourceware.org Cc: Guinevere Larsen References: <7af123b1-ded2-40bb-b6af-7c5d4bb6f17a@suse.de> Content-Language: en-US From: Tom de Vries In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email, suse.de:mid, sourceware.org:url, imap1.dmz-prg2.suse.org:helo] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 8/26/25 16:35, Andrew Burgess wrote: > There is a bug in expect, see: > > https://sourceforge.net/p/expect/patches/26/ > > which causes empty substring matches from a regexp to instead return > the complete input buffer. To reproduce this bug, try this command: > > expect -c 'spawn sh -c "echo -n -e \"abc\""; \ > expect -re "(a?)(a)(bc)"; \ > puts "\n"; \ > for { set i 1 } { $i < 4 } { incr i } { \ > puts -nonewline "($i): \""; \ > puts -nonewline $expect_out($i,string); \ > puts "\"" \ > }' > > For a working expect the output looks like: > > spawn sh -c echo -n -e "abc" > abc > > (1): "" > (2): "a" > (3): "bc" > > But for a broken expect the output looks like: > > spawn sh -c echo -n -e "abc" > abc > > (1): "abc" > (2): "a" > (3): "bc" > > Notice that (1) is now returning the complete input buffer rather than > the empty string, this is wrong. > > This is not the first time this bug has impacted GDB's testsuite, > this commit seems to be working around the same problem: > > commit e579b537353cd91cb8fac1eaeb69901d4936766f > Date: Sat Aug 16 20:32:37 2025 +0200 > > [gdb/testsuite] Fix TUI tests on freebsd > > I recently pushed this commit: > > commit 3825c972a636852600b47c242826313f4b9963b8 > Date: Wed Jun 18 15:02:29 2025 +0100 > > gdb: allow gdb.Color to work correctly with pagination > > Which added gdb.python/py-color-pagination.exp. Bug PR gdb/33321 was > then created as the test was failing on some hosts. Turns out, this > is same expect bug. > > The fix presented here is the same as for e579b537353cd91cb8, avoid > using optional regexp substrings at the start of a regexp, and instead > use two separate regexp patterns. With this change in place, the test > now passes on all hosts. > > There's no change in what is being tested after this commit. > Hi Andrew, thanks for digging into this. I've tested this patch on Tumbleweed, and it fixed the problem for me there. The patch LGTM. Approved-By: Tom de Vries - Tom > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33321 > --- > .../gdb.python/py-color-pagination.exp | 36 +++++++++++++------ > 1 file changed, 25 insertions(+), 11 deletions(-) > > diff --git a/gdb/testsuite/gdb.python/py-color-pagination.exp b/gdb/testsuite/gdb.python/py-color-pagination.exp > index 3235fffe5cc..e1ca1f1ce75 100644 > --- a/gdb/testsuite/gdb.python/py-color-pagination.exp > +++ b/gdb/testsuite/gdb.python/py-color-pagination.exp > @@ -66,18 +66,25 @@ proc test_pagination { type mode } { > exp_continue > } > > - -re "^(${::any_color}?)(${::any_color})$::str" { > + -re "^(${::any_color})(${::any_color})$::str" { > # After a continuation prompt GDB will restore the previous > # color, and then we immediately switch to a new color. > set restored_color $expect_out(1,string) > - if { $restored_color ne "" > - && $restored_color ne $expected_restore_color } { > + if { $restored_color ne $expected_restore_color } { > set saw_bad_color_handling true > } > set last_color $expect_out(2,string) > exp_continue > } > > + -re "^(${::any_color})$::str" { > + # This pattern matches printing STR in all cases that are not > + # immediately after a pagination prompt. In this case there is > + # a single escape sequence to set the color. > + set last_color $expect_out(1,string) > + exp_continue > + } > + > -re "^\033\\\[${::decimal}m$::str" { > # This catches the case where the color's escape sequence has > # not been converted back into a full style. This indicates > @@ -86,18 +93,25 @@ proc test_pagination { type mode } { > exp_continue > } > > - -re "^((?:\033\\\[m)?)$::pagination_prompt$" { > + -re "^\033\\\[m$::pagination_prompt$" { > # After a pagination prompt we expect GDB to restore the last > # color. > set expected_restore_color $last_color > > - # If we didn't see a color reset sequence then the pagination > - # prompt will have been printed in the wrong color, this is a > - # GDB bug. > - set color_reset $expect_out(1,string) > - if { $color_reset eq "" } { > - set saw_bad_color_handling true > - } > + # Send '\n' to view more output. > + send_gdb "\n" > + exp_continue > + } > + > + -re "^$::pagination_prompt$" { > + # After a pagination prompt we expect GDB to restore the last > + # color. > + set expected_restore_color $last_color > + > + # If we didn't see a color reset sequence before the pagination > + # prompt, then the prompt will have been printed in the wrong > + # color, this is a GDB bug. > + set saw_bad_color_handling true > > # Send '\n' to view more output. > send_gdb "\n" > > base-commit: 3825c972a636852600b47c242826313f4b9963b8