From patchwork Tue Apr 23 13:06:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 32382 Received: (qmail 48431 invoked by alias); 23 Apr 2019 13:06:52 -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 48369 invoked by uid 89); 23 Apr 2019 13:06:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 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, SPF_PASS autolearn=ham version=3.3.1 spammy=gigabytes X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr140075.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (40.107.14.75) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Apr 2019 13:06:49 +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=s3H53L7U2aupMMNrvFr3/SntRg8wosm0NGDKDeglX1I=; b=mjPlOC0YuOIWpvxL2ks8cZKCCH0BskfY3bQdhRxzUMJ9m7rPcwbF5VLowQQt9yAN6aBOb6XhqKSArXPmjoYfLmcbQ89N6XynwdNuI66bWCxQa4gC+7ecHXFAuDnk7lzWQAki04C+SKjuV/eQAN83s9eXOOau/CLDWelRKy3Sc2I= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2453.eurprd08.prod.outlook.com (10.172.250.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.14; Tue, 23 Apr 2019 13:06:33 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::399b:3a32:bff9:827e]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::399b:3a32:bff9:827e%11]) with mapi id 15.20.1813.017; Tue, 23 Apr 2019 13:06:33 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd , Alan Hayward Subject: [PATCH 4/4] testsuite: Add option to capture gdbserver debug Date: Tue, 23 Apr 2019 13:06:33 +0000 Message-ID: <20190423130624.94781-5-alan.hayward@arm.com> References: <20190423130624.94781-1-alan.hayward@arm.com> In-Reply-To: <20190423130624.94781-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 Add both board option and environment variable which enables gdbserver debug and sends it to the file gdbserver.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 gdbserver debug enabled in the following way: make check GDBSERVER_DEBUG=all Disable tspeed.exp when debugging to prevent the log file filling many gigabytes then timing out. gdb/testsuite/ChangeLog: 2019-04-23 Alan Hayward * Makefile.in: Pass through GDBSERVER_DEBUG. * README (Testsuite Parameters): Add GDBSERVER_DEBUG. (gdbserver,debug): Add board setting. * gdb.trace/tspeed.exp: Skip when debugging. * lib/gdb.exp (gdbserver_debug_enabled): New procedure. * lib/gdbserver-support.exp: Likewise --- gdb/testsuite/Makefile.in | 4 ++- gdb/testsuite/README | 19 +++++++++++++ gdb/testsuite/gdb.trace/tspeed.exp | 5 ++++ gdb/testsuite/lib/gdb.exp | 7 +++++ gdb/testsuite/lib/gdbserver-support.exp | 38 ++++++++++++++++++++++++- 5 files changed, 71 insertions(+), 2 deletions(-) -- 2.20.1 (Apple Git-117) diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in index 6625512d50..40225e3b91 100644 --- a/gdb/testsuite/Makefile.in +++ b/gdb/testsuite/Makefile.in @@ -53,6 +53,7 @@ RUNTESTFLAGS = FORCE_PARALLEL = GDB_DEBUG = +GDBSERVER_DEBUG = # Default number of iterations that we will use to run the testsuite # if the user does not specify the RACY_ITER environment variable @@ -165,6 +166,7 @@ check-read1: 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) @@ -172,7 +174,7 @@ DO_RUNTEST = \ rootme=`pwd`; export rootme; \ srcdir=${srcdir} ; export srcdir ; \ EXPECT=${EXPECT} ; export EXPECT ; \ - EXEEXT=${EXEEXT} ; export EXEEXT ; $(gdb_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 e17f218da8..43f35a9d4b 100644 --- a/gdb/testsuite/README +++ b/gdb/testsuite/README @@ -302,6 +302,17 @@ 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 +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: + + make check GDBSERVER_DEBUG=all + Race detection ************** @@ -513,6 +524,14 @@ 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 + output directory. Valid values are: + "debug" - turn on gdbserver debug. + "remote" - turn on gdbserver remote debug. + "all" - turn on all the above debug options. + Testsuite Organization ********************** diff --git a/gdb/testsuite/gdb.trace/tspeed.exp b/gdb/testsuite/gdb.trace/tspeed.exp index 6fd812e4f6..9afec64acf 100644 --- a/gdb/testsuite/gdb.trace/tspeed.exp +++ b/gdb/testsuite/gdb.trace/tspeed.exp @@ -19,6 +19,11 @@ if {[skip_shlib_tests]} { return 0 } +# Do not run if gdbsever debug is enabled - the output file is many Gb. +if [gdbserver_debug_enabled] { + return 0 +} + standard_testfile set executable $testfile diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 896cd80741..35d65d0e43 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -6410,5 +6410,12 @@ proc gdb_debug_init { } { gdb_test "set logging on" ".*" "Enable logging" } +# Check if debugging is enabled for gdbserver. + +proc gdbserver_debug_enabled { } { + # Always disabled for GDB only setups. + return 0 +} + # Always load compatibility stuff. load_lib future.exp diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index 2cb64f7d2f..164a1d1d3c 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -283,12 +283,26 @@ proc gdbserver_start { options arguments } { # If gdbserver_reconnect will be called $gdbserver_reconnect_p must be # set to true already during gdbserver_start. global gdbserver_reconnect_p + global srcdir + global subdir if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} { # GDB client could accidentally connect to a stale server. - # append gdbserver_command " --debug --once" append gdbserver_command " --once" } + # 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" + } + } + if { $options != "" } { append gdbserver_command " $options" } @@ -561,3 +575,25 @@ proc mi_gdbserver_start_multi { } { return [mi_gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] } + +# Check if debugging is enabled for gdbserver. + +proc gdbserver_debug_enabled { } { + global gdbserverdebug + + # If not already read, get the debug setting from environment or board setting. + if ![info exists gdbserverdebug] { + global env + if [info exists env(GDBSERVER_DEBUG)] { + set gdbserverdebug $env(GDBSERVER_DEBUG) + } elseif [target_info exists gdbserver,debug] { + set gdbserverdebug [target_info gdbserver,debug] + } else { + return 0 + } + } + + # Only return success on valid values. + return [expr { $gdbserverdebug == "debug" || $gdbserverdebug == "remote" + || $gdbserverdebug == "all" }] +}