This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

MI testsuite improvements


Hi,

This patch is a prerequisite to the patch that includes the syntax
checker for the MI output commands.

It does several things,
   - Gives the inferior it's own PTY to send output to
   - Turn's echo'ing off on the GDB terminal side
   - Anchor's all output, from begining to end
   - Update's MI testcase's to deal with changes
   - Changes mi_gdb_test to take another parameter, called IPATTERN,
     that simply matches the output of the inferior.

This greatly improves the amount of error checking done by the
testsuite, since it checks *all* output of GDB, at least when GDB
responds with a "PASS" status from mi_gdb_test.

Finally, the mi_inferior_spawn_id global was added to mi-support.exp.
This can be used by testscripts directly to check the output of the
inferior. However, only mi-console.exp use's it. If mi-console.exp can
be changed, like I mentioned about here,
   http://sources.redhat.com/ml/gdb/2005-02/msg00066.html
then the global can be removed, and mi-console.exp can simply call
mi_gdb_test.

Thanks,
Bob Rossi

2005-02-10  Bob Rossi  <bob@brasko.net>

    * gdb.mi/mi-console.exp: Use global 'mi_inferior_spawn_id' and change
    gdb_expect to use expect -i $mi_inferior_spawn_id
    * gdb.mi/mi2-console.exp: Ditto
    * gdb.mi/mi-disassemble.exp: Remove unneeded .* in match and escaped the
    '|' charachter.
    * gdb.mi/mi-disassemble.exp: Ditto
    * gdb.mi/mi-syn-frame.exp: 403-exec-continue now use's mi_gdb_test
    same for 406-data-evaluate-expression, same for 408-exec-continue,
    same for 410-data-evaluate-expression
    * gdb.mi/mi-syn-frame.exp: Ditto
    * lib/mi-support.exp (mi_inferior_spawn_id): add global
    (mi_gdb_start): spawn a new pty for inferior
    Send 'tty' and 'stty -echo' command's to GDB
    (mi_delete_breakpoints): No need to match .* anymore
    No need to match echo'd command
    (mi_gdb_file_cmd):  No need to match echo'd command
    (mi_gdb_test): Add IPATTERN parameter,
    Match the output of the inferior to IPATTERN

Index: src/gdb/testsuite/gdb.mi/mi-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-console.exp,v
retrieving revision 1.12
diff -w -u -r1.12 mi-console.exp
--- src/gdb/testsuite/gdb.mi/mi-console.exp	9 Aug 2004 16:32:44 -0000	1.12
+++ src/gdb/testsuite/gdb.mi/mi-console.exp	10 Feb 2005 13:33:52 -0000
@@ -34,6 +34,7 @@
 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
+global mi_inferior_spawn_id
 
 gdb_exit
 if [mi_gdb_start] {
@@ -64,11 +65,11 @@
     }
 }
 
