This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 4/6] testsuite: Don't use expect_background to reap gdbserver
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Yao Qi <qiyaoltc at gmail dot com>, gdb-patches at sourceware dot org
- Date: Mon, 13 Apr 2015 15:20:40 +0100
- Subject: Re: [PATCH 4/6] testsuite: Don't use expect_background to reap gdbserver
- Authentication-results: sourceware.org; auth=none
- References: <1424699660-11727-1-git-send-email-palves at redhat dot com> <1424699660-11727-5-git-send-email-palves at redhat dot com> <864mokuuep dot fsf at gmail dot com> <552BB206 dot 4000803 at redhat dot com> <552BC3C2 dot 6010103 at gmail dot com> <552BC9FC dot 2020201 at redhat dot com>
Pedro Alves <palves@redhat.com> writes:
>> looks we can't prevent DejaGNU invoking send_user.
>
> I think we should just call raw "expect" instead then.
Using "expect" is OK to me, how about the patch below?
--
Yao (éå)
From: Yao Qi <yao.qi@linaro.org>
Date: Mon, 13 Apr 2015 12:36:56 +0100
Subject: [PATCH] Catch exception in lib/gdbserver-support.exp:gdb_exit
I see the error when I run gdb-sigterm.exp with native-gdbserver
on x86_64-linux.
infrun: prepare_to_wait^M
Cannot execute this command while the target is running.^M
Use the "interrupt" command to stop the target^M
and then try again.^M
gdb.base/gdb-sigterm.exp: expect eof #0: got eof
gdb.base/gdb-sigterm.exp: expect eof #0: stepped 12 times
ERROR OCCURED: : spawn id exp8 not open
while executing
"expect {
-i exp8 -timeout 10
-re "$gdb_prompt $" {
exp_continue
}
-i "$server_spawn_id" eof {
wait -i $expect_out(spawn_id)
unse..."
("uplevel" body line 1)
invoked from within
In gdb-sigterm.exp, SIGTERM is sent to GDB and it exits. However,
Dejagnu or tcl doesn't know this.
This patch is to catch the exception, but error messages are still
shown in the console and gdb.log. In order to avoid this, we also
replace gdb_expect with expect.
gdb/testsuite:
2015-04-13 Yao Qi <yao.qi@linaro.org>
* lib/gdbserver-support.exp (gdb_exit): Catch exception
and use expect instead of gdb_expect.
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 53843b8..b3140c2 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -353,15 +353,23 @@ proc gdb_exit {} {
global gdb_prompt
if {[info exists gdb_spawn_id] && [info exists server_spawn_id]} {
- send_gdb "monitor exit\n";
- gdb_expect {
- -re "$gdb_prompt $" {
- exp_continue
- }
- -i "$server_spawn_id" eof {
- wait -i $expect_out(spawn_id)
- unset server_spawn_id
- unset inferior_spawn_id
+ # GDB may be terminated in an expected way or an unexpected way,
+ # but DejaGNU doesn't know that, so gdb_spawn_id isn't unset.
+ # Catch the exceptions.
+ catch {
+ 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.
+ expect {
+ -i "$gdb_spawn_id" -re "$gdb_prompt $" {
+ exp_continue
+ }
+ -i "$server_spawn_id" eof {
+ wait -i $expect_out(spawn_id)
+ unset server_spawn_id
+ unset inferior_spawn_id
+ }
}
}
}