MI testsuite to use PTY for inferior

Bob Rossi bob@brasko.net
Wed Jul 27 03:18:00 GMT 2005


Hi,

This patch is following the acceptance of the -inferior-tty-set command.
It basically changes the MI testsuite to use a pty for the inferior,
instead of mixing output from GDB and the inferior on the same console.
The function mi_gdb_test is now capable of checking the output of both
GDB and the inferior, without major headaches. In particular, look at
the difference to the mi-console.exp testcase.

If/Once this patch is accepted, I plan on fully anchoring GDB's output
in the MI testsuite. This will ensure that everything is being matched
correctly. It will also ensure I can capture the output of the MI
command and do a syntax check against the output of all the commands.

Currently, there is a parameter to mi_gdb_start. This tells the
lib/mi-support.exp that the testsuite is capable of dealing with a PTY
for the inferior.

I think that this parameter should go away, and I should test both mi-
and mi2- with the inferior PTY. However, Andrew was unsure at the time
that this was a good idea. I'm under the impression that MI is currently
useless without the assumption that FE's are using PTY's for the
inferior console. Is it OK if I resend this patch, which would effect
both mi- and mi2-?

One other note. If you call mi_gdb_test with GDB output to match, and
inferior output to match, then 2 tests are issued, not 1. You can get 2
passed, 1 pass/1 fail or 2 failed.

Thanks,
Bob Rossi

Index: gdb/testsuite/ChangeLog
+	* gdb.mi/gdb669.exp: Tell mi_gdb_start to use a PTY for inferior.
+	Update Copyright.
+	* gdb.mi/gdb680.exp: Ditto.
+	* gdb.mi/gdb701.exp: Ditto.
+	* gdb.mi/gdb792.exp: Ditto.
+	* gdb.mi/mi-break.exp: Ditto.
+	* gdb.mi/mi-disassemble.exp: Ditto.
+	* gdb.mi/mi-eval.exp: Ditto.
+	* gdb.mi/mi-file.exp: Ditto.
+	* gdb.mi/mi-hack-cli.exp: Ditto.
+	* gdb.mi/mi-pthreads.exp: Ditto.
+	* gdb.mi/mi-read-memory.exp: Ditto.
+	* gdb.mi/mi-regs.exp: Ditto.
+	* gdb.mi/mi-simplerun.exp: Ditto.
+	* gdb.mi/mi-var-block.exp: Ditto.
+	* gdb.mi/mi-var-child.exp: Ditto.
+	* gdb.mi/mi-basics.exp: Tell mi_gdb_start to use a PTY for inferior.
+	(test_setshow_inferior_tty): Add global mi_inferior_tty_name to scope.
+	(test_setshow_inferior_tty): Change tests to inferior-tty-set/show
+	* gdb.mi/mi-cli.exp: Tell mi_gdb_start to use a PTY for inferior.
+	* gdb.mi/mi-console.exp: Ditto.
+	(47-exec-next): Use mi_gdb_test to get GDB and Inferior output.
+	* gdb.mi/mi-return.exp: Ditto.
+	* gdb.mi/mi-stack.exp: Ditto.
+	* gdb.mi/mi-stepi.exp: Ditto.
+	* gdb.mi/mi-until.exp: Ditto.
+	* gdb.mi/mi-var-cmd.exp: Ditto.
+	* gdb.mi/mi-var-display.exp: Ditto.
+	* gdb.mi/mi-watch.exp: Ditto.
+	* gdb.mi/mi-syn-frame.exp: Tell mi_gdb_start to use PTY for inferior.
+	(403-exec-continue): Use mi_gdb_test to get GDB and Inferior output.
+	(406-data-evaluate-expression have_a_very_merry_interrupt()): Ditto.
+	(410-data-evaluate-expression bar()): Ditto.
+	(408-exec-continue): Use mi_gdb_test to get GDB output.
+	* lib/mi-support.exp (mi_inferior_spawn_id): Add inferior PTY
+	descriptor.
+	(mi_inferior_tty_name): Add inferior PTY file name.
+	(mi_gdb_start): Add INERIOR_PTY parameter, if TRUE, use PTY for
+	inferior, otherwise share GDB's PTY.
+	(mi_gdb_test): Add IPATTERN parameter, match inferior output from
+	the inferior's very own PTY.

