summaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib/mi-support.exp
diff options
context:
space:
mode:
authorBob Rossi <bob@brasko.net>2005-08-04 01:52:31 +0000
committerBob Rossi <bob@brasko.net>2005-08-04 01:52:31 +0000
commit763ee8502617a60851cf77aef5fb095a9366eb4e (patch)
treeda82f4b9d82fa1741ab0f793e7d74b8f4117b324 /gdb/testsuite/lib/mi-support.exp
parent9351e9aea97e861b65057c69a606f776106c9482 (diff)
downloadgdb-763ee8502617a60851cf77aef5fb095a9366eb4e.tar.gz
2005-08-02 Bob Rossi <bob@brasko.net>
* 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. Change tests to inferior-tty-set/show. * gdb.mi/mi-console.exp: Tell mi_gdb_start to use a PTY for inferior. (47-exec-next): Use mi_gdb_test to get GDB and Inferior output. * gdb.mi/mi-syn-frame.exp: Tell mi_gdb_start to use a PTY for inferior. Use mi_gdb_test to get GDB and Inferior 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 INFERIOR_PTY parameter. (mi_gdb_test): Add IPATTERN parameter.
Diffstat (limited to 'gdb/testsuite/lib/mi-support.exp')
-rw-r--r--gdb/testsuite/lib/mi-support.exp68
1 files changed, 65 insertions, 3 deletions
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index da4fd34168c..64f42b5f2eb 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -28,6 +28,9 @@ if ![info exists mi_gdb_prompt] then {
set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
}
+global mi_inferior_spawn_id
+global mi_inferior_tty_name
+
set MIFLAGS "-i=mi"
#
@@ -81,13 +84,17 @@ proc mi_uncatched_gdb_exit {} {
}
#
-# start gdb -- start gdb running, default procedure
+# mi_gdb_start [INFERIOR_PTY] -- start gdb running, default procedure
+#
+# INFERIOR_PTY should be set to separate-inferior-tty to have the inferior work
+# with it's own PTY. If set to same-inferior-tty, the inferior shares GDB's PTY.
+# The default value is same-inferior-tty.
#
# 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
@@ -98,6 +105,13 @@ proc mi_gdb_start { } {
global MIFLAGS
gdb_stop_suppressing_tests;
+ set inferior_pty no-tty
+
+ if { [llength $args] == 1} {
+ set inferior_pty [lindex $args 0]
+ }
+
+ set separate_inferior_pty [string match $inferior_pty separate-inferior-tty]
# Start SID.
if { [info procs sid_start] != "" } {
@@ -117,6 +131,16 @@ proc mi_gdb_start { } {
exit 1
}
}
+
+ # Create the new PTY for the inferior process.
+ if { $separate_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 +213,19 @@ proc mi_gdb_start { } {
warning "Couldn't set the width to 0."
}
}
+ # If allowing the inferior to have its own PTY then assign the inferior
+ # its own terminal device here.
+ if { $separate_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,7 +548,8 @@ proc mi_gdb_load { arg } {
return 0
}
-# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
+# mi_gdb_test COMMAND PATTERN MESSAGE [IPATTERN] -- 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.
@@ -520,6 +558,9 @@ proc mi_gdb_load { arg } {
# MESSAGE is the message to be printed. (If this is the empty string,
# then sometimes we don't call pass or fail at all; I don't
# understand this at all.)
+# IPATTERN is the pattern to match for the inferior's output. This parameter
+# is optional. If present, it will produce a PASS if the match is
+# successful, and a FAIL if unsuccessful.
#
# Returns:
# 1 if the test failed,
@@ -536,6 +577,10 @@ proc mi_gdb_test { args } {
set pattern [lindex $args 1]
set message [lindex $args 2]
+ if [llength $args]==4 {
+ set ipattern [lindex $args 3]
+ }
+
if [llength $args]==5 {
set question_string [lindex $args 3];
set response_string [lindex $args 4];
@@ -686,6 +731,23 @@ proc mi_gdb_test { args } {
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
}