From patchwork Tue Jul 9 07:17:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Bunt X-Patchwork-Id: 33627 Received: (qmail 34610 invoked by alias); 9 Jul 2019 07:17:15 -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 34596 invoked by uid 89); 9 Jul 2019 07:17:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=stephen, Stephen X-HELO: EUR04-DB3-obe.outbound.protection.outlook.com Received: from mail-eopbgr60085.outbound.protection.outlook.com (HELO EUR04-DB3-obe.outbound.protection.outlook.com) (40.107.6.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Jul 2019 07:17:12 +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=jxI4gBw5ba0kFV77n/Ho20au00DKeEGElccliTclG6g=; b=SoUo2UlR+WZnellq+/vTNONncNGsMxRFC2AbX/E4FV1co8b6u6j8SfqYOqxUUEiVys9OsNVxrR8JPTXr4jOBT6D8lX74qBsZWILM5uNecJOnBHCpbGKvvPkacvF2LenNYM0hHbRUW+cSnHsY3PSdGMThgurqg4cgfQeVWWSivxY= Received: from VI1PR08MB3200.eurprd08.prod.outlook.com (52.133.15.152) by VI1PR08MB4271.eurprd08.prod.outlook.com (20.179.25.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18; Tue, 9 Jul 2019 07:17:08 +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.020; Tue, 9 Jul 2019 07:17:08 +0000 From: Richard Bunt To: "gdb-patches@sourceware.org" CC: nd Subject: [PATCH v2] Restore original GDB prompt in define.exp Date: Tue, 9 Jul 2019 07:17:08 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Richard.Bunt@arm.com; x-ms-oob-tlc-oobclassifiers: OLM:4941; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 Content-ID: <70B371EDD073084DA69BC07BEC87B358@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Richard.Bunt@arm.com X-IsSubscribed: yes Restore original GDB prompt in define.exp define.exp will fail on a GDB which has set a custom prompt to identify itself. This is because the test resets the prompt to a hard coded "(gdb)" but then verifies the success of this against the value in $gdb_prompt, which is set to the custom prompt. The original approach to fix this involved resetting the prompt to $gdb_prompt rather than a hard coded "(gdb)". However it was noted during review that $gdb_prompt is a regular expression rather than a string. This is problematic because in general the prompt would be reset to a regular expression rather than an instance of a string accepted by said regular expression. The fix used in commit avoids the above issue by capturing the literal prompt from running "show prompt" and uses this literal to restore the previous prompt. Regression tested with GCC 7.3.0 on x86_64, ppc64le, aarch64. gdb/testsuite/ChangeLog: 2019-07-04 Richard Bunt Stephen Roberts * gdb.base/define.exp: Restore original prompt. --- gdb/testsuite/gdb.base/define.exp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp index 0590da9..e8508b8 100644 --- a/gdb/testsuite/gdb.base/define.exp +++ b/gdb/testsuite/gdb.base/define.exp @@ -283,6 +283,15 @@ gdb_test_multiple "define target hookpost-testsuite" "" { gdb_test "target testsuite" "one\r\nhello\r\ntwo" "target testsuite with hooks" +# Save the GDB prompt so it can be restored to the original value later. +set prior_prompt "" +gdb_test_multiple "show prompt" "save gdb_prompt" { + -re "Gdb's prompt is \"($gdb_prompt) \"\.\[\r\n\]*$gdb_prompt $" { + set prior_prompt $expect_out(1,string) + pass "save gdb_prompt" + } +} + # This is a quasi-define command: Verify that the user can redefine # GDB's gdb_prompt. # @@ -292,7 +301,7 @@ gdb_test_multiple "set prompt \\(blah\\) " "set gdb_prompt" { } } -gdb_test_multiple "set prompt \\(gdb\\) " "reset gdb_prompt" { +gdb_test_multiple "set prompt $prior_prompt " "reset gdb_prompt" { -re "$gdb_prompt $" { pass "reset gdb_prompt" }