[4/4] testsuite: Add option to capture gdbserver debug

Message ID 20190416101729.16176-5-alan.hayward@arm.com
State New, archived
Headers

Commit Message

Alan Hayward April 16, 2019, 10:17 a.m. UTC
  Add board option which enables gdbserver debug and sends it to the
file gdbserver.log, located in the output directory for the current
test.  Document this.

Add debug versions of the native gdbserver board files.

Disable tspeed.exp when debugging to prevent the log file filling
many gigabytes then timing out.

gdb/testsuite/ChangeLog:

2019-04-16  Alan Hayward  <alan.hayward@arm.com>

	* README (gdbserver,debug): Add board setting.
	* boards/native-extended-gdbserver-debug.exp: New file.
	* boards/native-gdbserver-debug.exp: New file.
	* gdb.trace/tspeed.exp: Skip when debugging.
	* lib/gdbserver-support.exp: Check for gdbserver,debug.
---
 gdb/testsuite/README                          |  8 ++++++
 .../native-extended-gdbserver-debug.exp       | 26 +++++++++++++++++++
 .../boards/native-gdbserver-debug.exp         | 25 ++++++++++++++++++
 gdb/testsuite/gdb.trace/tspeed.exp            |  5 ++++
 gdb/testsuite/lib/gdbserver-support.exp       | 16 +++++++++++-
 5 files changed, 79 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/boards/native-extended-gdbserver-debug.exp
 create mode 100644 gdb/testsuite/boards/native-gdbserver-debug.exp

-- 
2.20.1 (Apple Git-117)
  

Comments

Tom Tromey April 16, 2019, 7:49 p.m. UTC | #1
>>>>> "Alan" == Alan Hayward <Alan.Hayward@arm.com> writes:

Alan> Add board option which enables gdbserver debug and sends it to the
Alan> file gdbserver.log, located in the output directory for the current
Alan> test.  Document this.

Alan> Add debug versions of the native gdbserver board files.

Alan> Disable tspeed.exp when debugging to prevent the log file filling
Alan> many gigabytes then timing out.

Thanks.

Alan> +gdbserver,debug
Alan> +
Alan> +  When set gdbserver debug is outputed to the file gdbserver.log in the test

I think it should say "is sent" rather than "is outputed".

Alan> diff --git a/gdb/testsuite/boards/native-extended-gdbserver-debug.exp b/gdb/testsuite/boards/native-extended-gdbserver-debug.exp

I wonder if a new board is needed for this?
Could it be done some other way, like a command-line setting?

TBH I'm not sure what the typical approach is for something like this.

Alan>  	if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
Alan>  	    # GDB client could accidentally connect to a stale server.
Alan> -	    # append gdbserver_command " --debug --once"
Alan>  	    append gdbserver_command " --once"

Was this intentional?


One random thought I had about this series is that it would be nice to
have a way to get "set remotelogfile" output in the test directory.
That way a failing test could be re-run with gdbreplay without much
trouble.

Tom
  
Alan Hayward April 17, 2019, 3:43 p.m. UTC | #2
(Patches 1 to 3 pushed).

> On 16 Apr 2019, at 20:49, Tom Tromey <tom@tromey.com> wrote:

> 

>>>>>> "Alan" == Alan Hayward <Alan.Hayward@arm.com> writes:

> 

> Alan> Add board option which enables gdbserver debug and sends it to the

> Alan> file gdbserver.log, located in the output directory for the current

> Alan> test.  Document this.

> 

> Alan> Add debug versions of the native gdbserver board files.

> 

> Alan> Disable tspeed.exp when debugging to prevent the log file filling

> Alan> many gigabytes then timing out.

> 

> Thanks.

> 

> Alan> +gdbserver,debug

> Alan> +

> Alan> +  When set gdbserver debug is outputed to the file gdbserver.log in the test

> 

> I think it should say "is sent" rather than "is outputed”.


Done.

