* lib/gdb.exp(gdb_test): Surround the result pattern with

parenthesis in case it contains multiple regexps separated
	with |.

Fixes last nights native failures.

	* gdb.base/watchpoint.exp: Use gdb_test.
	* gdb.base/default.exp: Ditto.

More improvements.
This commit is contained in:
Bob Manson 1997-02-03 03:35:42 +00:00
parent 85fbaa747f
commit 0d8017baad
4 changed files with 61 additions and 124 deletions

View file

@ -1,3 +1,12 @@
Sun Feb 2 00:55:14 1997 Bob Manson <manson@charmed.cygnus.com>
* lib/gdb.exp(gdb_test): Surround the result pattern with
parenthesis in case it contains multiple regexps separated
with |.
* gdb.base/watchpoint.exp: Use gdb_test.
* gdb.base/default.exp: Ditto.
Sat Feb 1 23:51:01 1997 Bob Manson <manson@charmed.cygnus.com> Sat Feb 1 23:51:01 1997 Bob Manson <manson@charmed.cygnus.com>
* gdb.*/*.exp: Replace $prompt with $gdb_prompt. * gdb.*/*.exp: Replace $prompt with $gdb_prompt.

View file

@ -350,13 +350,13 @@ gdb_test "pwd" "Working directory .*" "pwd"
#test run "r" abbreviation #test run "r" abbreviation
if [istarget "*-*-vxworks*"] then { if [istarget "*-*-vxworks*"] then {
send_gdb "set args\n" gdb_test "set args" "" ""
expect -re "$gdb_prompt $" {}
gdb_test "r" "Starting program: .* gdb_test "r" "Starting program: .*
You must specify a function name to run, and arguments if any"\ You must specify a function name to run, and arguments if any"\
"run \"r\" abbreviation" "run \"r\" abbreviation"
send_gdb "set args main\n" gdb_test "set args main" "" ""
expect -re "$gdb_prompt $" {}
} else { } else {
send_gdb "r\n" send_gdb "r\n"
expect { expect {
@ -382,12 +382,12 @@ No program loaded.*$gdb_prompt $"\
#test run #test run
if [istarget "*-*-vxworks*"] then { if [istarget "*-*-vxworks*"] then {
send_gdb "set args\n" gdb_test "set args" "" ""
expect -re "$gdb_prompt $" {}
gdb_test "run" "Starting program: .* gdb_test "run" "Starting program: .*
You must specify a function name to run, and arguments if any" You must specify a function name to run, and arguments if any"
send_gdb "set args main\n" gdb_test "set args main" "" ""
expect -re "$gdb_prompt $" {}
} else { } else {
send_gdb "run\n" send_gdb "run\n"
expect { expect {
@ -415,17 +415,8 @@ gdb_test "rbreak" "" "rbreak"
#test return #test return
# The middle case accommodates the a29k, where doing the "ni" above causes # The middle case accommodates the a29k, where doing the "ni" above causes
# an initial stack to be created. # an initial stack to be created.
send_gdb "return\n" gdb_test "return" "No selected frame..*" "return" "Make .* return now.*y or n. $" "y"
expect {
-re "No selected frame..*$gdb_prompt $"\
{ pass "return" }
-re "Make .* return now.*y or n. $" {
send_gdb "y\n"
exp_continue
}
-re ".*$gdb_prompt $" { fail "return" }
timeout { fail "(timeout) return" }
}
#test reverse-search #test reverse-search
gdb_test "reverse-search" "No previous regular expression.*|There is no previous regular expression.*" "reverse-search" gdb_test "reverse-search" "No previous regular expression.*|There is no previous regular expression.*" "reverse-search"

View file

@ -56,66 +56,42 @@ proc initialize {} {
global decimal global decimal
global srcfile global srcfile
send_gdb "break marker1\n" if [gdb_test "break marker1" "Breakpoint 1 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker1" ] {
expect { return 0;
-re "Breakpoint 1 at $hex: file .*$srcfile, line $decimal.*$gdb_prompt $" {
pass "set breakpoint at marker1"
}
-re ".*$gdb_prompt $" { fail "set breakpoint at marker1" ; return 0 }
timeout { fail "set breakpoint at marker1 (timeout)" ; return 0 }
} }
send_gdb "break marker2\n"
expect { if [gdb_test "break marker2" "Breakpoint 2 at $hex: file .*$srcfile, line $decimal.*" "set breakpoint at marker2" ] {
-re "Breakpoint 2 at $hex: file .*$srcfile, line $decimal.*$gdb_prompt $" { return 0;
pass "set breakpoint at marker2"
}
-re ".*$gdb_prompt $" { fail "set breakpoint at marker2" ; return 0 }
timeout { fail "set breakpoint at marker2 (timeout)" ; return 0 }
} }
send_gdb "info break\n"
expect { if [gdb_test "info break" "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*" "info break in watchpoint.exp" ] {
-re "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*\r\n$gdb_prompt $" { pass "info break in watchpoint.exp" } return 0;
-re ".*$gdb_prompt $" { fail "info break in watchpoint.exp" ; return 0 }
timeout { fail "info break in watchpoint.exp (timeout)" ; return 0 }
} }
send_gdb "watch ival3\n"
expect { if [gdb_test "watch ival3" ".*\[Ww\]atchpoint 3: ival3" "set watchpoint on ival3" ] {
-re ".*\[Ww\]atchpoint 3: ival3\r\n$gdb_prompt $" { return 0;
pass "set watchpoint on ival3"
}
-re ".*$gdb_prompt $" { fail "set watchpoint on ival3" ; return 0 }
timeout { fail "set watchpoint on ival3 (timeout)" ; return 0 }
} }
# "info watch" is the same as "info break" # "info watch" is the same as "info break"
send_gdb "info watch\n" if [gdb_test "info watch" "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*\r\n3\[ \]*.*watchpoint.*ival3" "watchpoint found in watchpoint/breakpoint table" ] {
expect { return 0;
-re "1\[ \]*breakpoint.*marker1.*\r\n2\[ \]*breakpoint.*marker2.*\r\n3\[ \]*.*watchpoint.*ival3\r\n$gdb_prompt $" {
pass "watchpoint found in watchpoint/breakpoint table"
}
-re ".*$gdb_prompt $" {
fail "watchpoint found in watchpoint/breakpoint table" ; return 0
}
timeout {
fail "watchpoint found in watchpoint/breakpoint table (timeout)" ; return 0
}
} }
# After installing the watchpoint, we disable it until we are ready # After installing the watchpoint, we disable it until we are ready
# to use it. This allows the test program to run at full speed until # to use it. This allows the test program to run at full speed until
# we get to the first marker function. # we get to the first marker function.
send_gdb "disable 3\n" if [gdb_test "disable 3" "disable 3\[\r\n\]+" "disable watchpoint" ] {
expect { return 0;
-re "disable 3\[\r\n\]+$gdb_prompt $" { pass "disable watchpoint" }
-re ".*$gdb_prompt $" { fail "disable watchpoint" ; return 0 }
timeout { fail "disable watchpoint (timeout)" ; return 0 }
} }
return 1 return 1
} }
@ -131,21 +107,11 @@ proc test_simple_watchpoint {} {
# Ensure that the watchpoint is disabled when we startup. # Ensure that the watchpoint is disabled when we startup.
send_gdb "disable 3\n" if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_simple_watchpoint" ] {
expect { return 0;
-re "^disable 3\[\r\n\]+$gdb_prompt $" {
pass "disable watchpoint in test_simple_watchpoint"
}
-re ".*$gdb_prompt $" {
fail "disable watchpoint in test_simple_watchpoint"
return 0
}
timeout {
fail "disable watchpoint in test_simple_watchpoint (timeout)"
return 0
}
} }
# Run until we get to the first marker function. # Run until we get to the first marker function.
gdb_run_cmd gdb_run_cmd
@ -166,13 +132,11 @@ proc test_simple_watchpoint {} {
# After reaching the marker function, enable the watchpoint. # After reaching the marker function, enable the watchpoint.
send_gdb "enable 3\n" if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "enable watchpoint" ] {
expect { return ;
-re "^enable 3\[\r\n\]+$gdb_prompt $" { pass "enable watchpoint" }
-re ".*$gdb_prompt $" { fail "enable watchpoint" ; return }
timeout { fail "enable watchpoint (timeout)" ; return }
} }
gdb_test "break func1" "Breakpoint.*at.*" gdb_test "break func1" "Breakpoint.*at.*"
gdb_test "set \$func1_breakpoint_number = \$bpnum" "" gdb_test "set \$func1_breakpoint_number = \$bpnum" ""
@ -223,13 +187,11 @@ Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count
# Disable the watchpoint so we run at full speed until we exit. # Disable the watchpoint so we run at full speed until we exit.
send_gdb "disable 3\n" if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "watchpoint disabled" ] {
expect { return ;
-re "^disable 3\[\r\n\]+$gdb_prompt $" { pass "watchpoint disabled" }
-re ".*$gdb_prompt $" { fail "watchpoint disabled" ; return }
timeout { fail "watchpoint disabled (timeout)" ; return }
} }
# Run until process exits. # Run until process exits.
if $noresults==1 then { return } if $noresults==1 then { return }
@ -250,21 +212,11 @@ proc test_disabling_watchpoints {} {
# Ensure that the watchpoint is disabled when we startup. # Ensure that the watchpoint is disabled when we startup.
send_gdb "disable 3\n" if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint in test_disabling_watchpoints" ] {
expect { return 0;
-re "^disable 3\[\r\n\]+$gdb_prompt $" {
pass "disable watchpoint in test_disabling_watchpoints"
}
-re ".*$gdb_prompt $" {
fail "disable watchpoint in test_disabling_watchpoints"
return 0
}
timeout {
fail "disable watchpoint in test_disabling_watchpoints (timeout)"
return 0
}
} }
# Run until we get to the first marker function. # Run until we get to the first marker function.
gdb_run_cmd gdb_run_cmd
@ -285,13 +237,11 @@ proc test_disabling_watchpoints {} {
# After reaching the marker function, enable the watchpoint. # After reaching the marker function, enable the watchpoint.
send_gdb "enable 3\n" if [gdb_test "enable 3" "^enable 3\[\r\n\]+" "watchpoint enabled" ] {
expect { return ;
-re "^enable 3\[\r\n\]+$gdb_prompt $" { pass "watchpoint enabled" }
-re ".*$gdb_prompt $" { fail "watchpoint enabled" ; return }
timeout { fail "watchpoint enabled (timeout)" ; return }
} }
# Continue until the first change, from -1 to 0 # Continue until the first change, from -1 to 0
# Don't check the old value, because on VxWorks the variable value # Don't check the old value, because on VxWorks the variable value
# will not have been reinitialized. # will not have been reinitialized.
@ -302,21 +252,11 @@ proc test_disabling_watchpoints {} {
# Disable the watchpoint but leave breakpoints # Disable the watchpoint but leave breakpoints
send_gdb "disable 3\n" if [gdb_test "disable 3" "^disable 3\[\r\n\]+" "disable watchpoint #2 in test_disabling_watchpoints" ] {
expect { return 0;
-re "^disable 3\[\r\n\]+$gdb_prompt $" {
pass "disable watchpoint #2 in test_disabling_watchpoints"
}
-re ".*$gdb_prompt $" {
"disable watchpoint #2 in test_disabling_watchpoints"
return 0
}
timeout {
"disable watchpoint #2 in test_disabling_watchpoints (timeout)"
return 0
}
} }
# Check watchpoint list, looking for the entry that confirms the # Check watchpoint list, looking for the entry that confirms the
# watchpoint is disabled. # watchpoint is disabled.
gdb_test "info watchpoints" "3\[ \]*.*watchpoint\[ \]*keep\[ \]*n\[ \]*ival3\r\n.*" "watchpoint disabled in table" gdb_test "info watchpoints" "3\[ \]*.*watchpoint\[ \]*keep\[ \]*n\[ \]*ival3\r\n.*" "watchpoint disabled in table"
@ -382,6 +322,7 @@ proc test_stepping {} {
-re "Run.*exit from.*marker1.* at" { } -re "Run.*exit from.*marker1.* at" { }
default { fail "finish from marker1" ; return } default { fail "finish from marker1" ; return }
} }
expect { expect {
-re "marker1 \\(\\);.*$gdb_prompt $" { -re "marker1 \\(\\);.*$gdb_prompt $" {
send_gdb "step\n" send_gdb "step\n"
@ -455,13 +396,10 @@ proc test_watchpoint_triggered_in_syscall {} {
# If we send_gdb "123\n" before gdb has switched the tty, then it goes # If we send_gdb "123\n" before gdb has switched the tty, then it goes
# to gdb, not the inferior, and we lose. So that is why we have # to gdb, not the inferior, and we lose. So that is why we have
# watchpoint.c prompt us, so we can wait for that prompt. # watchpoint.c prompt us, so we can wait for that prompt.
send_gdb "continue\n" if [gdb_test "continue" "Continuing\\.\r\ntype stuff for buf now:" "continue to read" ] {
expect { return ;
-re "Continuing\\.\r\ntype stuff for buf now:" {
pass "continue to read"
}
default { fail "continue to read"; return }
} }
send_gdb "123\n" send_gdb "123\n"
expect { expect {
-re ".*\[Ww\]atchpoint.*buf\\\[0\\\].*Old value = 0.*New value = 49\[^\n\]*\n" { set x [expr $x+1] ; exp_continue } -re ".*\[Ww\]atchpoint.*buf\\\[0\\\].*Old value = 0.*New value = 49\[^\n\]*\n" { set x [expr $x+1] ; exp_continue }
@ -552,7 +490,6 @@ proc test_complex_watchpoint {} {
# Start with a fresh gdb. # Start with a fresh gdb.
gdb_exit
gdb_start gdb_start
gdb_reinitialize_dir $srcdir/$subdir gdb_reinitialize_dir $srcdir/$subdir
gdb_load $binfile gdb_load $binfile

View file

@ -354,13 +354,13 @@ proc gdb_test { args } {
gdb_start gdb_start
set result -1 set result -1
} }
-re "\[\r\n\]*$pattern\[\r\n\]+$gdb_prompt $" { -re "\[\r\n\]*($pattern)\[\r\n\]+$gdb_prompt $" {
if ![string match "" $message] then { if ![string match "" $message] then {
pass "$message" pass "$message"
} }
set result 0 set result 0
} }
-re "${question_string}$" { -re "(${question_string})$" {
send_gdb "$response_string\n"; send_gdb "$response_string\n";
exp_continue; exp_continue;
} }