From patchwork Fri Feb 7 14:59:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shahab Vahedi X-Patchwork-Id: 37734 Received: (qmail 81878 invoked by alias); 7 Feb 2020 15:01:06 -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 81353 invoked by uid 89); 7 Feb 2020 15:00:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-lj1-f195.google.com Received: from mail-lj1-f195.google.com (HELO mail-lj1-f195.google.com) (209.85.208.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Feb 2020 15:00:50 +0000 Received: by mail-lj1-f195.google.com with SMTP id x7so2489743ljc.1 for ; Fri, 07 Feb 2020 07:00:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qOlWZgg7XsBDOe5yzAQjPKUyg6eWsLMyQj5tKYXKyRU=; b=SA3iQ4z9yyzXJPDxtBlv2jz0+N2PkVkixcgOQmZ5ki4SakcEzUmUuEOAnxmbwaChVk sQtUYc6l3lP2ECcEQTaALdSpvKuWg5fidh9RcmESVD/ZZ4PVITPS1ixx8g3bBenxXTB7 UWTqFoNlG9PTCZgdksBI1HmH3LXqemZ+d903V1FqVL2h5UT4duDdsd6wN+xQ4Sd9GwRL +X8GAsscTxIXroyHfIldwMJmdT72JqPi/RGvDhvHQMWPeZTEF4sXroSIpeWLaxlO7rYM FPqv1vtH1me7iW7UT8SXLbQ6R2/94VUUeGvVg5VodPi6yw8vdVeW/1dtYr2lKsmGMMSv aA1A== Return-Path: Received: from archie.internal.synopsys.com ([2a03:1b20:6:f011::2d]) by smtp.gmail.com with ESMTPSA id p136sm1184412lfa.8.2020.02.07.07.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 07:00:47 -0800 (PST) From: Shahab Vahedi To: gdb-patches@sourceware.org Cc: Shahab Vahedi , Shahab Vahedi , Francois Bedard , Anton Kolesov Subject: [PATCH 06/14] gdb/testsuite: Fix gdb.mi exit function Date: Fri, 7 Feb 2020 15:59:55 +0100 Message-Id: <20200207150003.8383-7-shahab.vahedi@gmail.com> In-Reply-To: <20200207150003.8383-1-shahab.vahedi@gmail.com> References: <20200207150003.8383-1-shahab.vahedi@gmail.com> MIME-Version: 1.0 From: Anton Kolesov There was a bug in gdb.mi tests where GDB was trying to connect to same GDBserver twice, because first instance wasn't properly killed after test is finished. That was happening with tests that run MI in a separate tty. Spawn id of this second UI was set as a default spawn_id of this application, however function "exp_pid" couldn't return a valid process ID for that spawn_id. As a result standard_close, invoked from gdb_exit failed to kill GDB process by PID. This patch fixes this problem by making sure that mi_gdb_exit will set current spawn_id to the ID of the main GDB tty, so that exp_pid will work and GDB will be killed. This patch also adds explicit invocation of mi_gdb_exit to the end of mi-break.exp tests, because those tests use separate tty for MI, so should use mi_gdb_exit, but by default runtest invokes gdb_exit when .exp file is finished, not the mi_gdb_exit. gdb/testsuite/ChangeLog: 2016-07-14 Anton Kolesov * gdb.mi/mi-break.exp (test_break): Explicitly exit the MI gdb. * gdb.mi/mi-watch.exp (test_watchpoint_all): Likewise. * lib/mi-support.exp (mi_uncatched_gdb_exit): Switch back to "main spawn id" before "remote_close". Signed-off-by: Anton Kolesov --- gdb/testsuite/gdb.mi/mi-break.exp | 5 +++++ gdb/testsuite/gdb.mi/mi-watch.exp | 5 +++++ gdb/testsuite/lib/mi-support.exp | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp index acec246f52ee..925a08e7190a 100644 --- a/gdb/testsuite/gdb.mi/mi-break.exp +++ b/gdb/testsuite/gdb.mi/mi-break.exp @@ -432,6 +432,11 @@ proc test_break {mi_mode} { test_abreak_creation test_explicit_breakpoints + + # If separate-mi-tty is used, GDB will not be properly closed by the + # default gdb_exit, which is called by default when .exp file is finished. + # Instead a mi_gdb_exit must be used. + mi_gdb_exit } if [gdb_debug_enabled] { diff --git a/gdb/testsuite/gdb.mi/mi-watch.exp b/gdb/testsuite/gdb.mi/mi-watch.exp index fe09f1dea404..1545f39bdc78 100644 --- a/gdb/testsuite/gdb.mi/mi-watch.exp +++ b/gdb/testsuite/gdb.mi/mi-watch.exp @@ -172,6 +172,11 @@ proc test_watchpoint_all {mi_mode type} { #test_rwatch_creation_and_listing #test_awatch_creation_and_listing test_watchpoint_triggering + + # If separate-mi-tty is used, GDB will not be properly closed by the + # default gdb_exit, which is called by default when .exp file is finished. + # Instead a mi_gdb_exit must be used. + mi_gdb_exit } if [gdb_debug_enabled] { diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 2c67cc287dce..922b021099ac 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -91,6 +91,13 @@ proc mi_uncatched_gdb_exit {} { } if ![is_remote host] { + # DejaGNU's standard_close uses spawn_id to figure out PID through + # exp_pid and then kill process by ID. However, when MI runs on + # secondary UI exp_pid returns nothing for it's spawn_id, so we have to + # switch back to the main spawn_id for remote_close to succeed. + if { $gdb_main_spawn_id != $gdb_spawn_id } { + switch_gdb_spawn_id $gdb_main_spawn_id + } remote_close host } unset gdb_spawn_id