Restore original GDB prompt in define.exp

Message ID 32795df0-3a46-2b7d-3db8-2902e0f55481@arm.com
State New, archived
Headers

Commit Message

Richard Bunt July 3, 2019, 1:35 p.m. UTC
  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.

define.exp has been modified to reset the prompt to $gdb_prompt rather
than a hard coded "(gdb)".

Regression tested with GCC 7.3.0 on x86_64, ppc64le, aarch64.

gdb/testsuite/ChangeLog:

2019-06-08  Richard Bunt  <richard.bunt@arm.com>
	Stephen Roberts  <stephen.roberts@arm.com>

	* gdb.base/define.exp: Restore original prompt.

Change-Id: Ie1b883be7cd77f2208ef9db6eadde1fd0d6a4e53
---
 gdb/testsuite/gdb.base/define.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.7.4
  

Comments

Tom Tromey July 3, 2019, 2:22 p.m. UTC | #1
>>>>> "Richard" == Richard Bunt <Richard.Bunt@arm.com> writes:

Richard> 2019-06-08  Richard Bunt  <richard.bunt@arm.com>
Richard> 	Stephen Roberts  <stephen.roberts@arm.com>

Richard> 	* gdb.base/define.exp: Restore original prompt.

Thank you for the patch.

This is ok.

Richard> -gdb_test_multiple "set prompt \\(gdb\\) " "reset gdb_prompt" {
Richard> +gdb_test_multiple "set prompt $gdb_prompt " "reset gdb_prompt" {

This is peculiar because both the original code and the new code have
backslashes in the "set" command -- gdb_prompt is actually a regexp, not
just a plain string.  But, it works anyhow, I guess something along the
way is ignoring the "\".  So, although it is weird, your patch doesn't
make it any worse.

Tom
  
Andreas Schwab July 3, 2019, 2:48 p.m. UTC | #2
On Jul 03 2019, Tom Tromey <tom@tromey.com> wrote:

>>>>>> "Richard" == Richard Bunt <Richard.Bunt@arm.com> writes:
>
> Richard> -gdb_test_multiple "set prompt \\(gdb\\) " "reset gdb_prompt" {
> Richard> +gdb_test_multiple "set prompt $gdb_prompt " "reset gdb_prompt" {
>
> This is peculiar because both the original code and the new code have
> backslashes in the "set" command -- gdb_prompt is actually a regexp, not
> just a plain string.  But, it works anyhow, I guess something along the
> way is ignoring the "\".

That's because it's a var_string, not a var_string_noescape.

Andreas.
  
Richard Bunt July 4, 2019, 2:22 p.m. UTC | #3
On 7/3/19 3:48 PM, Andreas Schwab wrote:
> On Jul 03 2019, Tom Tromey <tom@tromey.com> wrote:

> 

>>>>>>> "Richard" == Richard Bunt <Richard.Bunt@arm.com> writes:

>>

>> Richard> -gdb_test_multiple "set prompt \\(gdb\\) " "reset gdb_prompt" {

>> Richard> +gdb_test_multiple "set prompt $gdb_prompt " "reset gdb_prompt" {

>>

>> This is peculiar because both the original code and the new code have

>> backslashes in the "set" command -- gdb_prompt is actually a regexp, not

>> just a plain string.  But, it works anyhow, I guess something along the

>> way is ignoring the "\".

> 

> That's because it's a var_string, not a var_string_noescape.

> 

> Andreas.

> 


Thanks for the comments.

Based on these I would like to submit a v2 (when it's ready) which saves
the literal prompt from "show prompt" and restores from this.

I think this is a more robust solution as it will not break if someone is
indeed using $gdb_prompt with a more complex regular expression and
doesn't unnecessarily rely on the escape behavior of the GDB prompt.
Note: The test case which sets the prompt to \\(blah\\) still covers this
escaping behavior, but I see no need for the prompt restore test to rely
on it.

Many thanks,

Rich
  

Patch

diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp
index 0590da9..7bd4b7e 100644
--- a/gdb/testsuite/gdb.base/define.exp
+++ b/gdb/testsuite/gdb.base/define.exp
@@ -292,7 +292,7 @@  gdb_test_multiple "set prompt \\(blah\\) " "set gdb_prompt" {
     }
 }
 
-gdb_test_multiple "set prompt \\(gdb\\) " "reset gdb_prompt" {
+gdb_test_multiple "set prompt $gdb_prompt " "reset gdb_prompt" {
     -re "$gdb_prompt $" {
 	pass "reset gdb_prompt"
     }