From patchwork Wed Feb 6 23:11:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 31337 Received: (qmail 48407 invoked by alias); 6 Feb 2019 23:11:41 -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 48395 invoked by uid 89); 6 Feb 2019 23:11:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, MIME_BASE64_BLANKS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: sesbmg23.ericsson.net Received: from sesbmg23.ericsson.net (HELO sesbmg23.ericsson.net) (193.180.251.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Feb 2019 23:11:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1549494696; x=1552086696; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PasGgOHboh9chpFSgOs6fWOStShhBzLsD8JG15Elxq4=; b=CC0p2gKNURnyoFt+gMHlvbKItNz4D/d8tn0SnXMQ6hba3pdtOTdg3AeGIptGzK3o oga0FSmSOA0C5beTWLVmA9B4slvOi54Ik9POorZ8MYeWwwjfxlQOWBfJ0umizs0i 3cJYkHw9MNllVzxaVJ29YInJuSz/kMK5EkGjQ+PDH+Y=; Received: from ESESBMB502.ericsson.se (Unknown_Domain [153.88.183.115]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id E2.DD.24567.8A96B5C5; Thu, 7 Feb 2019 00:11:36 +0100 (CET) Received: from ESESBMR506.ericsson.se (153.88.183.202) by ESESBMB502.ericsson.se (153.88.183.115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 7 Feb 2019 00:11:36 +0100 Received: from ESESBMB501.ericsson.se (153.88.183.168) by ESESBMR506.ericsson.se (153.88.183.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 7 Feb 2019 00:11:36 +0100 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB501.ericsson.se (153.88.183.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Thu, 7 Feb 2019 00:11:36 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PasGgOHboh9chpFSgOs6fWOStShhBzLsD8JG15Elxq4=; b=LS9BKtcpH9S6OjtG3PeXnOX7k0C6Xq0I75vYDsw4qNumzBD4n5uuONRAOBChW4PEyECiKbph7GEYThUMpUiJ5KhGqvsuUSfPg17KAaYmUkHje3DZHGHtsYxln0NrFBwFBEHqWLuOFe3D1HnkDlvnpOumpKJKjcjXVD4kB58TcfE= Received: from BYAPR15MB2390.namprd15.prod.outlook.com (52.135.198.30) by BYAPR15MB3494.namprd15.prod.outlook.com (20.179.60.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.17; Wed, 6 Feb 2019 23:11:32 +0000 Received: from BYAPR15MB2390.namprd15.prod.outlook.com ([fe80::5445:37d6:bd5d:b8ce]) by BYAPR15MB2390.namprd15.prod.outlook.com ([fe80::5445:37d6:bd5d:b8ce%5]) with mapi id 15.20.1601.016; Wed, 6 Feb 2019 23:11:32 +0000 From: Simon Marchi To: Pedro Alves , Simon Marchi , "gdb-patches@sourceware.org" CC: "philippe.waroquiers@skynet.be" Subject: Re: [PATCH] Make gdb.base/corefile.exp work on terminals with few rows Date: Wed, 6 Feb 2019 23:11:32 +0000 Message-ID: References: <20190206034857.14608-1-simon.marchi@polymtl.ca> <12fe97cd-e3d9-56dd-fd88-f3c0fd7adae1@redhat.com> In-Reply-To: <12fe97cd-e3d9-56dd-fd88-f3c0fd7adae1@redhat.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; received-spf: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 Content-ID: <1A5B14E68DC46E498758B668264F7E0A@namprd15.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED Return-Path: simon.marchi@ericsson.com X-IsSubscribed: yes On 2019-02-06 1:42 p.m., Pedro Alves wrote: > On 02/06/2019 03:48 AM, Simon Marchi wrote: >> When creating a pty to spawn a subprocess (such as gdb), Expect >> copies the settings of its own controlling terminal, including the >> number of rows and columns. If you "make check" on a terminal with just >> a few rows (e.g. 4), GDB will paginate before reaching the initial >> prompt. In default_gdb_start, used by most tests, this is already >> handled: if we see the pagination prompt, we sent \n to continue. >> >> Philippe reported that gdb.base/corefile.exp didn't work in terminals >> with just a few rows. This test spawns GDB by hand, because it needs to >> check things before the initial prompt, which it couldn't do if it used >> default_gdb_start. >> >> In this case I think it's not safe to use the same technique as in >> default_gdb_start. Even if we could send a \n if we see a pagination >> prompt, we match some multiline regexes in there. So if a pagination >> slips in there, it might make the regexes not match and fail the test. >> >> It's also not possible to use -ex "set height 0" or -iex "set height 0", >> it is handled after the introduction text is shown. >> >> The simplest way I found to avoid showing the pagination completely is >> to set stty_init (documented in expect's man page) to initialize gdb's >> pty with a fixed number of rows. > > Hmm, good idea. But, if you have a small terminal with just a few > columns (as opposed to rows), then the testsuite all breaks, AFAICT. > > E.g., I just tried running gdb.base/break.exp with a small window and > the test hangs starting GDB. > > But with: > > --- c/gdb/testsuite/lib/gdb.exp > +++ w/gdb/testsuite/lib/gdb.exp > @@ -4752,6 +4752,9 @@ proc gdb_init { test_file_name } { > # tests. > setenv TERM "dumb" > > + global stty_init > + set stty_init "rows 25 cols 80" > + > # Some tests (for example gdb.base/maint.exp) shell out from gdb to use > # grep. Clear GREP_OPTIONS to make the behavior predictable, > # especially having color output turned on can cause tests to fail. > > ... it passes. And so does gdb.base/corefile.exp. > > Is there any reason we'd ever want GDB's terminal size to match > whatever the user's term size was? I'd think that sanitizing / forcing > the same sizes everywhere would just lead to more stable testing, > and thus be a good thing. Agreed. If we do this, we can remove the part where we match the pagination prompt during startup, like so: From 67bb1dde957fcd8a0168fb04afa3f8e3a4ccf9bb Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 5 Feb 2019 22:48:57 -0500 Subject: [PATCH] Make gdb.base/corefile.exp work on terminals with few rows When creating a pty to spawn a subprocess (such as gdb), Expect copies the settings of its own controlling terminal, including the number of rows and columns. If you "make check" on a terminal with just a few rows (e.g. 4), GDB will paginate before reaching the initial prompt. In default_gdb_start, used by most tests, this is already handled: if we see the pagination prompt, we sent \n to continue. Philippe reported that gdb.base/corefile.exp didn't work in terminals with just a few rows. This test spawns GDB by hand, because it needs to check things before the initial prompt, which it couldn't do if it used default_gdb_start. In this case I think it's not safe to use the same technique as in default_gdb_start. Even if we could send a \n if we see a pagination prompt, we match some multiline regexes in there. So if a pagination slips in there, it might make the regexes not match and fail the test. It's also not possible to use -ex "set height 0" or -iex "set height 0", it is handled after the introduction text is shown. The simplest way I found to avoid showing the pagination completely is to set stty_init (documented in expect's man page) to initialize gdb's pty with a fixed number of rows. And actually, if we set stty_init in gdb_init, it works nicely as a general solution applicable to all tests. We can therefore remove the solution introduced in e882ef3cfc3 ("testsuite: expect possible pagination when starting gdb") where we matched the pagination prompt during startup. gdb/testsuite/ChangeLog: * lib/gdb.exp (default_gdb_start): Don't match pagination prompt. (gdb_init): Set stty_init. --- gdb/testsuite/lib/gdb.exp | 44 ++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 24 deletions(-) -- 2.20.1 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index bc7ba12d480..d05854329d8 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1638,7 +1638,7 @@ proc default_gdb_spawn { } { # Default gdb_start procedure. proc default_gdb_start { } { - global gdb_prompt pagination_prompt + global gdb_prompt global gdb_spawn_id global inferior_spawn_id @@ -1659,29 +1659,20 @@ proc default_gdb_start { } { # When running over NFS, particularly if running many simultaneous # tests on different hosts all using the same server, things can # get really slow. Give gdb at least 3 minutes to start up. - set loop_again 1 - while { $loop_again } { - set loop_again 0 - gdb_expect 360 { - -re "$pagination_prompt" { - verbose "Hit pagination during startup. Pressing enter to continue." - send_gdb "\n" - set loop_again 1 - } - -re "\[\r\n\]$gdb_prompt $" { - verbose "GDB initialized." - } - -re "$gdb_prompt $" { - perror "GDB never initialized." - unset gdb_spawn_id - return -1 - } - timeout { - perror "(timeout) GDB never initialized after 10 seconds." - remote_close host - unset gdb_spawn_id - return -1 - } + gdb_expect 360 { + -re "\[\r\n\]$gdb_prompt $" { + verbose "GDB initialized." + } + -re "$gdb_prompt $" { + perror "GDB never initialized." + unset gdb_spawn_id + return -1 + } + timeout { + perror "(timeout) GDB never initialized after 10 seconds." + remote_close host + unset gdb_spawn_id + return -1 } } @@ -4752,6 +4743,11 @@ proc gdb_init { test_file_name } { # tests. setenv TERM "dumb" + # Initialize GDB's pty with a fixed size, to make sure we avoid pagination + # during startup. See "man expect" for details about stty_init. + global stty_init + set stty_init "rows 25 cols 80" + # Some tests (for example gdb.base/maint.exp) shell out from gdb to use # grep. Clear GREP_OPTIONS to make the behavior predictable, # especially having color output turned on can cause tests to fail.