From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49195 invoked by alias); 13 Apr 2015 11:42:17 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 49185 invoked by uid 89); 13 Apr 2015 11:42:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f52.google.com Received: from mail-pa0-f52.google.com (HELO mail-pa0-f52.google.com) (209.85.220.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 13 Apr 2015 11:42:15 +0000 Received: by pabtp1 with SMTP id tp1so99588747pab.2 for ; Mon, 13 Apr 2015 04:42:13 -0700 (PDT) X-Received: by 10.68.114.194 with SMTP id ji2mr26174798pbb.132.1428925333756; Mon, 13 Apr 2015 04:42:13 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id nj7sm7048738pbc.36.2015.04.13.04.42.11 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 13 Apr 2015 04:42:12 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 4/6] testsuite: Don't use expect_background to reap gdbserver References: <1424699660-11727-1-git-send-email-palves@redhat.com> <1424699660-11727-5-git-send-email-palves@redhat.com> Date: Mon, 13 Apr 2015 11:42:00 -0000 In-Reply-To: <1424699660-11727-5-git-send-email-palves@redhat.com> (Pedro Alves's message of "Mon, 23 Feb 2015 13:54:18 +0000") Message-ID: <864mokuuep.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00454.txt.bz2 Pedro Alves writes: > +proc gdb_exit {} { > + global gdb_spawn_id server_spawn_id > + 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 > + } > + } > + } Do we need to catch exception here? 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. > + close_gdbserver > + > + gdbserver_orig_gdb_exit > +} This error terminates the whole testing, so the following tests are not run. I wrap the send_gdb and gdb_expect statement above by "catch", testing looks fine, although error messages are still shown in the console and gdb.log. --=20 Yao (=E9=BD=90=E5=B0=A7) From: Yao Qi 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. gdb/testsuite: 2015-04-13 Yao Qi * lib/gdbserver-support.exp (gdb_exit): Catch exception. diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gd= bserver-support.exp index 53843b8..8d4858a 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -353,15 +353,20 @@ proc gdb_exit {} { global gdb_prompt =20 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"; + 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 + } } } }