]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb.multi/attach-no-multi-process.exp: Detect no remote non-stop
authorPedro Alves <pedro@palves.net>
Fri, 2 Jun 2023 00:05:38 +0000 (01:05 +0100)
committerPedro Alves <pedro@palves.net>
Wed, 11 Jun 2025 13:59:42 +0000 (14:59 +0100)
Running gdb.multi/attach-no-multi-process.exp on Cygwin, where
GDBserver does not support non-stop mode, I see:

 FAIL: gdb.multi/attach-no-multi-process.exp: target_non_stop=off: info threads
 FAIL: gdb.multi/attach-no-multi-process.exp: target_non_stop=on: attach to the program via remote (timeout)
 FAIL: gdb.multi/attach-no-multi-process.exp: target_non_stop=on: info threads (timeout)

Let's ignore the first "info threads" fail.  The timeouts look like
this:

 builtin_spawn /home/alves/gdb-cache-cygwin/gdb/../gdbserver/gdbserver --once --multi localhost:2346
 Listening on port 2346
 target extended-remote localhost:2346
 Remote debugging using localhost:2346
 Non-stop mode requested, but remote does not support non-stop
 (gdb) gdb_do_cache: can_spawn_for_attach (  )
 builtin_spawn /home/alves/gdb/build-cygwin-testsuite/outputs/gdb.multi/attach-no-multi-process/attach-no-multi-process
 attach 14540
 FAIL: gdb.multi/attach-no-multi-process.exp: target_non_stop=on: attach to the program via remote (timeout)
 info threads
 FAIL: gdb.multi/attach-no-multi-process.exp: target_non_stop=on: info threads (timeout)

Note the "Non-stop mode requested, but remote does not support
non-stop" line.

The intro to gdb_target_cmd_ext says:

 # gdb_target_cmd_ext
 # Send gdb the "target" command.  Returns 0 on success, 1 on failure, 2 on
 # unsupported.

That's perfect here, we can just use gdb_target_cmd_ext instead of
gdb_target_cmd, and check for 2 (unsupported).  That's what this patch
does.

However gdb_target_cmd_ext incorrectly returns 1 instead of 2 for the
case where the remote target says it does not support non-stop.  That
is also fixed by this patch.

With this, we no longer get those timeout fails.  We get instead:

 target extended-remote localhost:2346
 Remote debugging using localhost:2346
 Non-stop mode requested, but remote does not support non-stop
 (gdb) UNSUPPORTED: gdb.multi/attach-no-multi-process.exp: target_non_stop=on: non-stop RSP

Approved-by: Kevin Buettner <kevinb@redhat.com>
Change-Id: I1ab3162f74200c6c02a17a0600b102d2d12db236

gdb/testsuite/gdb.multi/attach-no-multi-process.exp
gdb/testsuite/lib/gdbserver-support.exp

index 28aabaf9edf332c5f61ef3d2ee96713900edab09..502f30940cc24369985e2066ac6f08238abfb9d5 100644 (file)
@@ -59,7 +59,10 @@ proc test {target_non_stop} {
        "switch to inferior 2"
     set res [gdbserver_start "--multi" ""]
     set gdbserver_gdbport [lindex $res 1]
-    gdb_target_cmd "extended-remote" $gdbserver_gdbport
+    if { [gdb_target_cmd_ext "extended-remote" $gdbserver_gdbport] == 2 } {
+       unsupported "non-stop RSP"
+       return
+    }
 
     # Start a program, then attach to it.
     set spawn_id_list [spawn_wait_for_attach [list $binfile]]
index c2850724c523cb93224cc3b5fdf2f93364ca6bbb..23892068c97879b14b4d975c0c6e1ba2df1964a3 100644 (file)
@@ -69,7 +69,7 @@ proc gdb_target_cmd_ext { targetname serialport {additional_text ""} } {
            }
            -re "Non-stop mode requested, but remote does not support non-stop.*$gdb_prompt $" {
                verbose "remote does not support non-stop"
-               return 1
+               return 2
            }
            -re "Remote MIPS debugging.*$additional_text.*$gdb_prompt" {
                verbose "Set target to $targetname"