From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DF7A43857C49 for ; Tue, 29 Mar 2022 14:26:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DF7A43857C49 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-660-bbmovIhtNSuKBqVUzY36vQ-1; Tue, 29 Mar 2022 10:26:36 -0400 X-MC-Unique: bbmovIhtNSuKBqVUzY36vQ-1 Received: by mail-wm1-f70.google.com with SMTP id z16-20020a05600c0a1000b0038bebbd8548so940641wmp.3 for ; Tue, 29 Mar 2022 07:26:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Nnun5ENySuW6kmKteKlyquA9Ah5ehSkxmFo/dwK2RBo=; b=gKj6kt7MmcGbgA44njcTT88tFF1eqho5lQNGsUqIOuLQeHYwOIHLOuHOeXJEgGKeTs 6IOVbCiziwwzp836TfbvPfpxOyIdIsBdoAONK0wI7hfh3WpC6DLAYubIyE0PS9L+6qMO ig2Esc7Rn2ki9vSc/O9SbbmssT2QtN8XBtES4OseobOu/Ar9PD9ehTRCyryOSOLIqYi5 xn2rz2YtSuiSy1MO3OwU/HVq7CeoR335cMhWE4W6912sv8E2qdN0BYaqf+i+5ELZt2ym p6scBEsQsRglXaDiClKw3GWavevogphaCzYxBtZfihOriOWPSIpyvk5eiRosiA2ZkOFb Zo6g== X-Gm-Message-State: AOAM533sr1iq7UIhCGYOjpw07jBpfIquzbRU5ovN68SADXF292ZaWNZ1 ktechb5XmCTPYKlxZoc6+5t0E2MhDfJYJV9pfSnzHEmYCHN6WFw07KIZZ8uQLpzpDolrawFrEE0 eNnsNcnRzvmp1eYo5Twbd7Sujju0ZZANdtL3K1l0VlFIP3Q/+T1i//JRhajZcv65lTLeIqsVaww == X-Received: by 2002:a05:6000:b:b0:205:911a:3dfa with SMTP id h11-20020a056000000b00b00205911a3dfamr31263390wrx.373.1648563994381; Tue, 29 Mar 2022 07:26:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4kHlevhws/gNRVw89u6LWIP+2PSrr+j07Vgezedyg1ost1jzkxNA5KmYTgw5aorqVu5hP3g== X-Received: by 2002:a05:6000:b:b0:205:911a:3dfa with SMTP id h11-20020a056000000b00b00205911a3dfamr31263359wrx.373.1648563994032; Tue, 29 Mar 2022 07:26:34 -0700 (PDT) Received: from localhost (host86-169-131-113.range86-169.btcentralplus.com. [86.169.131.113]) by smtp.gmail.com with ESMTPSA id a11-20020a5d456b000000b0020406ce0e06sm14715870wrc.94.2022.03.29.07.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 07:26:33 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv4 1/3] gdb: improved EOF handling when using readline 7 Date: Tue, 29 Mar 2022 15:26:27 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2022 14:26:40 -0000 In this commit: commit a6b413d24ccc5d76179bab866834e11fd6fec294 Date: Fri Mar 11 14:44:03 2022 +0000 gdb: work around prompt corruption caused by bracketed-paste-mode a change was made to GDB to work around bug PR gdb/28833. The consequence of this work around is that, when bracketed paste mode is enabled in readline, and GDB is quit by sending EOF, then the output will look like this: (gdb) quit The ideal output, which is what we get when bracketed paste mode is off, is this: (gdb) quit The reason we need to make this change is explained in the original commit referenced above. What isn't mentioned in the above commit, is that the change that motivated this work around was only added in readline 8, older versions of readline don't require the change. In later commits in this series I will add a fix to GDB's in-tree copy of readline (this fix is back-ported from upstream readline), and then I will change GDB so that, when using the (patched) in-tree readline, we can have the ideal output in all cases. However, GDB can be built against the system readline. When this is done, and the system readline is version 8, then we will still have to use the work around (two line) style output. But, if GDB is built against the system readline, and the system readline is an older version 7 readline, then there's no reason why we can't have the ideal output, after all, readline 7 doesn't include the change that we need to work around. This commit changes GDB so that, when using readline 7 we get the ideal output in all cases. This change is trivial (a simple check against the readline version number) so I think this should be fine to include. For testing this commit, you need to configure GDB including the '--with-system-readline' flag, and build GDB on a system that uses readline 7, for example 'Ubuntu 18.04'. Then run the test 'gdb.base/eof-exit.exp', you should expect everything to PASS. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28833 --- gdb/event-top.c | 3 ++- gdb/testsuite/gdb.base/eof-exit.exp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/event-top.c b/gdb/event-top.c index 3ba7239518e..a5686488976 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -783,7 +783,8 @@ command_line_handler (gdb::unique_xmalloc_ptr &&rl) we first print '\n' to move to the next line, and then print the quit. This isn't ideal, but avoids corrupting the prompt. */ const char *value = rl_variable_value ("enable-bracketed-paste"); - if (value != nullptr && strcmp (value, "on") == 0) + if (value != nullptr && strcmp (value, "on") == 0 + && ((rl_readline_version >> 8) & 0xff) > 0x07) printf_unfiltered ("\n"); printf_unfiltered ("quit\n"); execute_command ("quit", 1); diff --git a/gdb/testsuite/gdb.base/eof-exit.exp b/gdb/testsuite/gdb.base/eof-exit.exp index 2d9530ccebe..ad5f33d2f10 100644 --- a/gdb/testsuite/gdb.base/eof-exit.exp +++ b/gdb/testsuite/gdb.base/eof-exit.exp @@ -49,7 +49,7 @@ proc run_test {} { # line after the 'quit', this catches that case. fail $gdb_test_name } - -re "$::gdb_prompt quit\[^\n\]*\r\n\[^\n\]*$" { + -re "$::gdb_prompt \[^\n\r\]*quit\[^\n\]*\r\n\[^\n\]*$" { pass $gdb_test_name } eof { -- 2.25.4