From patchwork Thu Feb 21 10:34:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 31538 Received: (qmail 103911 invoked by alias); 21 Feb 2019 10:34:35 -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 103897 invoked by uid 89); 21 Feb 2019 10:34:34 -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, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Safe, confuse X-HELO: EUR04-VI1-obe.outbound.protection.outlook.com Received: from mail-eopbgr80058.outbound.protection.outlook.com (HELO EUR04-VI1-obe.outbound.protection.outlook.com) (40.107.8.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Feb 2019 10:34:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5bdBJ6+f7mF729rbSy3ftKqijt9W06WgWD7Fa9tPEA0=; b=jOyUxdNmOpxR9Ji/VfMnacvPY+g7pKLXslw/0IO7+nTYfi8usUFZm1cEWMxtWBv2IJW3PGHr1DOSY4DzU3FzznJfovzRnYbxpgNJk7aiswbc4Au+QNTxOyIc9fOA1DgOFdynr4+sazih702kzkgSqv1V4ZEFUcz7fond80obykc= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2390.eurprd08.prod.outlook.com (10.172.250.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.19; Thu, 21 Feb 2019 10:34:30 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::e974:35a7:c83c:e5b7]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::e974:35a7:c83c:e5b7%3]) with mapi id 15.20.1622.020; Thu, 21 Feb 2019 10:34:30 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd , Alan Hayward Subject: [PATCH] Testsuite: Ensure changing directory does not break the log file Date: Thu, 21 Feb 2019 10:34:29 +0000 Message-ID: <20190221103420.18162-1-alan.hayward@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-IsSubscribed: yes get_compiler_info switches to a new log file before checking the compiler to ensure the checks are not logged. Afterwards it restores back to using the original log file. However, the logfile uses a relative path name - if the current test has changed the current directory then all further output for the test will be lost. This can confuse the code that collates the main gdb.log file at the end of a FORCE_PARALLEL run. fullpath-expand.exp calls gdb_compile after changing the current directory. The "Ensure stack protection is off for GCC" patch added a call to get_compiler_info from inside of gdb_compile, causing log file collection to break for FORCE_PARALLEL runs. The ideal solution would be to ensure the log file is always created using an absolute path name. However, this is set at multiple points in Makefile.in and in some instances just relies on dejagnu common code to set the log file directory to "." The simpler and safer solution is to override the builtin cd function. The new function checks the current log file and if the path is relative, then it resets the logging using an absolute path. Finally it calls the builtin cd. This ensures get_compiler_info (and any other code) can correctly backup and restore the current log file. Tested with make check and native-gdbserver. gdb/testsuite/ChangeLog: 2019-02-21 Alan Hayward * lib/gdb.exp (builtin_cd): rename of cd. (cd): Override builtin. --- gdb/testsuite/lib/gdb.exp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index d05854329d..17e437956d 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -6284,5 +6284,24 @@ proc gdb_define_cmd {command command_list} { } } +# Safe version of cd that ensures the log file is not stopped. + +rename cd builtin_cd + +proc cd { dir } { + # Get logfile, which will be prefixed with "-a ". + set saved_log [log_file -info] + + # If the logfile is a relative path, reset it to an absolute path. + if { [regexp "^-a \[^/\]" $saved_log match] } { + set saved_log [string replace $saved_log 0 2] + log_file + log_file -a "[pwd]/$saved_log" + } + + # Call the builtin version of cd. + builtin_cd $dir +} + # Always load compatibility stuff. load_lib future.exp