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

Alan Hayward Alan.Hayward@arm.com
Tue Apr 16 10:17:00 GMT 2019


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

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"
 	}
-- 
2.20.1 (Apple Git-117)



More information about the Gdb-patches mailing list