From patchwork Tue May 14 15:12:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 32682 Received: (qmail 61083 invoked by alias); 14 May 2019 15:13:03 -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 61021 invoked by uid 89); 14 May 2019 15:13:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=**************, race X-HELO: EUR03-DB5-obe.outbound.protection.outlook.com Received: from mail-eopbgr40078.outbound.protection.outlook.com (HELO EUR03-DB5-obe.outbound.protection.outlook.com) (40.107.4.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 May 2019 15:13:00 +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=NHEHX4Z/t7XBbaduLJtCOwsX9CEBu8BMsCmcB+W+XGQ=; b=ntwkXDGAG72NeVu7c69sNWnPKmY99WDaqW/pi26lyAuLgE/sI4cMK2QOCdKTy6kHmRjvoZSNoa+rEAg/JZ19T8Ak0cbmeoM1HK6Rfk+WTKIXWRSEVbDs0F1WmyeS3Cd0kU77NH1LA+1GFvotvuTOylmONFDL7p28So+VDFFPmhg= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2535.eurprd08.prod.outlook.com (10.172.251.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Tue, 14 May 2019 15:12:48 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::8c26:bb4b:6c93:9d40]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::8c26:bb4b:6c93:9d40%2]) with mapi id 15.20.1878.024; Tue, 14 May 2019 15:12:48 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd , Alan Hayward Subject: [PATCH 7/9] testsuite: Add replay logging to GDBSERVER_DEBUG Date: Tue, 14 May 2019 15:12:47 +0000 Message-ID: <20190514151238.8765-8-alan.hayward@arm.com> References: <20190514151238.8765-1-alan.hayward@arm.com> In-Reply-To: <20190514151238.8765-1-alan.hayward@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-oob-tlc-oobclassifiers: OLM:10000; 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 Add "replay" to the list of GDBSERVER_DEBUG options. This will cause a gdbserver.replay file to be written to the test output directory. At the same time switch this to a comma separated list in order to easily handle all possible options. The replay log is created by GDB, but has been added to GDBSERVER_DEBUG as it is only required for gdbserver tests. To enable it, the gdb_debug_init is overridden to allow the additional checking, before calling the original function. 2019-05-14 Alan Hayward * README (Testsuite Parameters): Add replay logging to GDBSERVER_DEBUG. (gdbserver,debug): Refer to GDBSERVER_DEBUG. * lib/gdbserver-support.exp (gdbserver_start): Treat gdbserverdebug as a comma separated list. (gdb_debug_init): Override procedure. --- gdb/testsuite/README | 21 +++++---- gdb/testsuite/lib/gdbserver-support.exp | 59 ++++++++++++++++++++----- 2 files changed, 59 insertions(+), 21 deletions(-) -- 2.20.1 (Apple Git-117) diff --git a/gdb/testsuite/README b/gdb/testsuite/README index 43f35a9d4bd..98fc8d1b852 100644 --- a/gdb/testsuite/README +++ b/gdb/testsuite/README @@ -304,14 +304,16 @@ For example, to turn on debugging for infrun and target, you can do: GDBSERVER_DEBUG -When set gdbserver debug is sent to the file gdbserver.debug in the test -output directory. Valid values are: - debug - turn on gdbserver debug. - remote - turn on gdbserver remote debug. - all - turn on all the above debug options. -For example, to turn on all gdbserver debugging, you can do: +When set gdbserver debug is sent to the a file in the test output directory. +It should be set to a comma separated list of the following options: + debug - write gdbserver debug to gdbserver.debug. + remote - write gdbserver remote debug to gdbserver.debug. + replay - write a replay log to the file gdbserver.replay for use + with gdbreplay. +Alternatively, it can be set to "all" to turn on all the above +For example, to turn on gdbserver debugging, you can do: - make check GDBSERVER_DEBUG=all + make check GDBSERVER_DEBUG="debug,replay" Race detection ************** @@ -527,10 +529,7 @@ gdb,debug gdbserver,debug When set gdbserver debug is sent to the file gdbserver.debug in the test - output directory. Valid values are: - "debug" - turn on gdbserver debug. - "remote" - turn on gdbserver remote debug. - "all" - turn on all the above debug options. + output directory. For valid values see the entry for GDBSERVER_DEBUG. Testsuite Organization ********************** diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index 54aa55771c1..2ccc717ef60 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -293,13 +293,23 @@ proc gdbserver_start { options arguments } { # Enable debug if set. if [gdbserver_debug_enabled] { global gdbserverdebug - set debugfile [standard_output_file gdbserver.debug] - if { $gdbserverdebug == "debug" } { - append gdbserver_command " --debug --debug-file=$debugfile" - } elseif { $gdbserverdebug == "remote" } { - append gdbserver_command " --remote-debug --debug-file=$debugfile" - } elseif { $gdbserverdebug == "all" } { - append gdbserver_command " --debug --remote-debug --debug-file=$debugfile" + set enabled 0 + foreach entry [split $gdbserverdebug ,] { + switch -- $entry { + "debug" { + append gdbserver_command " --debug" + set enabled 1 + } + "remote" { + append gdbserver_command " --remote-debug" + set enabled 1 + } + } + } + # Ensure debugfile is only added if something has been enabled + if { $enabled } { + set debugfile [standard_output_file gdbserver.debug] + append gdbserver_command " --debug-file=$debugfile" } } @@ -595,9 +605,13 @@ proc gdbserver_debug_enabled { } { } } - # Only return success on valid values. - return [expr { $gdbserverdebug == "debug" || $gdbserverdebug == "remote" - || $gdbserverdebug == "all" }] + # Expand the all option + if { $gdbserverdebug == "all" } { + set gdbserverdebug "debug,remote,replay" + } + + # Ensure it is not empty. + return [expr { $gdbserverdebug != "" }] } # Write the command line used to invocate gdbserver to the cmd file. @@ -608,3 +622,28 @@ proc gdbserver_write_cmd_file { cmdline } { puts $cmd_file $cmdline catch "close $cmd_file" } + +# Override gdb_debug_init so that we can set replay logging in GDB if required. +# Backup the original function so we can call it afterwards + +rename gdb_debug_init _gdb_debug_init + +proc gdb_debug_init { } { + global gdbserverdebug + global gdb_prompt + + if [gdbserver_debug_enabled] { + foreach entry [split $gdbserverdebug ,] { + if { $entry == "replay" } { + set replayfile [standard_output_file_with_gdb_instance gdbserver.replay] + send_gdb "set remotelogfile $replayfile\n" optional + gdb_expect 10 { + -re "$gdb_prompt $" {} + } + } + } + } + + # Now call the standard debug init function + _gdb_debug_init +}