2003-11-22 Andrew Cagney <cagney@redhat.com>
* lib/gdb.exp (gdb_test_multiple): Add simple example. * gdb.base/structs.exp: Use gdb_test_multiple.
This commit is contained in:
parent
38a7ce4b44
commit
d422fe19c6
3 changed files with 24 additions and 63 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2003-11-22 Andrew Cagney <cagney@redhat.com>
|
||||||
|
|
||||||
|
* lib/gdb.exp (gdb_test_multiple): Add simple example.
|
||||||
|
* gdb.base/structs.exp: Use gdb_test_multiple.
|
||||||
|
|
||||||
2003-11-20 Andrew Cagney <cagney@redhat.com>
|
2003-11-20 Andrew Cagney <cagney@redhat.com>
|
||||||
|
|
||||||
* gdb.base/structs.exp: Handle and recover from internal errors.
|
* gdb.base/structs.exp: Handle and recover from internal errors.
|
||||||
|
|
|
@ -294,10 +294,9 @@ proc test_struct_returns { n } {
|
||||||
# "return_value_unknown", if non-empty, records why GDB realised
|
# "return_value_unknown", if non-empty, records why GDB realised
|
||||||
# that it didn't know where the return value was.
|
# that it didn't know where the return value was.
|
||||||
|
|
||||||
send_gdb "return foo${n}\n"
|
|
||||||
set test "return foo<n>; ${tests}"
|
set test "return foo<n>; ${tests}"
|
||||||
set return_value_unknown 0
|
set return_value_unknown 0
|
||||||
gdb_expect {
|
gdb_test_multiple "return foo${n}" "${test}" {
|
||||||
-re "The location" {
|
-re "The location" {
|
||||||
# Ulgh, a struct return, remember this (still need prompt).
|
# Ulgh, a struct return, remember this (still need prompt).
|
||||||
set return_value_unknown 1
|
set return_value_unknown 1
|
||||||
|
@ -312,8 +311,7 @@ proc test_struct_returns { n } {
|
||||||
exp_continue
|
exp_continue
|
||||||
}
|
}
|
||||||
-re "Make fun${n} return now.*y or n. $" {
|
-re "Make fun${n} return now.*y or n. $" {
|
||||||
send_gdb "y\n"
|
gdb_test_multiple "y" "${test}" {
|
||||||
gdb_expect {
|
|
||||||
-re "L${n} *= fun${n}.*${gdb_prompt} $" {
|
-re "L${n} *= fun${n}.*${gdb_prompt} $" {
|
||||||
# Need to step off the function call
|
# Need to step off the function call
|
||||||
gdb_test "next" "L.* *= fun.*" "${test}"
|
gdb_test "next" "L.* *= fun.*" "${test}"
|
||||||
|
@ -321,38 +319,17 @@ proc test_struct_returns { n } {
|
||||||
-re "L[expr ${n} + 1] *= fun[expr ${n} + 1].*${gdb_prompt} $" {
|
-re "L[expr ${n} + 1] *= fun[expr ${n} + 1].*${gdb_prompt} $" {
|
||||||
pass "${test}"
|
pass "${test}"
|
||||||
}
|
}
|
||||||
-re "A problem internal to GDB has been detected" {
|
|
||||||
fail "${test} (GDB internal error 2)"
|
|
||||||
gdb_internal_error_resync
|
|
||||||
}
|
|
||||||
-re "${gdb_prompt} $" {
|
|
||||||
fail "${test} (wrong line info)"
|
|
||||||
}
|
|
||||||
timeout {
|
|
||||||
fail "${test} (timeout 2)"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-re "A problem internal to GDB has been detected" {
|
|
||||||
fail "${test} (GDB internal error 1)"
|
|
||||||
gdb_internal_error_resync
|
|
||||||
}
|
|
||||||
-re "${gdb_prompt} $" {
|
|
||||||
fail "${test} (no query)"
|
|
||||||
}
|
|
||||||
timeout {
|
|
||||||
fail "${test} (timeout 1)"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check that the return-value is as expected. At this stage we're
|
# Check that the return-value is as expected. At this stage we're
|
||||||
# just checking that GDB has returned a value consistent with
|
# just checking that GDB has returned a value consistent with
|
||||||
# "return_value_unknown" set above.
|
# "return_value_unknown" set above.
|
||||||
|
|
||||||
send_gdb "p/c L${n}\n"
|
|
||||||
set test "value foo<n> returned; ${tests}"
|
set test "value foo<n> returned; ${tests}"
|
||||||
setup_kfails structs-*tld* i686-*-* gdb/1447
|
setup_kfails structs-*tld* i686-*-* gdb/1447
|
||||||
gdb_expect {
|
gdb_test_multiple "p/c L${n}" "${test}" {
|
||||||
-re " = [foo ${n}].*${gdb_prompt} $" {
|
-re " = [foo ${n}].*${gdb_prompt} $" {
|
||||||
if $return_value_unknown {
|
if $return_value_unknown {
|
||||||
# This contradicts the above claim that GDB didn't
|
# This contradicts the above claim that GDB didn't
|
||||||
|
@ -375,17 +352,6 @@ proc test_struct_returns { n } {
|
||||||
fail "${test}"
|
fail "${test}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-re "A problem internal to GDB has been detected" {
|
|
||||||
fail "${test} (GDB internal error)"
|
|
||||||
gdb_internal_error_resync
|
|
||||||
}
|
|
||||||
-re "${gdb_prompt} $" {
|
|
||||||
# Garbage returned, garbage printed
|
|
||||||
fail "${test}"
|
|
||||||
}
|
|
||||||
timeout {
|
|
||||||
fail "${test} (timeout)"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check that a "finish" works.
|
# Check that a "finish" works.
|
||||||
|
@ -409,10 +375,9 @@ proc test_struct_returns { n } {
|
||||||
|
|
||||||
# Finish the function, set 'finish_value_unknown" to non-empty if the
|
# Finish the function, set 'finish_value_unknown" to non-empty if the
|
||||||
# return-value was not found.
|
# return-value was not found.
|
||||||
send_gdb "finish\n"
|
|
||||||
set test "finish foo<n>; ${tests}"
|
set test "finish foo<n>; ${tests}"
|
||||||
set finish_value_unknown 0
|
set finish_value_unknown 0
|
||||||
gdb_expect {
|
gdb_test_multiple "finish" "${test}" {
|
||||||
-re "Value returned is .*${gdb_prompt} $" {
|
-re "Value returned is .*${gdb_prompt} $" {
|
||||||
pass "${test}"
|
pass "${test}"
|
||||||
}
|
}
|
||||||
|
@ -421,26 +386,14 @@ proc test_struct_returns { n } {
|
||||||
set finish_value_unknown 1
|
set finish_value_unknown 1
|
||||||
pass "${test}"
|
pass "${test}"
|
||||||
}
|
}
|
||||||
-re "A problem internal to GDB has been detected" {
|
|
||||||
fail "${test} (GDB internal error)"
|
|
||||||
gdb_internal_error_resync
|
|
||||||
}
|
|
||||||
-re ".*${gdb_prompt} $" {
|
|
||||||
# Garbage returned
|
|
||||||
fail "${test}"
|
|
||||||
}
|
|
||||||
timeout {
|
|
||||||
fail "${test} (timeout)"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Re-print the last (return-value) using the more robust
|
# Re-print the last (return-value) using the more robust
|
||||||
# "p/c". If no return value was found, the 'Z' from the previous
|
# "p/c". If no return value was found, the 'Z' from the previous
|
||||||
# check that the variable was cleared, is printed.
|
# check that the variable was cleared, is printed.
|
||||||
send_gdb "p/c\n"
|
|
||||||
set test "value foo<n> finished; ${tests}"
|
set test "value foo<n> finished; ${tests}"
|
||||||
setup_kfails structs-*tld* i686-*-* gdb/1447
|
setup_kfails structs-*tld* i686-*-* gdb/1447
|
||||||
gdb_expect {
|
gdb_test_multiple "p/c" "${test}" {
|
||||||
-re "[foo ${n}]\[\r\n\]+${gdb_prompt} $" {
|
-re "[foo ${n}]\[\r\n\]+${gdb_prompt} $" {
|
||||||
if $finish_value_unknown {
|
if $finish_value_unknown {
|
||||||
# This contradicts the above claim that GDB didn't
|
# This contradicts the above claim that GDB didn't
|
||||||
|
@ -460,17 +413,6 @@ proc test_struct_returns { n } {
|
||||||
fail "${test}"
|
fail "${test}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-re "A problem internal to GDB has been detected" {
|
|
||||||
fail "${test} (GDB internal error)"
|
|
||||||
gdb_internal_error_resync
|
|
||||||
}
|
|
||||||
-re ".*${gdb_prompt} $" {
|
|
||||||
# Garbage returned
|
|
||||||
fail "${test}"
|
|
||||||
}
|
|
||||||
timeout {
|
|
||||||
fail "${test} (timeout)"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Finally, check that "return" and finish" have consistent
|
# Finally, check that "return" and finish" have consistent
|
||||||
|
|
|
@ -430,6 +430,20 @@ proc gdb_internal_error_resync {} {
|
||||||
# 0 if only user-supplied patterns matched
|
# 0 if only user-supplied patterns matched
|
||||||
# -1 if there was an internal error.
|
# -1 if there was an internal error.
|
||||||
#
|
#
|
||||||
|
# You can use this function thus:
|
||||||
|
#
|
||||||
|
# gdb_test_multiple "print foo" "test foo" {
|
||||||
|
# -re "expected output 1" {
|
||||||
|
# pass "print foo"
|
||||||
|
# }
|
||||||
|
# -re "expected output 2" {
|
||||||
|
# fail "print foo"
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# The standard patterns, such as "Program exited..." and "A problem
|
||||||
|
# ...", all being implicitly appended to that list.
|
||||||
|
#
|
||||||
proc gdb_test_multiple { command message user_code } {
|
proc gdb_test_multiple { command message user_code } {
|
||||||
global verbose
|
global verbose
|
||||||
global gdb_prompt
|
global gdb_prompt
|
||||||
|
|
Loading…
Reference in a new issue