> Alan> diff --git a/gdb/testsuite/boards/native-extended-gdbserver-debug.exp b/gdb/testsuite/boards/native-extended-gdbserver-debug.exp

> 

> I wonder if a new board is needed for this?

> Could it be done some other way, like a command-line setting?


Agreed, it’s a little awkward. I’ve been playing round with an alternative
implementation and have added it an environment variable (in addition to the
board setting).

So, now you can do:
	make check GDBSERVER_DEBUG=all

Which is much nicer. However, see final comment.

> 

> TBH I'm not sure what the typical approach is for something like this.

> 

> Alan>  	if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {

> Alan>  	    # GDB client could accidentally connect to a stale server.

> Alan> -	    # append gdbserver_command " --debug --once"

> Alan>  	    append gdbserver_command " --once"

> 

> Was this intentional?


Yes, I removed this commented out line. I suspect it was there so that you could
quickly switch over to using "—debug". With my changes you shouldn’t need it.

> 

> 

> One random thought I had about this series is that it would be nice to

> have a way to get "set remotelogfile" output in the test directory.

> That way a failing test could be re-run with gdbreplay without much

> trouble.


Yes, I think it’d be possible using a similar approach.  You’d end up with another
environment variable, REPLAY_LOG=1 or something.  My only concern is that it’s
starting down the road of adding more environment vars to the make line - which
people might not want?


I’ll post the updated version as a V2 so that I can use git send-email.


Alan.
  

Patch

diff --git a/gdb/testsuite/README b/gdb/testsuite/README
index db90ea4698..01595d35aa 100644
--- a/gdb/testsuite/README
+++ b/gdb/testsuite/README
@@ -497,6 +497,14 @@  gdb,nopie_flag
   The flag required to force the compiler to produce non-position-independent
   executables.
 
+gdbserver,debug
+
+  When set gdbserver debug is outputed to the file gdbserver.log 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/boards/native-extended-gdbserver-debug.exp b/gdb/testsuite/boards/native-extended-gdbserver-debug.exp
new file mode 100644
index 0000000000..aa79416081
--- /dev/null
+++ b/gdb/testsuite/boards/native-extended-gdbserver-debug.exp
@@ -0,0 +1,26 @@ 
+# Copyright 2019 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is a dejagnu "board file" and is used to run the testsuite
+# natively with gdbserver, in extended-remote mode, with gdbserver debug
+# turned on.
+#
+# To use this file:
+# bash$ cd ${build_dir}/gdb
+# bash$ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver-debug"
+
+load_board_description "native-extended-gdbserver"
+
+set_board_info gdbserver,debug "all"
diff --git a/gdb/testsuite/boards/native-gdbserver-debug.exp b/gdb/testsuite/boards/native-gdbserver-debug.exp
new file mode 100644
index 0000000000..ffca2cb8d5
--- /dev/null
+++ b/gdb/testsuite/boards/native-gdbserver-debug.exp
@@ -0,0 +1,25 @@ 
+# Copyright 2019 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is a dejagnu "board file" and is used to run the testsuite
+# natively with gdbserver, with gdbserver debug turned on.
+#
+# To use this file:
+# bash$ cd ${build_dir}/gdb
+# bash$ make check RUNTESTFLAGS="--target_board=native-gdbserver-debug"
+
+load_board_description "native-gdbserver"
+
+set_board_info gdbserver,debug "all"
diff --git a/gdb/testsuite/gdb.trace/tspeed.exp b/gdb/testsuite/gdb.trace/tspeed.exp
index 6fd812e4f6..70a8e1f5b4 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 [target_info exists gdbserver,debug] {
+    return 0
+}
+
 standard_testfile
 set executable $testfile
 
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 2cb64f7d2f..745cf670b1 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"
 	}
 
+	# Set debug according to the board setting.
+	if [target_info exists gdbserver,debug] {
+	  set gdbserverdebug [target_info gdbserver,debug]
+	  set debugfile [standard_output_file gdbserver.log]
+	  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"
 	}