-gdb_expect {
-    -re "@\"H\"\r\n.*@\"e\"\r\n.*@\"l\"\r\n.*@\"l\"\r\n.*@\"o\"\r\n.*@\" \"\r\n.*@\"\\\\\\\\\"\r\n.*@\"\\\\\"\"\r\n.*@\"!\"\r\n.*@\"\\\\r\"\r\n.*@\"\\\\n\"\r\n" {
+expect {
+    -i $mi_inferior_spawn_id -re "@\"H\"\r\n.*@\"e\"\r\n.*@\"l\"\r\n.*@\"l\"\r\n.*@\"o\"\r\n.*@\" \"\r\n.*@\"\\\\\\\\\"\r\n.*@\"\\\\\"\"\r\n.*@\"!\"\r\n.*@\"\\\\r\"\r\n.*@\"\\\\n\"\r\n" {
 	pass "Hello message"
     }
-    -re "Hello" {
+    -i $mi_inferior_spawn_id -re "Hello" {
 
 	# Probably a native system where GDB doesn't have direct
 	# control over the inferior console.
Index: src/gdb/testsuite/gdb.mi/mi-disassemble.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-disassemble.exp,v
retrieving revision 1.13
diff -w -u -r1.13 mi-disassemble.exp
--- src/gdb/testsuite/gdb.mi/mi-disassemble.exp	15 Aug 2004 10:15:58 -0000	1.13
+++ src/gdb/testsuite/gdb.mi/mi-disassemble.exp	10 Feb 2005 13:33:52 -0000
@@ -163,7 +163,7 @@
     # -data-disassembly -f basics.c -l 32 -- 9
 
     mi_gdb_test "123-data-disassemble -f foo -l abc -n 0 -- 0" \
-             ".*123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
+             "123\\^error,msg=\"mi_cmd_disassemble: Invalid filename.\"" \
              "data-disassemble bogus filename"
 
     mi_gdb_test "321-data-disassemble -s foo -e bar -- 0" \
@@ -171,7 +171,7 @@
              "data-disassemble bogus address"
 
     mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
-             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
+             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
              "data-disassemble mix different args"
 
     mi_gdb_test "789-data-disassemble -f basics.c -l $line_main_body -- 9" \
Index: src/gdb/testsuite/gdb.mi/mi-syn-frame.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-syn-frame.exp,v
retrieving revision 1.2
diff -w -u -r1.2 mi-syn-frame.exp
--- src/gdb/testsuite/gdb.mi/mi-syn-frame.exp	24 Feb 2003 20:15:47 -0000	1.2
+++ src/gdb/testsuite/gdb.mi/mi-syn-frame.exp	10 Feb 2005 13:33:52 -0000
@@ -58,16 +58,10 @@
 #
 # Continue back to main()
 #
-
-send_gdb "403-exec-continue\n"
-gdb_expect {
-  -re "403\\^running\[\r\n\]+${my_mi_gdb_prompt}hi in foo\[\r\n\]+403\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "403-exec-continue"
-  }
-  timeout {
-    fail "403-exec-continue"
-  }
-}
+mi_gdb_test "403-exec-continue" \
+			"403\\^running\[\r\n\]+${my_mi_gdb_prompt}403\\\*stopped" \
+			"hi in foo\[\r\n\]\+" \
+			"testing exec continue"
 
 mi_gdb_test "404-stack-list-frames 0 0" "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
 
@@ -78,7 +72,11 @@
 
 mi_gdb_test "405-break-insert subroutine" "405\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\",times=\"0\"\}"
 
-mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" "Waiting to get a signal\[\r\n\]+\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\""
+mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" \
+            "\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\"" \
+			"Waiting to get a signal\[\r\n\]+" \
+			"data evaluate expression"
+
 
 # We should have both a signal handler and a call dummy frame
 # in this next output.
@@ -86,15 +84,8 @@
 mi_gdb_test "407-stack-list-frames" "407\\^done,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"subroutine\",args=\\\[\{name=\"in\",value=\"$decimal\"\}\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"<signal handler called>\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",func=\"have_a_very_merry_interrupt\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
 
 
-send_gdb "408-exec-continue\n"
-gdb_expect {
-  -re "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "408-exec-continue"
-  }
-  timeout {
-    fail "408-exec-continue"
-  }
-}
+mi_gdb_test "408-exec-continue" \
+			"408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped"
 
 mi_gdb_test "409-stack-list-frames 0 0" "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
 
@@ -102,7 +93,10 @@
 # Call bar() by hand, which should get an exception while running.
 # 
 
-mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" "call inferior function which raises exception"
+mi_gdb_test "410-data-evaluate-expression bar()" \
+            "\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" \
+			"hi in bar\[\r\n\]+" \
+			"call inferior function which raises exception" 
 
 mi_gdb_test "411-stack-list-frames" "411\\^done,reason=\"signal-received\",signal-name=\".*\",signal-meaning=\".*\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"bar\",args=\\\[\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception"
 
Index: src/gdb/testsuite/gdb.mi/mi2-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-console.exp,v
retrieving revision 1.2
diff -w -u -r1.2 mi2-console.exp
--- src/gdb/testsuite/gdb.mi/mi2-console.exp	9 Aug 2004 22:21:54 -0000	1.2
+++ src/gdb/testsuite/gdb.mi/mi2-console.exp	10 Feb 2005 13:33:52 -0000
@@ -34,6 +34,7 @@
 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi2"
+global mi_inferior_spawn_id
 
 gdb_exit
 if [mi_gdb_start] {
@@ -64,11 +65,11 @@
     }
 }
 
-gdb_expect {
-    -re "@\"H\"\r\n.*@\"e\"\r\n.*@\"l\"\r\n.*@\"l\"\r\n.*@\"o\"\r\n.*@\" \"\r\n.*@\"\\\\\\\\\"\r\n.*@\"\\\\\"\"\r\n.*@\"!\"\r\n.*@\"\\\\r\"\r\n.*@\"\\\\n\"\r\n" {
+expect {
+    -i $mi_inferior_spawn_id -re "@\"H\"\r\n.*@\"e\"\r\n.*@\"l\"\r\n.*@\"l\"\r\n.*@\"o\"\r\n.*@\" \"\r\n.*@\"\\\\\\\\\"\r\n.*@\"\\\\\"\"\r\n.*@\"!\"\r\n.*@\"\\\\r\"\r\n.*@\"\\\\n\"\r\n" {
 	pass "Hello message"
     }
-    -re "Hello" {
+    -i $mi_inferior_spawn_id -re "Hello" {
 
 	# Probably a native system where GDB doesn't have direct
 	# control over the inferior console.
Index: src/gdb/testsuite/gdb.mi/mi2-disassemble.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-disassemble.exp,v
retrieving revision 1.3
diff -w -u -r1.3 mi2-disassemble.exp
--- src/gdb/testsuite/gdb.mi/mi2-disassemble.exp	15 Aug 2004 10:15:58 -0000	1.3
+++ src/gdb/testsuite/gdb.mi/mi2-disassemble.exp	10 Feb 2005 13:33:52 -0000
@@ -171,7 +171,7 @@
              "data-disassemble bogus address"
 
     mi_gdb_test "456-data-disassemble -s \$pc -f basics.c -- 0" \
-             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. | .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
+             "456\\^error,msg=\"mi_cmd_disassemble: Usage: \\( .-f filename -l linenum .-n howmany.. \\| .-s startaddr -e endaddr.\\) .--. mixed_mode.\"" \
              "data-disassemble mix different args"
 
     mi_gdb_test "789-data-disassemble -f basics.c -l $line_main_body -- 9" \
Index: src/gdb/testsuite/gdb.mi/mi2-syn-frame.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-syn-frame.exp,v
retrieving revision 1.1
diff -w -u -r1.1 mi2-syn-frame.exp
--- src/gdb/testsuite/gdb.mi/mi2-syn-frame.exp	7 Aug 2003 17:47:42 -0000	1.1
+++ src/gdb/testsuite/gdb.mi/mi2-syn-frame.exp	10 Feb 2005 13:33:52 -0000
@@ -59,15 +59,10 @@
 # Continue back to main()
 #
 
-send_gdb "403-exec-continue\n"
-gdb_expect {
-  -re "403\\^running\[\r\n\]+${my_mi_gdb_prompt}hi in foo\[\r\n\]+403\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "403-exec-continue"
-  }
-  timeout {
-    fail "403-exec-continue"
-  }
-}
+mi_gdb_test "403-exec-continue" \
+			"403\\^running\[\r\n\]+${my_mi_gdb_prompt}403\\\*stopped" \
+			"hi in foo\[\r\n\]\+" \
+			"testing exec continue"
 
 mi_gdb_test "404-stack-list-frames 0 0" "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
 
@@ -78,23 +73,18 @@
 
 mi_gdb_test "405-break-insert subroutine" "405\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\",times=\"0\"\}"
 
-mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" "Waiting to get a signal\[\r\n\]+\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\""
+mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" \
+            "\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\"" \
+			"Waiting to get a signal\[\r\n\]+" \
+			"data evaluate expression"
 
 # We should have both a signal handler and a call dummy frame
 # in this next output.
 
 mi_gdb_test "407-stack-list-frames" "407\\^done,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"subroutine\",args=\\\[\{name=\"in\",value=\"$decimal\"\}\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"<signal handler called>\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",func=\"have_a_very_merry_interrupt\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
 
-
-send_gdb "408-exec-continue\n"
-gdb_expect {
-  -re "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "408-exec-continue"
-  }
-  timeout {
-    fail "408-exec-continue"
-  }
-}
+mi_gdb_test "408-exec-continue" \
+			"408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped"
 
 mi_gdb_test "409-stack-list-frames 0 0" "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
 
@@ -102,7 +92,10 @@
 # Call bar() by hand, which should get an exception while running.
 # 
 
-mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" "call inferior function which raises exception"
+mi_gdb_test "410-data-evaluate-expression bar()" \
+            "\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" \
+			"hi in bar\[\r\n\]+" \
+			"call inferior function which raises exception" 
 
 mi_gdb_test "411-stack-list-frames" "411\\^done,reason=\"signal-received\",signal-name=\".*\",signal-meaning=\".*\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"bar\",args=\\\[\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception"
 
Index: src/gdb/testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.24
diff -w -u -r1.24 mi-support.exp
--- src/gdb/testsuite/lib/mi-support.exp	18 Jan 2004 15:23:30 -0000	1.24
+++ src/gdb/testsuite/lib/mi-support.exp	10 Feb 2005 13:33:53 -0000
@@ -28,6 +28,8 @@
     set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
 }
 
+global mi_inferior_spawn_id
+
 set MIFLAGS "-i=mi"
 
 #
@@ -117,6 +119,13 @@
 	    exit 1
 	}
     }
+
+	# spawn off the new pty for the inferior process
+	spawn -pty
+	global mi_inferior_spawn_id
+	set mi_inferior_spawn_id $spawn_id
+	set mi_inferior_tty_name $spawn_out(slave,name)
+	
     set res [remote_spawn host "$GDB -nw $GDBFLAGS $MIFLAGS [host_info gdb_opts]"];
     if { $res < 0 || $res == "" } {
 	perror "Spawning $GDB failed."
@@ -189,6 +198,26 @@
 	    warning "Couldn't set the width to 0."
 	}
     }
+    # set the inferior output to the new created terminal device
+    send_gdb "102-interpreter-exec console \"tty $mi_inferior_tty_name\"\n"
+    gdb_expect 10 {
+	-re ".*$mi_gdb_prompt$" {
+	    verbose "redirect inferior output to new terminal device."
+	}
+	timeout {
+	    warning "Couldn't redirect inferior output." 2
+	}
+    }
+    # tell GDB not to echo
+    send_gdb "103-interpreter-exec console \"shell stty -echo\"\n"
+    gdb_expect 10 {
+	-re ".*$mi_gdb_prompt$" {
+	    verbose "turning off the terminal echoing" 2
+	}
+	timeout {
+	    warning "Couldn't turn off the terminal's echoing."
+	}
+    }
 
     return 0;
 }
