From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id nxSnK0jGrWjbxAwAWB0awg (envelope-from ) for ; Tue, 26 Aug 2025 10:35:52 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=REOqxb5g; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 984851E048; Tue, 26 Aug 2025 10:35:52 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no 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 B25E11E023 for ; Tue, 26 Aug 2025 10:35:51 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0B0BB382E828 for ; Tue, 26 Aug 2025 14:35:51 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 001C4385B50C for ; Tue, 26 Aug 2025 14:35:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 001C4385B50C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 001C4385B50C 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=1756218923; cv=none; b=EYfauo0Je3jtgA5B3qBi/ApIeJxDuI/9fIPrVUzB+lHk66opYOLY+jOhn2PBQaDE/urPl8jXi7W61FV8T3YOVMX7/AoBpokigMWaM48uKXnMvjk78+vUszveSZH4fnTulP4+LBq/s5yzJ/0JTuvlzNpQvs1JgBNyvWnZfNyrrx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1756218923; c=relaxed/simple; bh=jjBrESKePq7q+cVo3B8/zTrk3PYVjWAsDlcUfJTAkxI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RYM4YsEFyjWly3udkfGTvV2yTa2Uhu8tXi7abvSyavnNO0tn0Ga9eA7BHJUOIFkR8ICPxVpzTWDd/tVNgtUSyKzRmaqk2O0E8qzye+R6bU0Exl+L1jOgMIDdAIls03ZUKuCdM6Jv2sYn2io+Ch6MbzzapWSeLIjfxs60vLWctUs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756218921; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UoBavDgzMRQllStuw4463RUaDbQIAg1H6iy9NcHaXD0=; b=REOqxb5gcfbpginx88sTuPRbA/mu8MqsKUhSwRehWSkfGF4Q8VEqsoWbj2mqH3RA78qM/J vsDoccWzq8PaGfFwhkgd8HzosvCp2BCLBFsk4p0qocxhsTk3miE8L5/ZtQQR4VWOS98uNT JQLSu+gSXML4u7nIAoahPhUr6hpkaFU= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-298-h5PGDgYLO7C_sN0X4l7msQ-1; Tue, 26 Aug 2025 10:35:19 -0400 X-MC-Unique: h5PGDgYLO7C_sN0X4l7msQ-1 X-Mimecast-MFC-AGG-ID: h5PGDgYLO7C_sN0X4l7msQ_1756218918 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45a1b0098c0so39839925e9.0 for ; Tue, 26 Aug 2025 07:35:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756218918; x=1756823718; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UoBavDgzMRQllStuw4463RUaDbQIAg1H6iy9NcHaXD0=; b=djagdp3huT1PGMyUP0u1z50S0HEixLlvMf+QfAbpdzpnKl8fMa39qSxgBON68N85u4 GG1aaYRXQ7Ta6jR0IFizKFeJ0Ip5DnvuzRtfwvHoAFGXAZOoXdTGm0iqczlnG9lAFwan hR0ljYGhjDewPHw9SJetCIo8wDZsu3xRqgsauqolNtbEiOG0KM7k0D0oM6x0ydr6r41E i9KBvsRb71lCMWwE0gSqSFU6jlbdKv2IQo5C3vsO9uagPM+skb7DJxlEpnj/5NQK0WKs U4LHFZmhpeGAYJQnTG4pZXUfVg7NBjM78IJgTlW844i9QAOOQ8nFI0NHFTnaKV47EkoR n4SA== X-Gm-Message-State: AOJu0YwdoJKpnKTp+o0CxDLxgxUAn2uZJbwYFCaXCSQefiofbxVsw++2 nRi5hoatXtRIfNR042mUzUIcDrVGWi1KISuQaLuTzvTeGt0yrzV1odOhYqgaNJCpydxbAo7VFJA rTAAUi1G4OC81hbsyFh3EAzezJ3hnkPbstxzvFOg+wp5f44pZepIUSGaF3e9hpo29ptNGQJW+nO Dl4/1w/dBtoInbrogYYS92+R9Y09CUjQA31GVmP6p1Gvh+z5k= X-Gm-Gg: ASbGnctj55RzxFoCCkgcKewzpoNdYTSQzbUSuq9f+PPI9Q1YSv+mHqnyRnkQgf29fBA jF4ZZh+dkV8GHHsHxobEpLCcV1o08aSxYhZ0zNx0PmLb6R+1PyXieXqqVD2XYUZy31XsDEY7318 NjWzlpQkBssU6COo3HU/9YY1WCqnsXCYWOtdBRwxAwFkBI/H3cneaIMdoBShM1JmHGZJ5nbgvoK 7ZKc/Ef5c0ZHBL3CHDvH7Ria4kafkdAaC1USL6+zZs9kuRbigONI5FIugmMrlVYms2Nae7+uPS8 UfWnxN8Ss2+NZ4aaygAdPzYbwyAdnhK6yNE= X-Received: by 2002:a05:6000:40df:b0:3c7:5844:333d with SMTP id ffacd0b85a97d-3c758443855mr9307649f8f.45.1756218917532; Tue, 26 Aug 2025 07:35:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/eIulteXBx45AFpCl8IGD7uPvlRD/Ou/Cq5Zatsnczpwi9TWU4E0FAJ6z1TktDzgJ9sSuzA== X-Received: by 2002:a05:6000:40df:b0:3c7:5844:333d with SMTP id ffacd0b85a97d-3c758443855mr9307620f8f.45.1756218916993; Tue, 26 Aug 2025 07:35:16 -0700 (PDT) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cad431ea49sm5401345f8f.42.2025.08.26.07.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Aug 2025 07:35:16 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , Tom de Vries , Guinevere Larsen Subject: [PATCH] gdb/testsuite: work around empty substring bug in expect Date: Tue, 26 Aug 2025 15:35:14 +0100 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: <7af123b1-ded2-40bb-b6af-7c5d4bb6f17a@suse.de> References: <7af123b1-ded2-40bb-b6af-7c5d4bb6f17a@suse.de> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mMwE6QAiqIf5bhEIVeaKi5YGhPdfhEAKMLjG3wBoI7s_1756218918 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 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. 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 -- 2.47.1