Re: [PATCH v3 31/34] Add testing infrastruture bits for running with MI on a separate UI

Simon Marchi
2016-06-28T20:19:27Z

On 16-05-06 08:35 AM, Pedro Alves wrote:
> With this, a specific test may can start GDB with MI on a separate UI
> by using:
>
> mi_gdb_start separate-mi-tty
>
> In addition, it's also possible to run the whole testsuite with MI on
> a separate tty, with:
>
> make check RUNTESTFLAGS="FORCE_SEPARATE_MI_TTY=1"
>
> gdb_main_spawn_id and mi_spawn_id are added so that tests may expect
> output from either channel.
>
> While at it, inferior_spawn_id was not being cleared when gdb exits,
> unlike the other spawn ids, thus a test that starts gdb more than once
> would end up using a stale spawn id.

Hi Pedro,

I think this commit breaks MI tests with native-gdbserver:

$ make check RUNTESTFLAGS="--target_board=native-gdbserver mi-var-child.exp"
...
Running /home/emaisin/build/binutils-gdb/gdb/testsuite/../../../../src/binutils-gdb/gdb/testsuite/gdb.mi/mi-var-child.exp ...
can't unset "inferior_spawn_id": no such variable
while executing
"unset inferior_spawn_id"
(procedure "close_gdbserver" line 20)
invoked from within
"close_gdbserver"
...

I added a few traces to understand what's happening, and it seems that inferior_spawn_id
is being unset at two places:

>>> gdbserver-support.exp:gdb_exit called
>>> gdb.exp:default_gdb_exit called
>>> mi-support.exp:default_mi_gdb_start called
*** set inferior_spawn_id to gdb_spawn_id exp8 in mi-support.exp:default_mi_gdb_start
>>> gdbserver-support.exp:gdbserver_start called
*** set server_spawn_id in gdbserver-support.exp:gdbserver_start
*** set inferior_spawn_id to server_spawn_id exp9 in gdbserver-support.exp.exp:gdbserver_start
>>> gdbserver-support.exp:gdbserver_start called
*** set server_spawn_id in gdbserver-support.exp:gdbserver_start
*** set inferior_spawn_id to server_spawn_id exp10 in gdbserver-support.exp.exp:gdbserver_start
>>> mi-support.exp:mi_uncatched_gdb_exit called
*** unset inferior_spawn_id in mi-support.exp:mi_uncatched_gdb_exit
>>> gdbserver-support.exp:gdb_exit called
*** unset server_spawn_id in gdbserver-support.exp:close_gdbserver
*** unset inferior_spawn_id in gdbserver-support.exp:close_gdbserver <--- This is the one that breaks.

The easy way would be to add a "info exists" check before unsetting it, but I don't know if
that would only hide a real problem.

Simon