Remove unneeded pattern matching in gdb.base/maint.exp

Message ID 1480698345-9779-1-git-send-email-lgustavo@codesourcery.com
State New, archived
Headers

Commit Message

Luis Machado Dec. 2, 2016, 5:05 p.m. UTC
  This gets rid of more useless pattern matching cases in gdb.base/maint.exp. It
is a follow-on to the previous patch that only removed the timeouts.

Regression-checked by running gdb.base/maint.exp.

gdb/testsuite/ChangeLog:

2016-12-02  Luis Machado  <lgustavo@codesourcery.com>

	* gdb.base/maint.exp: Remove gdb_prompt and timeout handling in
	gdb_test_multiple calls.
	Use gdb_test instead of gdb_test_multiple when possible.
---
 gdb/testsuite/gdb.base/maint.exp | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)
  

Comments

Pedro Alves Dec. 2, 2016, 5:30 p.m. UTC | #1
On 12/02/2016 05:05 PM, Luis Machado wrote:
> This gets rid of more useless pattern matching cases in gdb.base/maint.exp. It
> is a follow-on to the previous patch that only removed the timeouts.
> 
> Regression-checked by running gdb.base/maint.exp.
> 
> gdb/testsuite/ChangeLog:
> 
> 2016-12-02  Luis Machado  <lgustavo@codesourcery.com>
> 
> 	* gdb.base/maint.exp: Remove gdb_prompt and timeout handling in
> 	gdb_test_multiple calls.
> 	Use gdb_test instead of gdb_test_multiple when possible.
> ---
>  gdb/testsuite/gdb.base/maint.exp | 27 ++++++++-------------------
>  1 file changed, 8 insertions(+), 19 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
> index 17c606b..9d08ff1 100644
> --- a/gdb/testsuite/gdb.base/maint.exp
> +++ b/gdb/testsuite/gdb.base/maint.exp
> @@ -71,7 +71,7 @@ gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
>  gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
>  gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
>      "mt expand-symtabs" {
> -	-re "#compunits: (1|2) \\(\[+\](0|1|2)\\),.*$gdb_prompt $" {
> +	-re "#compunits: (1|2) \\(\[+\](0|1|2)\\),.*" {

Why are you removing this ...

>  	    # This should expand at most two primary symtabs.
>  	    # "Normally" it will not expand any, because the symtab
>  	    # holding "main" will already have been expanded, but if the
> @@ -93,7 +93,7 @@ if ![runto_main] then {
>  # If we're using .gdb_index there will be no psymtabs.
>  set have_gdb_index 0
>  gdb_test_multiple "maint info sections .gdb_index" "check for .gdb_index" {
> -    -re ": .gdb_index.*$gdb_prompt $" {
> +    -re ": .gdb_index.*" {
>  	set have_gdb_index 1
>      }

... and this ...

>      -re ".*$gdb_prompt $" {
> @@ -287,29 +287,18 @@ gdb_test "cd [standard_output_file {}]" \
>      "cd to objdir"
>  
>  gdb_test_multiple "maint print msymbols msymbols_output2 ${testfile}" "maint print msymbols" {
> -    -re "^maint print msymbols msymbols_output2 \[^\n\]*\r\n$gdb_prompt $" {
> +    -re "^maint print msymbols msymbols_output2 \[^\n\]*\r\n" {

... and this?

>      	gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" {
>  	    -re "msymbols_output2\r\n$gdb_prompt $" {
> -	    	gdb_test_multiple "shell grep factorial msymbols_output2" "maint print msymbols" {
> -		    -re "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*$gdb_prompt $" {
> -		    	pass "maint print msymbols"
> -		    }
> -		    -re ".*$gdb_prompt $" {
> -		        fail "maint print msymbols"
> -		    }
> -		}
> -		gdb_test "shell rm -f msymbols_output2" ".*" \
> -		    "shell rm -f msymbols_output2"
> -	    }
> -	    -re ".*$gdb_prompt $" {
> -		fail "maint print msymbols"
> +		gdb_test "shell grep factorial msymbols_output2" \
> +		    "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \
> +		    "maint print msymbols"
> +		gdb_test "shell rm -f msymbols_output2" ".*"
>  	    }
>  	}
>      }
> -    -re ".*$gdb_prompt $" {
> -	fail "maint print msymbols"
> -    }
>  }
> +
>  gdb_test "cd ${mydir}" \
>      "Working directory [string_to_regexp ${mydir}]\..*" \
>      "cd to mydir"
> 

This part looks OK.

Thanks,
Pedro Alves
  
Luis Machado Dec. 2, 2016, 5:40 p.m. UTC | #2
On 12/02/2016 11:30 AM, Pedro Alves wrote:
> On 12/02/2016 05:05 PM, Luis Machado wrote:
>> This gets rid of more useless pattern matching cases in gdb.base/maint.exp. It
>> is a follow-on to the previous patch that only removed the timeouts.
>>
>> Regression-checked by running gdb.base/maint.exp.
>>
>> gdb/testsuite/ChangeLog:
>>
>> 2016-12-02  Luis Machado  <lgustavo@codesourcery.com>
>>
>> 	* gdb.base/maint.exp: Remove gdb_prompt and timeout handling in
>> 	gdb_test_multiple calls.
>> 	Use gdb_test instead of gdb_test_multiple when possible.
>> ---
>>  gdb/testsuite/gdb.base/maint.exp | 27 ++++++++-------------------
>>  1 file changed, 8 insertions(+), 19 deletions(-)
>>
>> diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
>> index 17c606b..9d08ff1 100644
>> --- a/gdb/testsuite/gdb.base/maint.exp
>> +++ b/gdb/testsuite/gdb.base/maint.exp
>> @@ -71,7 +71,7 @@ gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
>>  gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
>>  gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
>>      "mt expand-symtabs" {
>> -	-re "#compunits: (1|2) \\(\[+\](0|1|2)\\),.*$gdb_prompt $" {
>> +	-re "#compunits: (1|2) \\(\[+\](0|1|2)\\),.*" {
>
> Why are you removing this ...
>

Doesn't gdb_test_multiple already check for a trailing $gdb_prompt?

>>  	    # This should expand at most two primary symtabs.
>>  	    # "Normally" it will not expand any, because the symtab
>>  	    # holding "main" will already have been expanded, but if the
>> @@ -93,7 +93,7 @@ if ![runto_main] then {
>>  # If we're using .gdb_index there will be no psymtabs.
>>  set have_gdb_index 0
>>  gdb_test_multiple "maint info sections .gdb_index" "check for .gdb_index" {
>> -    -re ": .gdb_index.*$gdb_prompt $" {
>> +    -re ": .gdb_index.*" {
>>  	set have_gdb_index 1
>>      }
>
> ... and this ...
>
>>      -re ".*$gdb_prompt $" {
>> @@ -287,29 +287,18 @@ gdb_test "cd [standard_output_file {}]" \
>>      "cd to objdir"
>>
>>  gdb_test_multiple "maint print msymbols msymbols_output2 ${testfile}" "maint print msymbols" {
>> -    -re "^maint print msymbols msymbols_output2 \[^\n\]*\r\n$gdb_prompt $" {
>> +    -re "^maint print msymbols msymbols_output2 \[^\n\]*\r\n" {
>
> ... and this?
>
>>      	gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" {
>>  	    -re "msymbols_output2\r\n$gdb_prompt $" {
>> -	    	gdb_test_multiple "shell grep factorial msymbols_output2" "maint print msymbols" {
>> -		    -re "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*$gdb_prompt $" {
>> -		    	pass "maint print msymbols"
>> -		    }
>> -		    -re ".*$gdb_prompt $" {
>> -		        fail "maint print msymbols"
>> -		    }
>> -		}
>> -		gdb_test "shell rm -f msymbols_output2" ".*" \
>> -		    "shell rm -f msymbols_output2"
>> -	    }
>> -	    -re ".*$gdb_prompt $" {
>> -		fail "maint print msymbols"
>> +		gdb_test "shell grep factorial msymbols_output2" \
>> +		    "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \
>> +		    "maint print msymbols"
>> +		gdb_test "shell rm -f msymbols_output2" ".*"
>>  	    }
>>  	}
>>      }
>> -    -re ".*$gdb_prompt $" {
>> -	fail "maint print msymbols"
>> -    }
>>  }
>> +
>>  gdb_test "cd ${mydir}" \
>>      "Working directory [string_to_regexp ${mydir}]\..*" \
>>      "cd to mydir"
>>
>
> This part looks OK.
>
> Thanks,
> Pedro Alves
>
>
  
Pedro Alves Dec. 2, 2016, 5:48 p.m. UTC | #3
On 12/02/2016 05:40 PM, Luis Machado wrote:

> Doesn't gdb_test_multiple already check for a trailing $gdb_prompt?

gdb_test does, but gdb_test_multiple does not.

What gdb_test_multiple has, is an internal pattern that
matches the prompt if no other user-specified pattern
matches:

	-re "\r\n$gdb_prompt $" {
	    if ![string match "" $message] then {
		fail "$message"
	    }
	    set result 1
	}

That's why the second regexp here:

   gdb_test_multiple "...." "...." {
      -re "some pattern $gdb_prompt $ {
      }
      -re ".*$gdb_prompt $ {
         fail "...."
      }
   }

... is unnecessary.

But the gdb_prompt match in the first regexp is absolutely
necessary, otherwise you leave it dangling in the expect
buffer and confuse whatever comes after.  Whether that
causes trouble or not in a given dejagnu invocation is racy,
depends on how much expect pulls in to its internal buffer
at a time.  Often, "make check-read1" will make such problems
more reproducible.  But just don't introduce the problem in
the first place, please.  :-)

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 17c606b..9d08ff1 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -71,7 +71,7 @@  gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
 gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
 gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
     "mt expand-symtabs" {
-	-re "#compunits: (1|2) \\(\[+\](0|1|2)\\),.*$gdb_prompt $" {
+	-re "#compunits: (1|2) \\(\[+\](0|1|2)\\),.*" {
 	    # This should expand at most two primary symtabs.
 	    # "Normally" it will not expand any, because the symtab
 	    # holding "main" will already have been expanded, but if the
@@ -93,7 +93,7 @@  if ![runto_main] then {
 # If we're using .gdb_index there will be no psymtabs.
 set have_gdb_index 0
 gdb_test_multiple "maint info sections .gdb_index" "check for .gdb_index" {
-    -re ": .gdb_index.*$gdb_prompt $" {
+    -re ": .gdb_index.*" {
 	set have_gdb_index 1
     }
     -re ".*$gdb_prompt $" {
@@ -287,29 +287,18 @@  gdb_test "cd [standard_output_file {}]" \
     "cd to objdir"
 
 gdb_test_multiple "maint print msymbols msymbols_output2 ${testfile}" "maint print msymbols" {
-    -re "^maint print msymbols msymbols_output2 \[^\n\]*\r\n$gdb_prompt $" {
+    -re "^maint print msymbols msymbols_output2 \[^\n\]*\r\n" {
     	gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" {
 	    -re "msymbols_output2\r\n$gdb_prompt $" {
-	    	gdb_test_multiple "shell grep factorial msymbols_output2" "maint print msymbols" {
-		    -re "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*$gdb_prompt $" {
-		    	pass "maint print msymbols"
-		    }
-		    -re ".*$gdb_prompt $" {
-		        fail "maint print msymbols"
-		    }
-		}
-		gdb_test "shell rm -f msymbols_output2" ".*" \
-		    "shell rm -f msymbols_output2"
-	    }
-	    -re ".*$gdb_prompt $" {
-		fail "maint print msymbols"
+		gdb_test "shell grep factorial msymbols_output2" \
+		    "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*" \
+		    "maint print msymbols"
+		gdb_test "shell rm -f msymbols_output2" ".*"
 	    }
 	}
     }
-    -re ".*$gdb_prompt $" {
-	fail "maint print msymbols"
-    }
 }
+
 gdb_test "cd ${mydir}" \
     "Working directory [string_to_regexp ${mydir}]\..*" \
     "cd to mydir"