From patchwork Tue May 14 15:12:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 32679 Received: (qmail 60041 invoked by alias); 14 May 2019 15:12:55 -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 59970 invoked by uid 89); 14 May 2019 15:12:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.7 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=RUNTESTFLAGS, hair, sends, FORCE_PARALLEL X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com Received: from mail-eopbgr150077.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (40.107.15.77) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 May 2019 15:12:53 +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=830LkC07JAQYHHQymVqA4bHOdKIJHIg5NRnz/QA1oEs=; b=H0I25Xc3kwaaXxPjX6svS1SBN/ptuX0+oC8LinUrFMhjesEgrt42wCTc6jzNyQL1QHNAgaecpFCk6wci6YKskXd1hpyntRigqBFazYC+jU40MM85/0HL1GJB0E1c0cd3YAvUU3wPe5KFNDGW4rlt9Huur/7rqx0Mz9HL7/2DjnA= 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:45 +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:45 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd , Alan Hayward Subject: [PATCH 3/9] testsuite: Add option to capture GDB debug Date: Tue, 14 May 2019 15:12:45 +0000 Message-ID: <20190514151238.8765-4-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:8882; 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 both board option and environment variable which enables gdb debug via a comma separated list and sends it to the file gdb.debug, located in the output directory for the current test. Document this. Add support for the environment variable in the Makefile. The testsuite can be run with gdb debug enabled in the following way: make check GDB_DEBUG="infrun,target,remote" A Test with multiple invocations of GDB will all append debug to the same log file. gdb/testsuite/ChangeLog: 2019-05-14 Alan Hayward * Makefile.in: Pass through GDB_DEBUG. * README (Testsuite Parameters): Add GDB_DEBUG. (gdb,debug): Add board setting. * lib/gdb.exp (default_gdb_start): Start debugging. (gdb_debug_enabled): New procedure. (gdb_debug_init): Likewise. --- gdb/testsuite/Makefile.in | 5 +++- gdb/testsuite/README | 16 ++++++++++++ gdb/testsuite/lib/gdb.exp | 54 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) -- 2.20.1 (Apple Git-117) diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in index 8d46fe15be4..2beba053ee6 100644 --- a/gdb/testsuite/Makefile.in +++ b/gdb/testsuite/Makefile.in @@ -52,6 +52,7 @@ RUNTESTFLAGS = FORCE_PARALLEL = +GDB_DEBUG = GDBSERVER_DEBUG = # Default number of iterations that we will use to run the testsuite @@ -164,15 +165,17 @@ check-read1: # status. TIMESTAMP = $(if $(TS),| $(srcdir)/print-ts.py $(if $(TS_FORMAT),$(TS_FORMAT),),) +gdb_debug = $(if $(GDB_DEBUG),GDB_DEBUG=$(GDB_DEBUG) ; export GDB_DEBUG ;,) gdbserver_debug = $(if $(GDBSERVER_DEBUG),GDBSERVER_DEBUG=$(GDBSERVER_DEBUG) ; export GDBSERVER_DEBUG ;,) + # All the hair to invoke dejagnu. A given invocation can just append # $(RUNTESTFLAGS) DO_RUNTEST = \ rootme=`pwd`; export rootme; \ srcdir=${srcdir} ; export srcdir ; \ EXPECT=${EXPECT} ; export EXPECT ; \ - EXEEXT=${EXEEXT} ; export EXEEXT ; $(gdbserver_debug) \ + EXEEXT=${EXEEXT} ; export EXEEXT ; $(gdb_debug) $(gdbserver_debug) \ $(RPATH_ENVVAR)=$$rootme/../../expect:$$rootme/../../libstdc++:$$rootme/../../tk/unix:$$rootme/../../tcl/unix:$$rootme/../../bfd:$$rootme/../../opcodes:$$$(RPATH_ENVVAR); \ export $(RPATH_ENVVAR); \ if [ -f $${rootme}/../../expect/expect ] ; then \ diff --git a/gdb/testsuite/README b/gdb/testsuite/README index 99d574511d2..43f35a9d4bd 100644 --- a/gdb/testsuite/README +++ b/gdb/testsuite/README @@ -293,6 +293,15 @@ can do: make check TS=1 TS_FORMAT='[%b %H:%S]' +GDB_DEBUG + +When set gdb debug is sent to the file gdb.debug in the test output +directory. It should be set to a comma separated list of gdb debug +components. +For example, to turn on debugging for infrun and target, you can do: + + make check GDB_DEBUG="infrun,target" + GDBSERVER_DEBUG When set gdbserver debug is sent to the file gdbserver.debug in the test @@ -508,6 +517,13 @@ gdb,nopie_flag The flag required to force the compiler to produce non-position-independent executables. +gdb,debug + + When set gdb debug is sent to the file gdb.debug in the test output + directory. It should be set to a comma separated list of gdb debug + components. For example, to turn on debugging for infrun and target, set to + "infrun,target". + gdbserver,debug When set gdbserver debug is sent to the file gdbserver.debug in the test diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 8dea857d5ed..ba276ac9297 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1746,6 +1746,8 @@ proc default_gdb_start { } { warning "Couldn't set the width to 0." } } + + gdb_debug_init return 0 } @@ -6409,6 +6411,58 @@ proc gdb_supported_languages {} { opencl rust minimal ada] } +# Check if debugging is enabled for gdb. + +proc gdb_debug_enabled { } { + global gdbdebug + + # If not already read, get the debug setting from environment or board setting. + if {![info exists gdbdebug]} { + global env + if [info exists env(GDB_DEBUG)] { + set gdbdebug $env(GDB_DEBUG) + } elseif [target_info exists gdb,debug] { + set gdbdebug [target_info gdb,debug] + } else { + return 0 + } + } + + # Ensure it not empty. + return [expr { $gdbdebug != "" }] +} + +# Turn on debugging if enabled, or reset if already on. + +proc gdb_debug_init { } { + + global gdb_prompt + + if ![gdb_debug_enabled] { + return; + } + + # First ensure logging is off. + send_gdb "set logging off\n" + + set debugfile [standard_output_file gdb.debug] + send_gdb "set logging file $debugfile\n" + + send_gdb "set logging debugredirect\n" + + global gdbdebug + foreach entry [split $gdbdebug ,] { + send_gdb "set debug $entry 1\n" + } + + # Now that everything is set, enable logging. + send_gdb "set logging on\n" + gdb_expect 10 { + -re "Copying output to $debugfile.*Redirecting debug output to $debugfile.*$gdb_prompt $" {} + timeout { warning "Couldn't set logging file" } + } +} + # Check if debugging is enabled for gdbserver. proc gdbserver_debug_enabled { } {