public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Bunt <ricbun01@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Restore original GDB prompt in define.exp
Date: Wed, 10 Jul 2019 13:17:00 -0000	[thread overview]
Message-ID: <20190710131701.88185.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b863685d70199489b3fe27abedfb1eb6d1452b7d

commit b863685d70199489b3fe27abedfb1eb6d1452b7d
Author: Richard Bunt <richard.bunt@arm.com>
Date:   Wed Jul 10 14:14:16 2019 +0100

    Restore original GDB prompt in define.exp
    
    define.exp will fail on a GDB which has set a custom prompt to identify
    itself.  This is because the test resets the prompt to a hard coded
    "(gdb)" but then verifies the success of this against the value in
    $gdb_prompt, which is set to the custom prompt.
    
    The original approach to fix this involved resetting the prompt to
    $gdb_prompt rather than a hard coded "(gdb)". However it was noted during
    review that $gdb_prompt is a regular expression rather than a string.
    This is problematic because in general the prompt would be reset to a
    regular expression rather than an instance of a string accepted by said
    regular expression.
    
    The fix used in this commit avoids the above issue by capturing the
    literal prompt from running "show prompt" and uses this literal to
    restore the previous prompt.
    
    Regression tested with GCC 7.3.0 on x86_64, ppc64le, aarch64.
    
    gdb/testsuite/ChangeLog:
    2019-07-10  Richard Bunt  <richard.bunt@arm.com>
    	Stephen Roberts  <stephen.roberts@arm.com>
    
    	* gdb.base/define.exp: Restore original prompt.

Diff:
---
 gdb/testsuite/ChangeLog           |  5 +++++
 gdb/testsuite/gdb.base/define.exp | 11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index fcf86bd..0118420 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-07-10  Richard Bunt  <richard.bunt@arm.com>
+	Stephen Roberts  <stephen.roberts@arm.com>
+
+	* gdb.base/define.exp: Restore original prompt.
+
 2019-07-09  Pedro Alves  <palves@redhat.com>
 
 	* gdb.cp/catch-multi-stdlib.exp: Adjust expected "info
diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp
index 0590da9..e8508b8 100644
--- a/gdb/testsuite/gdb.base/define.exp
+++ b/gdb/testsuite/gdb.base/define.exp
@@ -283,6 +283,15 @@ gdb_test_multiple "define target hookpost-testsuite" "" {
 
 gdb_test "target testsuite" "one\r\nhello\r\ntwo" "target testsuite with hooks"
 
+# Save the GDB prompt so it can be restored to the original value later.
+set prior_prompt ""
+gdb_test_multiple "show prompt" "save gdb_prompt" {
+    -re "Gdb's prompt is \"($gdb_prompt) \"\.\[\r\n\]*$gdb_prompt $" {
+	set prior_prompt $expect_out(1,string)
+	pass "save gdb_prompt"
+    }
+}
+
 # This is a quasi-define command: Verify that the user can redefine
 # GDB's gdb_prompt.
 #
@@ -292,7 +301,7 @@ gdb_test_multiple "set prompt \\(blah\\) " "set gdb_prompt" {
     }
 }
 
-gdb_test_multiple "set prompt \\(gdb\\) " "reset gdb_prompt" {
+gdb_test_multiple "set prompt $prior_prompt " "reset gdb_prompt" {
     -re "$gdb_prompt $" {
 	pass "reset gdb_prompt"
     }


                 reply	other threads:[~2019-07-10 13:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190710131701.88185.qmail@sourceware.org \
    --to=ricbun01@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).