Index: gdb/testsuite/gdb.mi/gdb669.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb669.exp,v
retrieving revision 1.5
diff -w -u -r1.5 gdb669.exp
--- gdb/testsuite/gdb.mi/gdb669.exp	13 Jan 2004 17:08:03 -0000	1.5
+++ gdb/testsuite/gdb.mi/gdb669.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if {[mi_gdb_start]} {
+if {[mi_gdb_start true]} {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/gdb680.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb680.exp,v
retrieving revision 1.1
diff -w -u -r1.1 gdb680.exp
--- gdb/testsuite/gdb.mi/gdb680.exp	3 Sep 2002 16:37:00 -0000	1.1
+++ gdb/testsuite/gdb.mi/gdb680.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002 Free Software Foundation, Inc.
+# Copyright 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/gdb701.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb701.exp,v
retrieving revision 1.1
diff -w -u -r1.1 gdb701.exp
--- gdb/testsuite/gdb.mi/gdb701.exp	16 Sep 2002 19:01:43 -0000	1.1
+++ gdb/testsuite/gdb.mi/gdb701.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002 Free Software Foundation, Inc.
+# Copyright 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/gdb792.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb792.exp,v
retrieving revision 1.4
diff -w -u -r1.4 gdb792.exp
--- gdb/testsuite/gdb.mi/gdb792.exp	9 Aug 2004 16:32:44 -0000	1.4
+++ gdb/testsuite/gdb.mi/gdb792.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002, 2003 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.10
diff -w -u -r1.10 mi-basics.exp
--- gdb/testsuite/gdb.mi/mi-basics.exp	6 Jul 2005 14:54:37 -0000	1.10
+++ gdb/testsuite/gdb.mi/mi-basics.exp	27 Jul 2005 03:06:25 -0000
@@ -33,7 +33,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
@@ -238,6 +238,7 @@
 
 proc test_setshow_inferior_tty {} {
     global mi_gdb_prompt
+    global mi_inferior_tty_name
 
     # Test that the commands,
     #   -inferior-tty-set
@@ -245,8 +246,8 @@
     # are setting/getting the same data in GDB.
 
     mi_gdb_test "301-inferior-tty-show" \
-		"301\\\^done" \
-		"initial tty is empty"
+		"301\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
+		"initial tty is mi_inferior_tty_name"
 
     mi_gdb_test "302-inferior-tty-set /dev/pts/1" \
 		"302\\\^done" \
@@ -262,7 +263,15 @@
 
     mi_gdb_test "305-inferior-tty-show" \
 		"305\\\^done" \
-		"final tty is empty"
+		"make sure tty is empty"
+
+    mi_gdb_test "306-inferior-tty-set $mi_inferior_tty_name" \
+		"306\\\^done" \
+		"set tty to mi_inferior_tty_name (the way it was)"
+
+    mi_gdb_test "307-inferior-tty-show" \
+		"307\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
+		"verify tty is correct"
 }
 
 if [test_mi_interpreter_selection] {
Index: gdb/testsuite/gdb.mi/mi-break.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-break.exp,v
retrieving revision 1.7
diff -w -u -r1.7 mi-break.exp
--- gdb/testsuite/gdb.mi/mi-break.exp	13 Aug 2004 16:21:29 -0000	1.7
+++ gdb/testsuite/gdb.mi/mi-break.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2001, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-cli.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-cli.exp,v
retrieving revision 1.4
diff -w -u -r1.4 mi-cli.exp
--- gdb/testsuite/gdb.mi/mi-cli.exp	18 May 2005 03:41:58 -0000	1.4
+++ gdb/testsuite/gdb.mi/mi-cli.exp	27 Jul 2005 03:06:25 -0000
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-console.exp,v
retrieving revision 1.14
diff -w -u -r1.14 mi-console.exp
--- gdb/testsuite/gdb.mi/mi-console.exp	27 Apr 2005 16:35:15 -0000	1.14
+++ gdb/testsuite/gdb.mi/mi-console.exp	27 Jul 2005 03:06:25 -0000
@@ -36,7 +36,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
@@ -54,37 +54,10 @@
 mi_run_to_main
 
 # Next over the hello() call which will produce lots of output
-send_gdb "47-exec-next\n"
-gdb_expect {
-    -re "47\\^running\r\n$mi_gdb_prompt" {
-	pass "Started step over hello"
-    }
-    timeout {
-	fail "Started step over hello (timeout)"
-    }
-}
-
-if { ![target_info exists gdb,noinferiorio]}  {
-    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" {
-	    pass "Hello message"
-	}
-	-re "Hello" {
-
-	    # Probably a native system where GDB doesn't have direct #
-	    # control over the inferior console.  # For this to work,
-	    # GDB would need to run the inferior process # under a PTY
-	    # and then use the even-loops ability to wait on #
-	    # multiple event sources to channel the output back
-	    # through the # MI.
-
-	    kfail "gdb/623" "Hello message"
-	}
-	timeout {
-	    fail "Hello message (timeout)"
-	}
-    }
-}
+mi_gdb_test "47-exec-next" \
+	    "47\\^running" \
+	    "Hello \\\\\"!\[\r\n\]+" \
+	    "Testing console output"
     
 gdb_expect {
     -re "47\\*stopped.*$mi_gdb_prompt$" {
Index: 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
--- gdb/testsuite/gdb.mi/mi-disassemble.exp	15 Aug 2004 10:15:58 -0000	1.13
+++ gdb/testsuite/gdb.mi/mi-disassemble.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-eval.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-eval.exp,v
retrieving revision 1.9
diff -w -u -r1.9 mi-eval.exp
--- gdb/testsuite/gdb.mi/mi-eval.exp	15 Aug 2004 10:15:58 -0000	1.9
+++ gdb/testsuite/gdb.mi/mi-eval.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-file.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
retrieving revision 1.5
diff -w -u -r1.5 mi-file.exp
--- gdb/testsuite/gdb.mi/mi-file.exp	8 May 2005 13:42:03 -0000	1.5
+++ gdb/testsuite/gdb.mi/mi-file.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-hack-cli.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-hack-cli.exp,v
retrieving revision 1.6
diff -w -u -r1.6 mi-hack-cli.exp
--- gdb/testsuite/gdb.mi/mi-hack-cli.exp	9 Aug 2004 16:32:44 -0000	1.6
+++ gdb/testsuite/gdb.mi/mi-hack-cli.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1999, 2001, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-pthreads.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-pthreads.exp,v
retrieving revision 1.7
diff -w -u -r1.7 mi-pthreads.exp
--- gdb/testsuite/gdb.mi/mi-pthreads.exp	13 Jan 2004 17:08:03 -0000	1.7
+++ gdb/testsuite/gdb.mi/mi-pthreads.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if {[mi_gdb_start]} {
+if {[mi_gdb_start true]} {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-read-memory.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-read-memory.exp,v
retrieving revision 1.9
diff -w -u -r1.9 mi-read-memory.exp
--- gdb/testsuite/gdb.mi/mi-read-memory.exp	9 Aug 2004 16:32:44 -0000	1.9
+++ gdb/testsuite/gdb.mi/mi-read-memory.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-regs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-regs.exp,v
retrieving revision 1.12
diff -w -u -r1.12 mi-regs.exp
--- gdb/testsuite/gdb.mi/mi-regs.exp	9 Aug 2004 16:32:44 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-regs.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-return.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-return.exp,v
retrieving revision 1.12
diff -w -u -r1.12 mi-return.exp
--- gdb/testsuite/gdb.mi/mi-return.exp	18 May 2005 03:41:59 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-return.exp	27 Jul 2005 03:06:25 -0000
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-simplerun.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-simplerun.exp,v
retrieving revision 1.12
diff -w -u -r1.12 mi-simplerun.exp
--- gdb/testsuite/gdb.mi/mi-simplerun.exp	15 Aug 2004 10:15:58 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-simplerun.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-stack.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-stack.exp,v
retrieving revision 1.16
diff -w -u -r1.16 mi-stack.exp
--- gdb/testsuite/gdb.mi/mi-stack.exp	20 Jun 2005 03:38:20 -0000	1.16
+++ gdb/testsuite/gdb.mi/mi-stack.exp	27 Jul 2005 03:06:26 -0000
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-stepi.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-stepi.exp,v
retrieving revision 1.11
diff -w -u -r1.11 mi-stepi.exp
--- gdb/testsuite/gdb.mi/mi-stepi.exp	18 May 2005 03:41:59 -0000	1.11
+++ gdb/testsuite/gdb.mi/mi-stepi.exp	27 Jul 2005 03:06:26 -0000
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: 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.4
diff -w -u -r1.4 mi-syn-frame.exp
--- gdb/testsuite/gdb.mi/mi-syn-frame.exp	13 Jun 2005 02:41:51 -0000	1.4
+++ gdb/testsuite/gdb.mi/mi-syn-frame.exp	27 Jul 2005 03:06:26 -0000
@@ -38,7 +38,7 @@
 set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*"
 
 mi_gdb_exit
-mi_gdb_start
+mi_gdb_start true
 mi_delete_breakpoints
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
@@ -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\",fullname=\"${fullname_syntax}${srcfile}\",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,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",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\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",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\",fullname=\"${fullname_syntax}${srcfile}\",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,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception"
 
Index: gdb/testsuite/gdb.mi/mi-until.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-until.exp,v
retrieving revision 1.9
diff -w -u -r1.9 mi-until.exp
--- gdb/testsuite/gdb.mi/mi-until.exp	18 May 2005 03:41:59 -0000	1.9
+++ gdb/testsuite/gdb.mi/mi-until.exp	27 Jul 2005 03:06:26 -0000
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-block.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-block.exp,v
retrieving revision 1.11
diff -w -u -r1.11 mi-var-block.exp
--- gdb/testsuite/gdb.mi/mi-var-block.exp	17 Aug 2004 09:38:29 -0000	1.11
+++ gdb/testsuite/gdb.mi/mi-var-block.exp	27 Jul 2005 03:06:26 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 #
 # This Program Is Free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-child.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-child.exp,v
retrieving revision 1.17
diff -w -u -r1.17 mi-var-child.exp
--- gdb/testsuite/gdb.mi/mi-var-child.exp	17 Aug 2004 09:38:29 -0000	1.17
+++ gdb/testsuite/gdb.mi/mi-var-child.exp	27 Jul 2005 03:06:26 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation
 
 # This Program Is Free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-cmd.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-cmd.exp,v
retrieving revision 1.18
diff -w -u -r1.18 mi-var-cmd.exp
--- gdb/testsuite/gdb.mi/mi-var-cmd.exp	14 Jan 2005 18:17:19 -0000	1.18
+++ gdb/testsuite/gdb.mi/mi-var-cmd.exp	27 Jul 2005 03:06:26 -0000
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-display.exp,v
retrieving revision 1.13
diff -w -u -r1.13 mi-var-display.exp
--- gdb/testsuite/gdb.mi/mi-var-display.exp	18 May 2005 03:41:59 -0000	1.13
+++ gdb/testsuite/gdb.mi/mi-var-display.exp	27 Jul 2005 03:06:26 -0000
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-watch.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-watch.exp,v
retrieving revision 1.12
diff -w -u -r1.12 mi-watch.exp
--- gdb/testsuite/gdb.mi/mi-watch.exp	18 May 2005 03:41:59 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-watch.exp	27 Jul 2005 03:06:26 -0000
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.27
diff -w -u -r1.27 mi-support.exp
--- gdb/testsuite/lib/mi-support.exp	18 May 2005 03:41:59 -0000	1.27
+++ gdb/testsuite/lib/mi-support.exp	27 Jul 2005 03:06:26 -0000
@@ -28,6 +28,9 @@
     set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
 }
 
+global mi_inferior_spawn_id
+global mi_inferior_tty_name
+
 set MIFLAGS "-i=mi"
 
 #
@@ -81,13 +84,16 @@
 }
 
 #
-# start gdb -- start gdb running, default procedure
+# start gdb INFERIOR_PTY -- start gdb running, default procedure
+#
+# INFERIOR_PTY should be set to TRUE to have the inferior work with it's
+# own PTY. If set to FALSE, the inferior shares GDB's PTY.
 #
 # When running over NFS, particularly if running many simultaneous
 # tests on different hosts all using the same server, things can
 # get really slow.  Give gdb at least 3 minutes to start up.
 #
-proc mi_gdb_start { } {
+proc mi_gdb_start { args } {
     global verbose
     global GDB
     global GDBFLAGS
@@ -99,6 +105,10 @@
 
     gdb_stop_suppressing_tests;
 
+    if { [llength $args] == 1} {
+	set inferior_pty [lindex $args 0]
+    }
+
     # Start SID.
     if { [info procs sid_start] != "" } {
 	verbose "Spawning SID"
@@ -117,6 +127,16 @@
 	    exit 1
 	}
     }
+
+    # spawn off the new pty for the inferior process
+    if { [ info exists inferior_pty ] } {
+	spawn -pty
+	global mi_inferior_spawn_id
+	global mi_inferior_tty_name
+	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 +209,19 @@
 	    warning "Couldn't set the width to 0."
 	}
     }
+    # If allowing the inferior to have it's own PTY then assign the inferior
+    # it's own terminal device here
+    if { [ info exists inferior_pty ] } {
+	send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n"
+	gdb_expect 10 {
+	    -re ".*102\\\^done\r\n$mi_gdb_prompt$" {
+		verbose "redirect inferior output to new terminal device."
+	    }
+	    timeout {
+	    	warning "Couldn't redirect inferior output." 2
+	    }
+    	}
+    }
 
     return 0;
 }
@@ -511,12 +544,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
@@ -533,14 +568,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];
@@ -691,6 +732,23 @@
 	    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" {
+		    pass "inferior_output:$message"
+		}
+		timeout {
+		    fail "inferior output timeout"
+		    set result 1
+		}
+	    }
+        }
+    }
+
     return $result
 }
 



More information about the Gdb-patches mailing list