From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6685 invoked by alias); 4 Jul 2019 14:22:46 -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 6677 invoked by uid 89); 4 Jul 2019 14:22:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1256 X-HELO: EUR04-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr70083.outbound.protection.outlook.com (HELO EUR04-HE1-obe.outbound.protection.outlook.com) (40.107.7.83) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 14:22:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FHjwCTAKw/dXY9wLVt6pNYNie16nc65wSadUkpVjLeI=; b=JA2ykPKqtMwgRJvunOUgUZfdBXEtMAhnYlGRQ+DY25PUgTH7OCn1+IHPb3AwiZV74STFB8H1vncLFRx5i4aHm/62KJutXJvuqbKMUTEBTd3NpfrrA5rnI4VPULsMqu/E9f2YmDKnvhUz77oTAwe5Cjto8Y6VH06tE1L6yJ68+50= Received: from VI1PR08MB3200.eurprd08.prod.outlook.com (52.133.15.152) by VI1SPR01MB331.eurprd08.prod.outlook.com (52.134.123.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2032.20; Thu, 4 Jul 2019 14:22:40 +0000 Received: from VI1PR08MB3200.eurprd08.prod.outlook.com ([fe80::a420:c6e1:2e3a:9433]) by VI1PR08MB3200.eurprd08.prod.outlook.com ([fe80::a420:c6e1:2e3a:9433%7]) with mapi id 15.20.2052.010; Thu, 4 Jul 2019 14:22:40 +0000 From: Richard Bunt To: Andreas Schwab , Tom Tromey CC: "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH] Restore original GDB prompt in define.exp Date: Thu, 04 Jul 2019 14:22:00 -0000 Message-ID: References: <32795df0-3a46-2b7d-3db8-2902e0f55481@arm.com> <87lfxfjiz6.fsf@tromey.com> In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Richard.Bunt@arm.com; x-ms-oob-tlc-oobclassifiers: OLM:6108; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 Content-Type: text/plain; charset="utf-8" Content-ID: Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Richard.Bunt@arm.com X-IsSubscribed: yes X-SW-Source: 2019-07/txt/msg00095.txt.bz2 DQoNCk9uIDcvMy8xOSAzOjQ4IFBNLCBBbmRyZWFzIFNjaHdhYiB3cm90ZToN Cj4gT24gSnVsIDAzIDIwMTksIFRvbSBUcm9tZXkgPHRvbUB0cm9tZXkuY29t PiB3cm90ZToNCj4gDQo+Pj4+Pj4+ICJSaWNoYXJkIiA9PSBSaWNoYXJkIEJ1 bnQgPFJpY2hhcmQuQnVudEBhcm0uY29tPiB3cml0ZXM6DQo+Pg0KPj4gUmlj aGFyZD4gLWdkYl90ZXN0X211bHRpcGxlICJzZXQgcHJvbXB0IFxcKGdkYlxc KSAiICJyZXNldCBnZGJfcHJvbXB0IiB7DQo+PiBSaWNoYXJkPiArZ2RiX3Rl c3RfbXVsdGlwbGUgInNldCBwcm9tcHQgJGdkYl9wcm9tcHQgIiAicmVzZXQg Z2RiX3Byb21wdCIgew0KPj4NCj4+IFRoaXMgaXMgcGVjdWxpYXIgYmVjYXV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GluZyBiZWhhdmlvciwgYnV0IEkgc2VlIG5vIG5l ZWQgZm9yIHRoZSBwcm9tcHQgcmVzdG9yZSB0ZXN0IHRvIHJlbHkNCm9uIGl0 Lg0KDQpNYW55IHRoYW5rcywNCg0KUmljaA0K >From gdb-patches-return-157268-listarch-gdb-patches=sources.redhat.com@sourceware.org Thu Jul 04 15:47:09 2019 Return-Path: Delivered-To: listarch-gdb-patches@sources.redhat.com Received: (qmail 114269 invoked by alias); 4 Jul 2019 15:47:09 -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 Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 114256 invoked by uid 89); 4 Jul 2019 15:47:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 15:47:07 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20B6D368E7 for ; Thu, 4 Jul 2019 15:47:06 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D7D48501 for ; Thu, 4 Jul 2019 15:47:05 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [pushed] Fix foreach_with_prefix regression Date: Thu, 04 Jul 2019 15:47:00 -0000 Message-Id: <20190704154704.3501-1-palves@redhat.com> X-SW-Source: 2019-07/txt/msg00096.txt.bz2 Content-length: 4836 Fix a silly bug in commit a26c8de0ee93 ("Fix early return in foreach_with_prefix"). That patch made foreach_with_prefix always return after the first iteration, making ~10k tests disappear from test runs... This fixes it, and as penance, adds a testcase that exercises all kinds of different returns possible (ok, error, return, break, continue). I've written it with regular "foreach", and then switched to foreach_with_prefix and made sure we get the same results. I put the testcase in a new gdb.testsuite/ subdir, since this is exercising the testsuite harness bits. We can move this elsewhere if people prefer a different place, but I'm going ahead in order to unbreak the testsuite ASAP. gdb/testsuite/ChangeLog: 2019-07-04 Pedro Alves * lib/gdb.exp (foreach_with_prefix): Don't return early if body returned ok(0), break(3) or continue(4). * gdb.testsuite/foreach_with_prefix.exp: New file. --- gdb/testsuite/ChangeLog | 6 ++ .../gdb.testsuite/foreach_with_prefix.exp | 98 ++++++++++++++++++++++ gdb/testsuite/lib/gdb.exp | 4 +- 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.testsuite/foreach_with_prefix.exp diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 2ad89ac01f5..7631cce62a9 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-07-04 Pedro Alves + + * lib/gdb.exp (foreach_with_prefix): Don't return early if + body returned ok(0), break(3) or continue(4). + * gdb.testsuite/foreach_with_prefix.exp: New file. + 2019-07-04 Alan Hayward * gdb.server/unittest.exp: Allow 0 unit tests to run. diff --git a/gdb/testsuite/gdb.testsuite/foreach_with_prefix.exp b/gdb/testsuite/gdb.testsuite/foreach_with_prefix.exp new file mode 100644 index 00000000000..9cd41496c49 --- /dev/null +++ b/gdb/testsuite/gdb.testsuite/foreach_with_prefix.exp @@ -0,0 +1,98 @@ +# Copyright 2019 Free Software Foundation, Inc. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Testsuite self-tests for foreach_with_prefix. + +# Check that SEQVAR and EXPECTED_SEQ hold the same sequence. +proc check_sequence {seqvar expected_seq} { + verbose -log "\"$seqvar\" eq \"$expected_seq\"?" + + set test "sequence matches" + if {$seqvar eq $expected_seq} { + pass $test + } else { + fail $test + } +} + +# Test TCL_OK (0). +with_test_prefix "ok" { + set seq "" + foreach_with_prefix var1 {0 1} { + foreach_with_prefix var2 {0 1} { + lappend seq $var1 $var2 + } + } + + check_sequence $seq "0 0 0 1 1 0 1 1" +} + +# Test TCL_ERROR (1). +with_test_prefix "error" { + catch { + set seq "" + foreach_with_prefix var1 {0 1} { + foreach_with_prefix var2 {0 1} { + lappend seq $var1 $var2 + error $seq + } + } + return "unreachable" + } seq + + check_sequence $seq "0 0" +} + +# Test TCL_RETURN (2). +with_test_prefix "return" { + proc test_return {} { + set seq "" + foreach_with_prefix var1 {0 1} { + foreach_with_prefix var2 {0 1} { + lappend seq $var1 $var2 + return $seq + } + } + return $seq + } + + set seq [test_return] + check_sequence $seq "0 0" +} + +# Test TCL_BREAK (3). +with_test_prefix "break" { + set seq "" + foreach_with_prefix var1 {0 1} { + foreach_with_prefix var2 {0 1} { + lappend seq $var1 $var2 + break + } + } + + check_sequence $seq "0 0 1 0" +} + +# Test TCL_CONTINUE (4). +with_test_prefix "continue" { + set seq "" + foreach_with_prefix var1 {0 1} { + foreach_with_prefix var2 {0 1} { + lappend seq $var1 $var2 + continue + } + } + + check_sequence $seq "0 0 0 1 1 0 1 1" +} diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 41f0ef58393..49ec8b2a550 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -2031,7 +2031,9 @@ proc foreach_with_prefix {var list body} { if {$code == 1} { global errorInfo errorCode return -code $code -errorinfo $errorInfo -errorcode $errorCode $result - } else { + } elseif {$code == 3} { + break + } elseif {$code == 2} { return -code $code $result } } -- 2.14.5