From patchwork Mon Apr 13 14:20:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 6183 Received: (qmail 58281 invoked by alias); 13 Apr 2015 14:20:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 58225 invoked by uid 89); 13 Apr 2015 14:20:50 -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-pd0-f178.google.com Received: from mail-pd0-f178.google.com (HELO mail-pd0-f178.google.com) (209.85.192.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 13 Apr 2015 14:20:49 +0000 Received: by pddn5 with SMTP id n5so108717683pdd.2 for ; Mon, 13 Apr 2015 07:20:47 -0700 (PDT) X-Received: by 10.67.15.102 with SMTP id fn6mr27653972pad.120.1428934847761; Mon, 13 Apr 2015 07:20:47 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id b9sm7551400pas.40.2015.04.13.07.20.45 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 13 Apr 2015 07:20:46 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: Yao Qi , 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> <864mokuuep.fsf@gmail.com> <552BB206.4000803@redhat.com> <552BC3C2.6010103@gmail.com> <552BC9FC.2020201@redhat.com> Date: Mon, 13 Apr 2015 15:20:40 +0100 In-Reply-To: <552BC9FC.2020201@redhat.com> (Pedro Alves's message of "Mon, 13 Apr 2015 14:51:56 +0100") Message-ID: <86zj6ct8hz.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Pedro Alves 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? 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 + } } } }