From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30887 invoked by alias); 23 Oct 2013 22:59:30 -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 30871 invoked by uid 89); 23 Oct 2013 22:59:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Oct 2013 22:59:28 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1VZ7Of-0001dZ-2G from Maciej_Rozycki@mentor.com for gdb-patches@sourceware.org; Wed, 23 Oct 2013 15:59:25 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 23 Oct 2013 15:59:25 -0700 Received: from [172.30.64.175] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Wed, 23 Oct 2013 23:59:23 +0100 Date: Wed, 23 Oct 2013 22:59:00 -0000 From: "Maciej W. Rozycki" To: Subject: [PATCH] testsuite: Persistent gdbserver cleanup Message-ID: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2013-10/txt/msg00738.txt.bz2 Hi, We have a number of tests that run `gdbserver' in the persistent mode, to be able to disconnect and reconnect. That has a side effect of leaving the `gdbserver' behind upon GDB termination at the conclusion of the respective test cases, because no kill request is sent to `gdbserver' at the end of session and as a result of receiving a KILL signal GDB merely disconnects. This causes problems in some remote test environments, such as QEMU in the system emulation mode, where `gdbserver' is run within Linux run on QEMU and QEMU's TCP port forwarding feature is used to communicate with the `gdbserver'. In this case a single TCP port is used to talk to `gdbserver' and a subsequent test case faces `gdbserver' still running controlling the program used for the test case that has just concluded. Killing off that `gdbserver' process, while possible, is complicated and I think test cases should try to leave the state clean if possible, so here's my proposal to make the harness explicitly request `gdbserver' to terminate before killing off GDB where the persistent mode has been requested. Additionally one test case terminated GDB in a disconnected state, so I made it reconnect before completion. No regressions in mips-linux-gnu testing. OK to apply? 2013-10-23 Maciej W. Rozycki gdb/testsuite/ * lib/gdb.exp (gdb_finish): Send a kill request to `gdbserver' if in the persistent mode. * gdb.trace/disconnected-tracing.exp: Reconnect before completion. Maciej gdb-test-gdbserver-reconnect-kill.diff Index: gdb-fsf-trunk-quilt/gdb/testsuite/gdb.trace/disconnected-tracing.exp =================================================================== --- gdb-fsf-trunk-quilt.orig/gdb/testsuite/gdb.trace/disconnected-tracing.exp 2013-10-17 22:42:31.578765350 +0100 +++ gdb-fsf-trunk-quilt/gdb/testsuite/gdb.trace/disconnected-tracing.exp 2013-10-17 22:44:53.117689854 +0100 @@ -147,3 +147,6 @@ proc disconnected_tfind { } { } disconnected_tfind + +# Reconnect for a clean gdbserver shutdown. +gdb_reconnect Index: gdb-fsf-trunk-quilt/gdb/testsuite/lib/gdb.exp =================================================================== --- gdb-fsf-trunk-quilt.orig/gdb/testsuite/lib/gdb.exp 2013-10-17 22:44:51.618780708 +0100 +++ gdb-fsf-trunk-quilt/gdb/testsuite/lib/gdb.exp 2013-10-17 22:44:53.117689854 +0100 @@ -3612,8 +3612,23 @@ proc gdb_init { args } { } proc gdb_finish { } { + global gdbserver_reconnect_p + global gdb_prompt global cleanfiles + # Give persistent gdbserver a chance to terminate before GDB is killed. + if {[info exists gdbserver_reconnect_p] && $gdbserver_reconnect_p} { + send_gdb "kill\n"; + gdb_expect 10 { + -re "y or n" { + send_gdb "y\n"; + exp_continue; + } + -re "$gdb_prompt $" { + } + } + } + # Exit first, so that the files are no longer in use. gdb_exit