diff --git a/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp b/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp index 6c480c8c0cf..d45e958a529 100644 --- a/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp +++ b/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp @@ -75,9 +75,19 @@ proc connect_no_symbol_file { sysroot action } { # Check if GDB succeeded connecting to GDBserver by attempting to detach # from the process. - gdb_test "detach" \ - ".*Detaching from program: , process.*Ending remote debugging.*" \ - "connection to GDBserver succeeded" + # Use an explicit fail clause to prevent the implicit clause matching + # "Ending remote debugging" from triggering, which would cause silent + # failure. + set ok 0 + gdb_test_multiple "detach" "" { + -re "\r\nDetaching from \[^\r\n\]*" { + set ok 1 + exp_continue + } + -re -wrap "" { + } + } + gdb_assert $ok "connection to GDBserver succeeded" } # Make sure we have the original symbol file in a safe place to copy from.