[gdb/testsuite] Fix silent timeouts in gdb.mi/mi-exec-run.exp with remote host
commit6b839dd3deea4de278ebd862edb9c91d335d63e2
authorTom de Vries <tdevries@suse.de>
Thu, 27 Oct 2022 14:53:12 +0000 (27 16:53 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 27 Oct 2022 14:53:12 +0000 (27 16:53 +0200)
treebf4b0b767bc9b9b62faad46fbb58e078b2bf2c92
parentb253899c901fed0ff56b2746945ffc824e412b81
[gdb/testsuite] Fix silent timeouts in gdb.mi/mi-exec-run.exp with remote host

I noticed that running test-case gdb.mi/mi-exec-run.exp with host board
local-remote-host.exp takes about 44 seconds.

I found two silent timeouts responsible for this.

The first is in mi_gdb_exit, where we have:
...
    if { [is_remote host] && [board_info host exists fileid] } {
        send_gdb "999-gdb-exit\n"
        gdb_expect 10 {
            -re "y or n" {
                send_gdb "y\n"
                exp_continue
            }
            -re "Undefined command.*$gdb_prompt $" {
                send_gdb "quit\n"
                exp_continue
            }
            -re "DOSEXIT code" { }
        }
    }
...
so in gdb.log we see:
...
999-gdb-exit^M
999^exit^M
=thread-exited,id="1",group-id="i1"^M
=thread-group-exited,id="i1"^M
...
after which expect just waits for the timeout.

Fix this by adding a gdb_expect clause to parse the exit:
...
            -re "\r\n999\\^exit\r\n" { }
...

Note that we're not parsing the thread-exited/thread-group-exited messages, because
they may not be present:
...
$ gdb -i=mi
=thread-group-added,id="i1"
(gdb)
999-gdb-exit
999^exit
$
...

After fixing that, we have:
...
(gdb) ^M
saw mi error
PASS: gdb.mi/mi-exec-run.exp: inferior-tty=separate: mi=separate: \
  force-fail=1: run failure detected
quit^M
&"quit\n"^M
...

What seems to be happening is that default_gdb_exit sends a cli interpreter
quit command to an mi interpreter, after which again expect just waits for the
timeout.

Fix this by adding mi_gdb_exit to the end of the test-case, as in many other
gdb.mi/*.exp test-cases.

After these two fixes, the test-case takes about 4 seconds.

Tested on x86_64-linux.
gdb/testsuite/gdb.mi/mi-exec-run.exp
gdb/testsuite/lib/mi-support.exp