diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 76ffd632b4a..9e0c49a9cdf 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-25 Pedro Alves + + * lib/gdb.exp (gdb_test_multiple): Split appends to $code and + move comments outside list. Append '-i "" eof' section. + 2019-03-22 Alan Hayward * README: Add pie options. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 6800c741874..e3c6b2d6f5e 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -906,10 +906,13 @@ proc gdb_test_multiple { command message user_code } { } } append code $processed_code - append code { - # Reset the spawn id, in case the processed code used -i. - -i "$gdb_spawn_id" + # Reset the spawn id, in case the processed code used -i. + append code { + -i "$gdb_spawn_id" + } + + append code { -re "Ending remote debugging.*$gdb_prompt $" { if ![isnative] then { warning "Can`t communicate to remote target." @@ -990,8 +993,10 @@ proc gdb_test_multiple { command message user_code } { } return -1 } + } - # Patterns below apply to any spawn id specified. + # Now patterns that apply to any spawn id specified. + append code { -i $any_spawn_id eof { perror "Process no longer exists" @@ -1013,6 +1018,20 @@ proc gdb_test_multiple { command message user_code } { } } + # remote_expect calls the eof section if there is an error on the + # expect call. We already have eof sections above, and we don't + # want them to get called in that situation. Since the last eof + # section becomes the error section, here we define another eof + # section, but with an empty spawn_id list, so that it won't ever + # match. + append code { + -i "" eof { + # This comment is here because the eof section must not be + # the empty string, otherwise remote_expect won't realize + # it exists. + } + } + set result 0 set code [catch {gdb_expect $code} string] if {$code == 1} {