[gdb/testsuite] Don't start gdb in gdb.base/gstack.exp

In test-case gdb.base/gstack.exp we start a gdb implicitly using
prepare_for_testing.

The gdb is not really used, but its spawn_id (available in variable
gdb_spawn_id) is used in a gdb_test_multiple, which is used to interact with
the gstack process.

Usually, a running gdb is cleaned up at test-case exit in gdb_finish, which
calls gdb_exit, which by default calls gdb_default_exit, which does
'send_gdb "quit\n"'.

However, this sends a quit to the host process expect is currently talking to,
defined by board_info(host,fileid), and after spawning gstack that's gstack, not
gdb.

Fix this by:
- using build_executable instead of prepare_for_testing to not spawn an unused
  gdb, and
- changing the gdb_test_multiple into a gdb_expect, eliminating the implicit use
  of gdb_spawn_id.

Tested on x86_64-linux.

Reviewed-By: Keith Seitz <keiths@redhat.com>

PR testsuite/32709
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32709
1 file changed