public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] testsuite: Add replay logging to GDBSERVER_DEBUG
@ 2019-05-17 15:46 Alan Hayward
  0 siblings, 0 replies; only message in thread
From: Alan Hayward @ 2019-05-17 15:46 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b420b89e4b321ff31f2e76cac499b908f042069b

commit b420b89e4b321ff31f2e76cac499b908f042069b
Author: Alan Hayward <alan.hayward@arm.com>
Date:   Tue Apr 30 16:00:29 2019 +0100

    testsuite: Add replay logging to GDBSERVER_DEBUG
    
    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.
    
    gdb/testsuite/ChangeLog:
    
            * 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.

Diff:
---
 gdb/testsuite/ChangeLog                 |  9 +++++
 gdb/testsuite/README                    | 21 ++++++------
 gdb/testsuite/lib/gdbserver-support.exp | 59 +++++++++++++++++++++++++++------
 3 files changed, 68 insertions(+), 21 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 057c71b..601aa4a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,14 @@
 2019-05-17  Alan Hayward  <alan.hayward@arm.com>
 
+	* 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.
+
+2019-05-17  Alan Hayward  <alan.hayward@arm.com>
+
 	* lib/gdb.exp (default_gdb_spawn): Call gdb_write_cmd_file.
 	(gdb_write_cmd_file): New procedure.
 	* lib/gdbserver-support.exp (gdbserver_start): Call
diff --git a/gdb/testsuite/README b/gdb/testsuite/README
index 43f35a9..98fc8d1 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 54aa557..2ccc717 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
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-17 15:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 15:46 [binutils-gdb] testsuite: Add replay logging to GDBSERVER_DEBUG Alan Hayward

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).