diff options
author | Yao Qi <yao.qi@linaro.org> | 2016-09-22 16:04:03 +0100 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2016-09-22 16:04:03 +0100 |
commit | f73842fc847e297fd44542de9601a84b4d6b28d8 (patch) | |
tree | e4001c969de7f910c0032c259b7540ea1379f204 | |
parent | de6784544abc97d5e396cb1e83eda1ae09f63d40 (diff) | |
download | gdb-f73842fc847e297fd44542de9601a84b4d6b28d8.zip gdb-f73842fc847e297fd44542de9601a84b4d6b28d8.tar.gz gdb-f73842fc847e297fd44542de9601a84b4d6b28d8.tar.bz2 |
Close gdbserver in mi_gdb_exit
In commit 6423214f (testsuite: Don't use expect_background to reap
gdbserver), we override gdb_exit in lib/gdbserver-support.exp, so
that we can close gdbserver first. However, we don't close gdbserver
in mi_gdb_exit. This makes a problem in my aarch64 mulit-arch testing,
in which I run some mi tests, mi-watch.exp for example, in different
variations (aarch64 and arm),
Schedule of variations:
junor0-2
junor0-2-arm/-marm
junor0-2-arm/-mthumb
When the test is done in the first variation (aarch64), test case is
recompiled for arm, but GDBserver with aarch64 program is still
running. When the second variation is started, GDB loads arm program,
but GDBserver still loads aarch64 program because the old GDBserver
process is using it. We'll get,
47-target-select remote junor0-2:2350^M
&"warning: Selected architecture arm is not compatible with reported target architecture aarch64\n"^M
&"warning: Architecture rejected target-supplied description\n"
This patch fixes this problem by closing GDBserver in mi_gdb_exit.
gdb/testsuite:
2016-09-22 Yao Qi <yao.qi@linaro.org>
* lib/gdbserver-support.exp: Rename mi_gdb_exit.
(gdb_exit): Rename it to ...
(gdbserver_gdb_exit): ... Close GDBserver.
(gdb_exit): New proc, call gdbserver_gdb_exit.
(mi_gdb_exit): Likewise.
-rw-r--r-- | gdb/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdbserver-support.exp | 35 |
2 files changed, 38 insertions, 5 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4acd9ae..93ed241 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2016-09-22 Yao Qi <yao.qi@linaro.org> + * lib/gdbserver-support.exp: Rename mi_gdb_exit. + (gdb_exit): Rename it to ... + (gdbserver_gdb_exit): ... Close GDBserver. + (gdb_exit): New proc, call gdbserver_gdb_exit. + (mi_gdb_exit): Likewise. + +2016-09-22 Yao Qi <yao.qi@linaro.org> + * boards/gdbserver-base.exp (gdb_server_prog): Set the absolute path. * boards/remote-gdbserver-on-localhost.exp: Use gdbserver-base. diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index 70c8a5f..a44f241 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -356,12 +356,16 @@ proc close_gdbserver {} { unset server_spawn_id } -# Hook into GDB exit, and close GDBserver. +# Hook into GDB exit, and close GDBserver. We must load this +# explicitly here, and rename the procedures we want to override. +load_lib mi-support.exp if { [info procs gdbserver_orig_gdb_exit] == "" } { rename gdb_exit gdbserver_orig_gdb_exit + rename mi_gdb_exit gdbserver_orig_mi_gdb_exit } -proc gdb_exit {} { + +proc gdbserver_gdb_exit { is_mi } { global gdb_spawn_id server_spawn_id global gdb_prompt global gdbserver_reconnect_p @@ -369,7 +373,11 @@ proc gdb_exit {} { # Leave GDBserver running if we're exiting GDB in order to # reconnect to the same instance of GDBserver again. if {[info exists gdbserver_reconnect_p] && $gdbserver_reconnect_p} { - gdbserver_orig_gdb_exit + if { $is_mi } { + gdbserver_orig_mi_gdb_exit + } else { + gdbserver_orig_gdb_exit + } return } @@ -378,7 +386,12 @@ proc gdb_exit {} { # but DejaGNU doesn't know that, so gdb_spawn_id isn't unset. # Catch the exceptions. catch { - send_gdb "monitor exit\n"; + if { $is_mi } { + set monitor_exit "-interpreter-exec console \"monitor exit\"" + } else { + set monitor_exit "monitor exit" + } + send_gdb "$monitor_exit\n"; # We use expect rather than gdb_expect because # we want to suppress printing exception messages, otherwise, # remote_expect, invoked by gdb_expect, prints the exceptions. @@ -395,7 +408,19 @@ proc gdb_exit {} { } close_gdbserver - gdbserver_orig_gdb_exit + if { $is_mi } { + gdbserver_orig_mi_gdb_exit + } else { + gdbserver_orig_gdb_exit + } +} + +proc gdb_exit {} { + gdbserver_gdb_exit 0 +} + +proc mi_gdb_exit {} { + gdbserver_gdb_exit 1 } # Start a gdbserver process running HOST_EXEC and pass CHILD_ARGS |