@@ -209,7 +238,7 @@
 	    send_gdb "y\n";
 	    exp_continue
          }
-	 -re ".*102-break-delete\r\n102\\\^done\r\n$mi_gdb_prompt$" {
+	 -re "102\\\^done\r\n$mi_gdb_prompt$" {
             # This happens if there were no breakpoints
 	 }
 	 timeout { perror "Delete all breakpoints in mi_delete_breakpoints (timeout)" ; return }
@@ -219,9 +248,9 @@
 # empty BreakpointTable. Also, a query is not acceptable with mi.
     send_gdb "103-break-list\n"
     gdb_expect 30 {
-	 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{\}\r\n$mi_gdb_prompt$" {}
-	 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[\\\]\}" {}
-	 -re "103-break-list\r\n103\\\^doneNo breakpoints or watchpoints.\r\n\r\n$mi_gdb_prompt$" {warning "Unexpected console text received"}
+	 -re "103\\\^done,BreakpointTable=\{\}\r\n$mi_gdb_prompt$" {}
+	 -re "103\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[\\\]\}" {}
+	 -re "103\\\^doneNo breakpoints or watchpoints.\r\n\r\n$mi_gdb_prompt$" {warning "Unexpected console text received"}
 	 -re "$mi_gdb_prompt$" { perror "Breakpoints not deleted" ; return }
 	 -re "Delete all breakpoints.*or n.*$" {
 	    warning "Unexpected prompt for breakpoints deletion";
@@ -396,7 +425,7 @@
             perror "($arg) No such file or directory\n"
             return -1
         }
-        -re "105-file-exec-and-symbols .*\r\n105\\\^done\r\n$mi_gdb_prompt$" {
+        -re "105\\\^done\r\n$mi_gdb_prompt$" {
             # We (MI) are just giving the prompt back for now, instead of giving
 	    # some acknowledgement.
 	    return 0
@@ -516,12 +545,14 @@
     return 0
 }
 
-# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
+# mi_gdb_test COMMAND PATTERN IPATTERN MESSAGE -- send a command to gdb; test the result.
 #
 # COMMAND is the command to execute, send to GDB with send_gdb.  If
 #   this is the null string no command is sent.
 # PATTERN is the pattern to match for a PASS, and must NOT include
 #   the \r\n sequence immediately before the gdb prompt.
+# IPATTERN is the pattern to match for the inferior's output. This will not 
+#   produce a PASS if successfull, but will produce a FAIL if unsuccessful.
 # MESSAGE is an optional message to be printed.  If this is
 #   omitted, then the pass/fail messages use the command string as the
 #   message.  (If this is the empty string, then sometimes we don't
@@ -538,14 +569,20 @@
     global GDB expect_out
     upvar timeout timeout
 
-    if [llength $args]>2 then {
+    if { [llength $args] == 3} {
 	set message [lindex $args 2]
+    } elseif {[llength $args] == 4 } {
+	set message [lindex $args 3]
     } else {
 	set message [lindex $args 0]
     }
     set command [lindex $args 0]
     set pattern [lindex $args 1]
 
+    if [llength $args]==4 {
+	set ipattern [lindex $args 2]
+    }
+
     if [llength $args]==5 {
 	set question_string [lindex $args 3];
 	set response_string [lindex $args 4];
@@ -624,7 +661,7 @@
 	    gdb_start
 	    set result -1
 	}
-	 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" {
+	 -re "^(.*$pattern\[\r\n\]+$mi_gdb_prompt\[ \]*)$" {
 	    if ![string match "" $message] then {
 		pass "$message"
 	    }
@@ -696,6 +733,21 @@
 	    set result 1
 	}
     }
+
+    # if the GDB output matched, compare the inferior output
+    if { $result == 0 } {
+	if [ info exists ipattern ] {
+	    global mi_inferior_spawn_id
+	    expect {
+		-i $mi_inferior_spawn_id -re "$ipattern" {}
+		timeout {
+		    fail "inferior output timeout"
+		    set result 1
+		}
+	    }
+        }
+    }
+
     return $result
 }
 
@@ -864,11 +916,11 @@
     global decimal
     send_gdb "220-$cmd\n"
     gdb_expect {
-	-re ".*220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\".*$file\",line=\"$line\"\}$extra\r\n$mi_gdb_prompt$" {
+	-re "220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\".*$file\",line=\"$line\"\}$extra\r\n$mi_gdb_prompt$" {
 	    pass "$test"
 	    return 0
 	}
-	-re ".*220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\".*\",args=\[\\\[\{\].*\[\\\]\}\],file=\".*\",line=\"\[0-9\]*\"\}.*\r\n$mi_gdb_prompt$" {
+	-re "220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\".*\",args=\[\\\[\{\].*\[\\\]\}\],file=\".*\",line=\"\[0-9\]*\"\}.*\r\n$mi_gdb_prompt$" {
 	    fail "$test (stopped at wrong place)"
 	    return -1
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]