public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA] gdb.mi/*.exp, send_gdb vs. gdb_test
@ 2010-05-26  1:55 Michael Snyder
  2010-05-26  7:49 ` Vladimir Prus
  2010-08-26 15:06 ` Pedro Alves
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Snyder @ 2010-05-26  1:55 UTC (permalink / raw)
  To: gdb-patches, Vladimir Prus

[-- Attachment #1: Type: text/plain, Size: 29 bytes --]

Not as large as it looks...


[-- Attachment #2: mi.exp.txt --]
[-- Type: text/plain, Size: 19812 bytes --]

2010-05-25  Michael Snyder  <msnyder@msnyder-server.eng.vmware.com>

	* gdb.mi/mi-basics.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi-nonstop-exit.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi-nonstop.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi-ns-stale-regcache.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi-nsintrall.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi-nsmoribund.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi-nsthrexec.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi-return.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi-var-display.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi2-basics.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi2-console.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi2-return.exp: Replace send_gdb with gdb_test.
	* gdb.mi/mi2-var-display.exp: Replace send_gdb with gdb_test.

Index: mi2-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-basics.exp,v
retrieving revision 1.16
diff -u -p -r1.16 mi2-basics.exp
--- mi2-basics.exp	1 Jan 2010 07:32:03 -0000	1.16
+++ mi2-basics.exp	26 May 2010 00:34:29 -0000
@@ -60,23 +60,19 @@ proc test_mi_interpreter_selection {} {
 
     # All this test expects is to get the prompt back
     # with no syntax error message
-    send_gdb "-gdb-version\n"
-    gdb_expect {
-           -re "GNU gdb .*\r\n$mi_gdb_prompt$" \
-               { pass "acceptance of MI operations" 
-                 return 1}
-           -re ".*\r\n$mi_gdb_prompt$" \
-               { fail "acceptance of MI operations"
-                 note "Skipping all other MI tests." }
-           -re "Undefined command.*$gdb_prompt $" \
-               { fail "acceptance of MI operations"
-                 note "Skipping all other MI tests." }
-           -re ".*$gdb_prompt $" \
-               { fail "acceptance of MI operations"
-                 note "Skipping all other MI tests." }
-           timeout { fail "acceptance of MI operations (timeout)"
-                     note "Skipping all other MI tests." }
+    gdb_test_multiple "-gdb-version" "acceptance of MI operations" {
+	-re "GNU gdb .*\r\n$mi_gdb_prompt$" {
+	    pass "acceptance of MI operations" 
+	    return 1
+	}
+	-re ".*\r\n$mi_gdb_prompt$" {
+	    fail "acceptance of MI operations"
+	}
+	-re "Undefined command.*$gdb_prompt $" {
+	    fail "acceptance of MI operations"
+	}
     }
+    note "Skipping all other MI tests."
     return 0
 }
 
@@ -90,14 +86,17 @@ proc test_exec_and_symbol_mi_operatons {
 
     # Can't use mi_gdb_test as if this doesn't work,
     #  we must give up on the whole test file
-    send_gdb "-file-exec-and-symbols ${binfile}\n"
-    gdb_expect {
-           -re "\[\r\n\]*\\\^done\r\n$mi_gdb_prompt$" \
-               { pass "file-exec-and-symbols operation" }
-           timeout { fail "file-exec-and-symbols operation (timeout)"
-                     note "Skipping all other MI tests."
-                     return 0}
-    }
+    gdb_test_multiple "-file-exec-and-symbols ${binfile}" \
+	"file-exec-and-symbols operation" {
+	    -re "\[\r\n\]*\\\^done\r\n$mi_gdb_prompt$" {
+		pass "file-exec-and-symbols operation"
+	    }
+	    timeout {
+		fail "file-exec-and-symbols operation (timeout)"
+		note "Skipping all other MI tests."
+		return 0
+	    }
+	}
 
     # The following is not used by mi-support.exp, but we test here so
     # we get done with loading a program basics.
@@ -210,14 +209,13 @@ proc test_path_specification {} {
     # -environment-path -r dir
     # -environment-path -r
 
-    send_gdb "-environment-path\n"
-    gdb_expect 20 {
+    gdb_test_multiple "-environment-path" "-environment-path" {
 	-re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" { 
-	  set orig_path $expect_out(1,string); 
+	    set orig_path $expect_out(1,string); 
 	}
 	timeout { 
-	  perror "-environment-path (timeout)" ; 
-	  return 
+	    perror "-environment-path (timeout)" ; 
+	    return 
 	}
     }
 
Index: mi2-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-console.exp,v
retrieving revision 1.14
diff -u -p -r1.14 mi2-console.exp
--- mi2-console.exp	1 Jan 2010 07:32:03 -0000	1.14
+++ mi2-console.exp	26 May 2010 00:34:29 -0000
@@ -48,14 +48,10 @@ if  { [gdb_compile "${srcdir}/${subdir}/
 mi_run_to_main
 
 # Next over the hello() call which will produce lots of output
-send_gdb "220-exec-next\n"
-gdb_expect {
+gdb_test_multiple "220-exec-next" "Started step over hello" {
     -re "220\\^running\r\n(\\*running,thread-id=\"all\"\r\n)?$mi_gdb_prompt" {
 	pass "Started step over hello"
     }
-    timeout {
-	fail "Started step over hello (timeout)"
-    }
 }
 
 if { ![target_info exists gdb,noinferiorio] } {
Index: mi2-return.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-return.exp,v
retrieving revision 1.12
diff -u -p -r1.12 mi2-return.exp
--- mi2-return.exp	1 Jan 2010 07:32:03 -0000	1.12
+++ mi2-return.exp	26 May 2010 00:34:29 -0000
@@ -53,11 +53,9 @@ proc test_return_simple {} {
     set line_callee3_call         [expr $line_callee3_head + 2]
     set line_callee3_close_brace  [expr $line_callee3_head + 3]
 
-    send_gdb "111-exec-return\n"
-    gdb_expect {
-	-re "111\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"($line_callee3_call|$line_callee3_close_brace)\"\}\r\n$mi_gdb_prompt$" {pass "return from callee4 now"}
-	-re ".*\r\n$mi_gdb_prompt$" { fail "return from callee4 now" }
-	timeout { fail "return from callee4 now (timeout)"
+    gdb_test_multiple "111-exec-return" "return from callee4 now" {
+	-re "111\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"($line_callee3_call|$line_callee3_close_brace)\"\}\r\n$mi_gdb_prompt$" {
+	    pass "return from callee4 now"
 	}
     }
 }
Index: mi2-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-var-display.exp,v
retrieving revision 1.27
diff -u -p -r1.27 mi2-var-display.exp
--- mi2-var-display.exp	1 Jan 2010 07:32:03 -0000	1.27
+++ mi2-var-display.exp	26 May 2010 00:34:29 -0000
@@ -605,14 +605,11 @@ mi_gdb_test "-var-list-children anone" \
 
 # Record fp
 
-send_gdb "p/x \$fp\n"
-gdb_expect {
+gdb_test_multiple "p/x \$fp" "print FP register" {
     -re ".*($hex).*\\^done\r\n$mi_gdb_prompt$" { 
 	pass "print FP register"
 	set fp $expect_out(1,string) 
     }
-#    -re ".*" { fail "print FP register"}
-    timeout { fail "print FP register (timeout)"}
 }
 
 mi_continue_to "incr_a"
Index: mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.24
diff -u -p -r1.24 mi-basics.exp
--- mi-basics.exp	1 Jan 2010 07:32:03 -0000	1.24
+++ mi-basics.exp	26 May 2010 00:34:29 -0000
@@ -60,23 +60,19 @@ proc test_mi_interpreter_selection {} {
 
     # All this test expects is to get the prompt back
     # with no syntax error message
-    send_gdb "-gdb-version\n"
-    gdb_expect {
-           -re "GNU gdb .*\r\n$mi_gdb_prompt$" \
-               { pass "acceptance of MI operations" 
-                 return 1}
-           -re ".*\r\n$mi_gdb_prompt$" \
-               { fail "acceptance of MI operations"
-                 note "Skipping all other MI tests." }
-           -re "Undefined command.*$gdb_prompt $" \
-               { fail "acceptance of MI operations"
-                 note "Skipping all other MI tests." }
-           -re ".*$gdb_prompt $" \
-               { fail "acceptance of MI operations"
-                 note "Skipping all other MI tests." }
-           timeout { fail "acceptance of MI operations (timeout)"
-                     note "Skipping all other MI tests." }
+    gdb_test_multiple "-gdb-version" "acceptance of MI operations" {
+	-re "GNU gdb .*\r\n$mi_gdb_prompt$" {
+	    pass "acceptance of MI operations"
+	    return 1
+	}
+	-re ".*\r\n$mi_gdb_prompt$" {
+	    fail "acceptance of MI operations"
+	}
+	-re "Undefined command.*$gdb_prompt $" {
+	    fail "acceptance of MI operations"
+	}
     }
+    note "Skipping all other MI tests."
     return 0
 }
 
@@ -90,14 +86,17 @@ proc test_exec_and_symbol_mi_operatons {
 
     # Can't use mi_gdb_test as if this doesn't work,
     #  we must give up on the whole test file
-    send_gdb "-file-exec-and-symbols ${binfile}\n"
-    gdb_expect {
-           -re "\[\r\n\]*\\\^done\r\n$mi_gdb_prompt$" \
-               { pass "file-exec-and-symbols operation" }
-           timeout { fail "file-exec-and-symbols operation (timeout)"
-                     note "Skipping all other MI tests."
-                     return 0}
-    }
+    gdb_test_multiple "-file-exec-and-symbols ${binfile}" \
+	"-file-exec-and-symbols ${binfile}" {
+	    -re "\[\r\n\]*\\\^done\r\n$mi_gdb_prompt$" {
+		pass "file-exec-and-symbols operation"
+	    }
+	    timeout {
+		fail "file-exec-and-symbols operation (timeout)"
+		note "Skipping all other MI tests."
+		return 0
+	    }
+	}
 
     # The following is not used by mi-support.exp, but we test here so
     # we get done with loading a program basics.
@@ -208,14 +207,13 @@ proc test_path_specification {} {
     # -environment-path -r dir
     # -environment-path -r
 
-    send_gdb "-environment-path\n"
-    gdb_expect 20 {
+    gdb_test_multiple "-environment-path" "-environment-path" {
 	-re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" { 
-	  set orig_path $expect_out(1,string); 
+	    set orig_path $expect_out(1,string); 
 	}
 	timeout { 
-	  perror "-environment-path (timeout)" ; 
-	  return 
+	    perror "-environment-path (timeout)" ; 
+	    return 
 	}
     }
 
Index: mi-nonstop-exit.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-nonstop-exit.exp,v
retrieving revision 1.3
diff -u -p -r1.3 mi-nonstop-exit.exp
--- mi-nonstop-exit.exp	1 Jan 2010 07:32:03 -0000	1.3
+++ mi-nonstop-exit.exp	26 May 2010 00:34:29 -0000
@@ -37,14 +37,13 @@ mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load $binfile
 
 set supported 0
-send_gdb "-gdb-show non-stop\n"
-gdb_expect {
+gdb_test_multiple "-gdb-show non-stop" "" {
     -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
         if { $expect_out(1,string) == "1" } {
             set supported 1
         }
     }
-    -re ".$mi_gdb_prompt$" {
+    -re ".*$mi_gdb_prompt$" {
     }
 }
 
Index: mi-nonstop.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-nonstop.exp,v
retrieving revision 1.11
diff -u -p -r1.11 mi-nonstop.exp
--- mi-nonstop.exp	24 Feb 2010 07:51:46 -0000	1.11
+++ mi-nonstop.exp	26 May 2010 00:34:29 -0000
@@ -47,14 +47,13 @@ mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load $binfile
 
 set supported 0
-send_gdb "-gdb-show non-stop\n"
-gdb_expect {
+gdb_test_multiple "-gdb-show non-stop" "" {
     -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
 	if { $expect_out(1,string) == "1" } {
 	    set supported 1
 	}
     }
-    -re ".$mi_gdb_prompt$" {
+    -re ".*$mi_gdb_prompt$" {
     }
 }
 
@@ -94,14 +93,10 @@ mi_varobj_update * {I_W1 I_W0} "update v
 mi_check_varobj_value I_W0 1 "check varobj, w0, 1"
 mi_check_varobj_value I_W1 1 "check varobj, w1, 1"
 
-send_gdb "-exec-interrupt --thread 1\n"
-gdb_expect {
+gdb_test_multiple "-exec-interrupt --thread 1" "interrupted" {
     -re "\\^done\r\n$mi_gdb_prompt\\*stopped\[^\r\n\]+\r\n$" {
 	pass "interrupted"
     }
-    timeout {
-	fail "interrupted (timeout)"
-    }
 }
 # The interrupt command sends SIGINT to the target, and therefore the
 # thread might not be stopped immediately when we return from the target.
@@ -109,14 +104,10 @@ gdb_expect {
 sleep 1
 mi_check_thread_states {"stopped" "stopped" "stopped"} "thread state, stop 4"
 
-send_gdb "-exec-continue --all\n"
-gdb_expect {
+gdb_test_multiple "-exec-continue --all" "resume all" {
     -re ".*\\*running,thread-id=\"3\"\r\n\\*running,thread-id=\"2\"\r\n\\*running,thread-id=\"1\"\r\n$mi_gdb_prompt" {
 	pass "resume all"
     }
-    timeout {
-	fail "resume all (timeout)"
-    }
 }
 
 mi_expect_stop "breakpoint-hit" "break_at_me" "\[^\n\]*" "non-stop.c" "\[0-9\]*" {"" "disp=\"keep\""} "w0,i2 stop"
Index: mi-nsintrall.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-nsintrall.exp,v
retrieving revision 1.5
diff -u -p -r1.5 mi-nsintrall.exp
--- mi-nsintrall.exp	1 Jan 2010 07:32:03 -0000	1.5
+++ mi-nsintrall.exp	26 May 2010 00:34:29 -0000
@@ -37,14 +37,13 @@ mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load $binfile
 
 set supported 0
-send_gdb "-gdb-show non-stop\n"
-gdb_expect {
+gdb_test_multiple "-gdb-show non-stop\n" "" {
     -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
 	if { $expect_out(1,string) == "1" } {
 	    set supported 1
 	}
     }
-    -re ".$mi_gdb_prompt$" {
+    -re ".*$mi_gdb_prompt$" {
     }
 }
 
@@ -78,14 +77,10 @@ for {set i 6} {$i > 0} {incr i -1} {
     set running_re "$running_re\\*running,thread-id=\"$i\"\r\n"
 }
 
-send_gdb "-exec-continue --all\n"
-gdb_expect {
+gdb_test_multiple "-exec-continue --all" "resume all, no breakpoint" {
     -re ".*$running_re$mi_gdb_prompt" {
 	pass "resume all, no breakpoint"
     }
-    timeout {
-	fail "resume all, no breakpoint (timeout)"
-    }
 }
 mi_check_thread_states \
     {"running" "running" "running" "running" "running" "running"} \
@@ -101,14 +96,10 @@ mi_check_thread_states \
     "thread state, all interrupted"
 
 # resume all threads, and check that no thread is spuriously left interrupted
-send_gdb "-exec-continue --all\n"
-gdb_expect {
+gdb_test_multiple "-exec-continue --all" "resume all after interrupting" {
     -re ".*$running_re$mi_gdb_prompt" {
 	pass "resume all after interrupting"
     }
-    timeout {
-	fail "resume all after interrupting (timeout)"
-    }
 }
 
 sleep 1
Index: mi-nsmoribund.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-nsmoribund.exp,v
retrieving revision 1.5
diff -u -p -r1.5 mi-nsmoribund.exp
--- mi-nsmoribund.exp	1 Jan 2010 07:32:03 -0000	1.5
+++ mi-nsmoribund.exp	26 May 2010 00:34:29 -0000
@@ -37,14 +37,13 @@ mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load $binfile
 
 set supported 0
-send_gdb "-gdb-show non-stop\n"
-gdb_expect {
+gdb_test_multiple "-gdb-show non-stop" "" {
     -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
 	if { $expect_out(1,string) == "1" } {
 	    set supported 1
 	}
     }
-    -re ".$mi_gdb_prompt$" {
+    -re ".*$mi_gdb_prompt$" {
     }
 }
 
@@ -99,14 +98,10 @@ for {set i $nthreads} {$i > 0} {incr i -
     set running_re "$running_re\\*running,thread-id=\"$decimal\"\r\n"
 }
 
-send_gdb "-exec-continue --all\n"
-gdb_expect {
+gdb_test_multiple "-exec-continue --all" "resume all, thread specific breakpoint" {
     -re ".*$running_re$mi_gdb_prompt" {
 	pass "resume all, thread specific breakpoint"
     }
-    timeout {
-	fail "resume all, thread specific breakpoint (timeout)"
-    }
 }
 
 mi_expect_stop "breakpoint-hit" "thread_function" "\[^\n\]*" "$srcfile" \
@@ -128,20 +123,14 @@ mi_check_thread_states \
 # a target bug if it can step over breakpoints itself), a spurious
 # SIGTRAP/SIGSEGV can come at any time after deleting the breakpoint.
 
-send_gdb "102-break-delete\n"
-send_gdb "print done = 1\n"
-send_gdb "103-exec-continue --all\n"
-
-gdb_expect {
-    -re "\\*stopped,reason=\"exited-normally\"" {
-	pass "resume all, program exited normally"
-    }
-    -re "\\*stopped" {
-	fail "unexpected stop"
-    }
-    timeout {
-	fail "resume all, waiting for program exit (timeout)"
+gdb_test_multiple "102-break-delete\nprint done = 1\n103-exec-continue --all" \
+    "resume all, program exited normally" {
+	-re "\\*stopped,reason=\"exited-normally\"" {
+	    pass "resume all, program exited normally"
+	}
+	-re "\\*stopped" {
+	    fail "unexpected stop"
+	}
     }
-}
 
 mi_gdb_exit
Index: mi-ns-stale-regcache.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp,v
retrieving revision 1.1
diff -u -p -r1.1 mi-ns-stale-regcache.exp
--- mi-ns-stale-regcache.exp	29 Apr 2010 16:33:16 -0000	1.1
+++ mi-ns-stale-regcache.exp	26 May 2010 00:34:29 -0000
@@ -51,14 +51,13 @@ mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load $binfile
 
 set supported 0
-send_gdb "-gdb-show non-stop\n"
-gdb_expect {
+gdb_test_multiple "-gdb-show non-stop" "" {
     -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
 	if { $expect_out(1,string) == "1" } {
 	    set supported 1
 	}
     }
-    -re ".$mi_gdb_prompt$" {
+    -re ".*$mi_gdb_prompt$" {
     }
 }
 
Index: mi-nsthrexec.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-nsthrexec.exp,v
retrieving revision 1.2
diff -u -p -r1.2 mi-nsthrexec.exp
--- mi-nsthrexec.exp	1 Jan 2010 07:32:03 -0000	1.2
+++ mi-nsthrexec.exp	26 May 2010 00:34:29 -0000
@@ -47,14 +47,13 @@ mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load $binfile
 
 set supported 0
-send_gdb "-gdb-show non-stop\n"
-gdb_expect {
+gdb_test_multiple "-gdb-show non-stop" "" {
     -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
 	if { $expect_out(1,string) == "1" } {
 	    set supported 1
 	}
     }
-    -re ".$mi_gdb_prompt$" {
+    -re ".*$mi_gdb_prompt$" {
     }
 }
 
Index: mi-return.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-return.exp,v
retrieving revision 1.20
diff -u -p -r1.20 mi-return.exp
--- mi-return.exp	1 Jan 2010 07:32:03 -0000	1.20
+++ mi-return.exp	26 May 2010 00:34:29 -0000
@@ -53,11 +53,9 @@ proc test_return_simple {} {
     set line_callee3_call         [expr $line_callee3_head + 2]
     set line_callee3_close_brace  [expr $line_callee3_head + 3]
 
-    send_gdb "111-exec-return\n"
-    gdb_expect {
-	-re "111\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"($line_callee3_call|$line_callee3_close_brace)\"\}\r\n$mi_gdb_prompt$" {pass "return from callee4 now"}
-	-re ".*\r\n$mi_gdb_prompt$" { fail "return from callee4 now" }
-	timeout { fail "return from callee4 now (timeout)"
+    gdb_test_multiple "111-exec-return" "return from callee4 now" {
+	-re "111\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"($line_callee3_call|$line_callee3_close_brace)\"\}\r\n$mi_gdb_prompt$" {
+	    pass "return from callee4 now"
 	}
     }
 }
Index: mi-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-display.exp,v
retrieving revision 1.34
diff -u -p -r1.34 mi-var-display.exp
--- mi-var-display.exp	1 Jan 2010 07:32:03 -0000	1.34
+++ mi-var-display.exp	26 May 2010 00:34:29 -0000
@@ -606,14 +606,11 @@ mi_gdb_test "-var-list-children anone" \
 
 # Record fp
 
-send_gdb "p/x \$fp\n"
-gdb_expect {
+gdb_test_multiple "p/x \$fp" "print FP register" {
     -re ".*($hex).*\\^done\r\n$mi_gdb_prompt$" { 
 	pass "print FP register"
 	set fp $expect_out(1,string) 
     }
-#    -re ".*" { fail "print FP register"}
-    timeout { fail "print FP register (timeout)"}
 }
 
 mi_continue_to "incr_a"

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA] gdb.mi/*.exp, send_gdb vs. gdb_test
  2010-05-26  1:55 [RFA] gdb.mi/*.exp, send_gdb vs. gdb_test Michael Snyder
@ 2010-05-26  7:49 ` Vladimir Prus
  2010-05-26 17:07   ` Michael Snyder
  2010-08-26 15:06 ` Pedro Alves
  1 sibling, 1 reply; 5+ messages in thread
From: Vladimir Prus @ 2010-05-26  7:49 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches

On Wednesday 26 May 2010 04:36:02 Michael Snyder wrote:

> -    send_gdb "-gdb-version\n"
> -    gdb_expect {
> -           -re "GNU gdb .*\r\n$mi_gdb_prompt$" \
> -               { pass "acceptance of MI operations" 
> -                 return 1}
> -           -re ".*\r\n$mi_gdb_prompt$" \
> -               { fail "acceptance of MI operations"
> -                 note "Skipping all other MI tests." }
> -           -re "Undefined command.*$gdb_prompt $" \
> -               { fail "acceptance of MI operations"
> -                 note "Skipping all other MI tests." }
> -           -re ".*$gdb_prompt $" \
> -               { fail "acceptance of MI operations"
> -                 note "Skipping all other MI tests." }
> -           timeout { fail "acceptance of MI operations (timeout)"
> -                     note "Skipping all other MI tests." }
> +    gdb_test_multiple "-gdb-version" "acceptance of MI operations" {

You replace send_gdb with gdb_test_multiple, while changelog say you
replace with gdb_test.

> +    note "Skipping all other MI tests."

This seem to be emitted unconditionally now? It was previously emitted
on timeout only. There are two such issues in -- mi-basics and mi2-basics.
Seems OK otherwise.

- Volodya




Thanks,

-- 
Vladimir Prus
CodeSourcery
vladimir@codesourcery.com
(650) 331-3385 x722

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA] gdb.mi/*.exp, send_gdb vs. gdb_test
  2010-05-26  7:49 ` Vladimir Prus
@ 2010-05-26 17:07   ` Michael Snyder
  2010-06-02  8:49     ` Vladimir Prus
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2010-05-26 17:07 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: gdb-patches

Vladimir Prus wrote:
> On Wednesday 26 May 2010 04:36:02 Michael Snyder wrote:
> 
>> -    send_gdb "-gdb-version\n"
>> -    gdb_expect {
>> -           -re "GNU gdb .*\r\n$mi_gdb_prompt$" \
>> -               { pass "acceptance of MI operations" 
>> -                 return 1}
>> -           -re ".*\r\n$mi_gdb_prompt$" \
>> -               { fail "acceptance of MI operations"
>> -                 note "Skipping all other MI tests." }
>> -           -re "Undefined command.*$gdb_prompt $" \
>> -               { fail "acceptance of MI operations"
>> -                 note "Skipping all other MI tests." }
>> -           -re ".*$gdb_prompt $" \
>> -               { fail "acceptance of MI operations"
>> -                 note "Skipping all other MI tests." }
>> -           timeout { fail "acceptance of MI operations (timeout)"
>> -                     note "Skipping all other MI tests." }
>> +    gdb_test_multiple "-gdb-version" "acceptance of MI operations" {
> 
> You replace send_gdb with gdb_test_multiple, while changelog say you
> replace with gdb_test.
> 
>> +    note "Skipping all other MI tests."
> 
> This seem to be emitted unconditionally now? It was previously emitted
> on timeout only. There are two such issues in -- mi-basics and mi2-basics.
> Seems OK otherwise.

It's not unconditional.  The "pass" clause includes a return, so this
note will only be emitted on failure.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA] gdb.mi/*.exp, send_gdb vs. gdb_test
  2010-05-26 17:07   ` Michael Snyder
@ 2010-06-02  8:49     ` Vladimir Prus
  0 siblings, 0 replies; 5+ messages in thread
From: Vladimir Prus @ 2010-06-02  8:49 UTC (permalink / raw)
  To: gdb-patches

Michael Snyder wrote:

> Vladimir Prus wrote:
>> On Wednesday 26 May 2010 04:36:02 Michael Snyder wrote:
>> 
>>> -    send_gdb "-gdb-version\n"
>>> -    gdb_expect {
>>> -           -re "GNU gdb .*\r\n$mi_gdb_prompt$" \
>>> -               { pass "acceptance of MI operations"
>>> -                 return 1}
>>> -           -re ".*\r\n$mi_gdb_prompt$" \
>>> -               { fail "acceptance of MI operations"
>>> -                 note "Skipping all other MI tests." }
>>> -           -re "Undefined command.*$gdb_prompt $" \
>>> -               { fail "acceptance of MI operations"
>>> -                 note "Skipping all other MI tests." }
>>> -           -re ".*$gdb_prompt $" \
>>> -               { fail "acceptance of MI operations"
>>> -                 note "Skipping all other MI tests." }
>>> -           timeout { fail "acceptance of MI operations (timeout)"
>>> -                     note "Skipping all other MI tests." }
>>> +    gdb_test_multiple "-gdb-version" "acceptance of MI operations" {
>> 
>> You replace send_gdb with gdb_test_multiple, while changelog say you
>> replace with gdb_test.
>> 
>>> +    note "Skipping all other MI tests."
>> 
>> This seem to be emitted unconditionally now? It was previously emitted
>> on timeout only. There are two such issues in -- mi-basics and mi2-basics.
>> Seems OK otherwise.
> 
> It's not unconditional.  The "pass" clause includes a return, so this
> note will only be emitted on failure.

OK, then this is not an issue.

- Volodya



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA] gdb.mi/*.exp, send_gdb vs. gdb_test
  2010-05-26  1:55 [RFA] gdb.mi/*.exp, send_gdb vs. gdb_test Michael Snyder
  2010-05-26  7:49 ` Vladimir Prus
@ 2010-08-26 15:06 ` Pedro Alves
  1 sibling, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2010-08-26 15:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Michael Snyder, Vladimir Prus

On Wednesday 26 May 2010 01:36:02, Michael Snyder wrote:
>         * gdb.mi/mi-nsmoribund.exp: Replace send_gdb with gdb_test.

> Index: mi-nsmoribund.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-nsmoribund.exp,v
> retrieving revision 1.5
> diff -u -p -r1.5 mi-nsmoribund.exp
> --- mi-nsmoribund.exp   1 Jan 2010 07:32:03 -0000       1.5
> +++ mi-nsmoribund.exp   26 May 2010 00:34:29 -0000
> @@ -37,14 +37,13 @@ mi_gdb_reinitialize_dir $srcdir/$subdir

(...)

> @@ -128,20 +123,14 @@ mi_check_thread_states \
>  # a target bug if it can step over breakpoints itself), a spurious
>  # SIGTRAP/SIGSEGV can come at any time after deleting the breakpoint.
>  
> -send_gdb "102-break-delete\n"
> -send_gdb "print done = 1\n"
> -send_gdb "103-exec-continue --all\n"
> -
> -gdb_expect {
> -    -re "\\*stopped,reason=\"exited-normally\"" {
> -       pass "resume all, program exited normally"
> -    }
> -    -re "\\*stopped" {
> -       fail "unexpected stop"
> -    }
> -    timeout {
> -       fail "resume all, waiting for program exit (timeout)"
> +gdb_test_multiple "102-break-delete\nprint done = 1\n103-exec-continue --all" \
> +    "resume all, program exited normally" {
> +       -re "\\*stopped,reason=\"exited-normally\"" {
> +           pass "resume all, program exited normally"
> +       }
> +       -re "\\*stopped" {
> +           fail "unexpected stop"
> +       }
>      }
> -}
>  

This particular change introduces a race that causes an
ocasional spurious FAIL:

 FAIL: gdb.mi/mi-nsmoribund.exp: resume all, program exited normally

The test says:

 # (...) Send all commands in a row, since if something
 # goes wrong with moribund locations support or displaced stepping (or
 # a target bug if it can step over breakpoints itself), a spurious
 # SIGTRAP/SIGSEGV can come at any time after deleting the breakpoint.

Each of those commands will produce one prompt:

 102-break-delete
 102^done
 (gdb) 
 print done = 1
 103-exec-continue --all
 &"print done = 1\n"
 ~"$1 = 1"
 ~"\n"
 ^done
 (gdb) 
 103^running
 *running,thread-id="5"
 (gdb) FAIL: gdb.mi/mi-nsmoribund.exp: resume all, program exited normally

which depending on how data appears on expect's buffer, can
make gdb_test_multiple think that's an error:

gdb_test_multiple has:
...
	 -re "\r\n$gdb_prompt $" {
	    if ![string match "" $message] then {
		fail "$message"
	    }
...


I've switched back that particular test in mi-nsmoribund.exp
to send_gdb/gdb_expect to fix this.

This particular test is just more susceptible to this race
than other uses of gdb_test_multiple in gdb.mi/, but I think
all such uses are in fact wrong, since $gdb_prompt is a prefix
of $mi_gdb_prompt,

    set gdb_prompt "\[(\]gdb\[)\]"
    set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"

and that happens to match that gdb_test_multiple regex shown
above, so, any gdb_test_multiple that has 

 -re "... .. ... $mi_gdb_prompt"

is racy.  Plus, gdb_test_multiple is tied to CLI's output internally.
The fact that it works most of the time appears only to be a fortunate
accident.  Should we have an mi_gdb_test_multiple instead?  Either
that, or I think we should consider reverting all gdb_test_multiple
uses under gdb.mi/ back to send_gdb/gdb_test.

-- 
Pedro Alves

2010-08-26  Pedro Alves  <pedro@codesourcery.com>

	* gdb.mi/mi-nsmoribund.exp: Revert back to send_gdb/gdb_expect in
	one test.

---
 gdb/testsuite/gdb.mi/mi-nsmoribund.exp |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

Index: src/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.mi/mi-nsmoribund.exp	2010-08-26 15:35:37.000000000 +0100
+++ src/gdb/testsuite/gdb.mi/mi-nsmoribund.exp	2010-08-26 15:47:16.000000000 +0100
@@ -121,15 +121,21 @@ mi_check_thread_states \
 # goes wrong with moribund locations support or displaced stepping (or
 # a target bug if it can step over breakpoints itself), a spurious
 # SIGTRAP/SIGSEGV can come at any time after deleting the breakpoint.
+# Note that this causes multiple prompts to appear before the output
+# we are interested in, so we can't use mi_gdb_test or
+# gdb_test_multiple (or an MI equivalent).
 
-gdb_test_multiple "102-break-delete\nprint done = 1\n103-exec-continue --all" \
-    "resume all, program exited normally" {
-	-re "\\*stopped,reason=\"exited-normally\"" {
-	    pass "resume all, program exited normally"
-	}
-	-re "\\*stopped" {
-	    fail "unexpected stop"
-	}
+send_gdb "102-break-delete\n"
+send_gdb "print done = 1\n"
+send_gdb "103-exec-continue --all\n"
+
+gdb_expect {
+    -re "\\*stopped,reason=\"exited-normally\"" {
+       pass "resume all, program exited normally"
+    }
+    timeout {
+       fail "resume all, waiting for program exit (timeout)"
     }
+}
 
 mi_gdb_exit

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-08-26 15:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-26  1:55 [RFA] gdb.mi/*.exp, send_gdb vs. gdb_test Michael Snyder
2010-05-26  7:49 ` Vladimir Prus
2010-05-26 17:07   ` Michael Snyder
2010-06-02  8:49     ` Vladimir Prus
2010-08-26 15:06 ` Pedro Alves

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).