[1/1] testsuite: adapt to new --debug command line option

Message ID 20250102115147.4159173-1-christina.schimpe@intel.com
State New
Headers
Series [1/1] testsuite: adapt to new --debug command line option |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed

Commit Message

Schimpe, Christina Jan. 2, 2025, 11:51 a.m. UTC
  Since commit "gdbserver: allow the --debug command line option to take a
value", gdbserver no longer supports
  --debug
  --remote-debug
  --event-loop-debug.

Instead, --debug now takes a comma separated list of components.

The make check parameter GDBSERVER_DEBUG doesn't support these changes
yet.  This patch fixes this, by adding the --debug gdbserver arguments,
as "debug-threads", "debug-remote", "debug-event-loop" or "debug-all" for
GDBSERVER_DEBUG.  Replay logging is still enabled by adding the
"replay" GDBSERVER_DEBUG argument.  We can also configure "all" to
enable all of the available options.

Now, for instance, we can use it as follows:

make check GDBSERVER_DEBUG="debug-remote,debug-event-loop,replay" RUNTESTFLAGS="--target_board=native-gdbserver" TESTS="gdb.trace/ftrace.exp"

or simply

make check GDBSERVER_DEBUG="all" RUNTESTFLAGS="--target_board=native-gdbserver" TESTS="gdb.trace/ftrace.exp"

to enable all debug options.
---
 gdb/testsuite/README                    | 24 +++++++++++++++-----
 gdb/testsuite/lib/gdbserver-support.exp | 29 ++++++++++++++++---------
 2 files changed, 38 insertions(+), 15 deletions(-)
  

Comments

Tom Tromey Jan. 6, 2025, 3:13 p.m. UTC | #1
>>>>> Christina Schimpe <christina.schimpe@intel.com> writes:

> Since commit "gdbserver: allow the --debug command line option to take a
> value", gdbserver no longer supports
>   --debug
>   --remote-debug
>   --event-loop-debug.

Thank you.  This looks good to me.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  
Schimpe, Christina Jan. 7, 2025, 2:11 p.m. UTC | #2
> -----Original Message-----
> From: Tom Tromey <tom@tromey.com>
> Sent: Monday, January 6, 2025 4:13 PM
> To: Schimpe, Christina <christina.schimpe@intel.com>
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH 1/1] testsuite: adapt to new --debug command line option
> 
> >>>>> Christina Schimpe <christina.schimpe@intel.com> writes:
> 
> > Since commit "gdbserver: allow the --debug command line option to take
> > a value", gdbserver no longer supports
> >   --debug
> >   --remote-debug
> >   --event-loop-debug.
> 
> Thank you.  This looks good to me.
> Approved-By: Tom Tromey <tom@tromey.com>
> 
> Tom

Thanks for the review. I've pushed this patch now.

Christina
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  

Patch

diff --git a/gdb/testsuite/README b/gdb/testsuite/README
index 06664d723e7..c5d42982004 100644
--- a/gdb/testsuite/README
+++ b/gdb/testsuite/README
@@ -319,14 +319,28 @@  GDBSERVER_DEBUG
 
 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.
+	debug-all - write gdbserver debug for threads remote and event-loop.
+	debug-threads - write gdbserver threads debug to gdbserver.debug.
+	debug-remote - write gdbserver remote debug to gdbserver.debug.
+	debug-event-loop - write gdbserver event-loog 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:
+Alternatively, it can be set to "all" to turn on all the above, e.g.:
 
-	make check GDBSERVER_DEBUG="debug,replay"
+	make check GDBSERVER_DEBUG="all"
+
+To turn on all --debug gdbserver parameter options but without replay logging,
+use the following:
+
+	make check GDBSERVER_DEBUG="debug-all"
+
+To turn on gdbserver debugging for all remote debug and replay logging,
+you can do:
+
+	make check GDBSERVER_DEBUG="debug-remote, replay"
+
+Note that the GDBSERVER_DEBUG options are not equivalent to the gdbserver
+parameter options of "--debug", as also the replay logging is supported.
 
 GDB_TARGET_USERNAME
 GDB_HOST_USERNAME
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 41ad5e6cbfb..346c9b93951 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -367,12 +367,26 @@  proc gdbserver_start { options arguments } {
 	    set enabled 0
 	    foreach entry [split $gdbserverdebug ,] {
 	      switch -- $entry {
-		"debug" {
-		  append gdbserver_command " --debug"
+		"debug-all" {
+		  append gdbserver_command " --debug=all"
 		  set enabled 1
 		}
-		"remote" {
-		  append gdbserver_command " --remote-debug"
+		"all" {
+		  # Different from the debug-all option, all argument sets
+		  # the replay log file.  See gdb_debug_init.
+		  append gdbserver_command " --debug=all"
+		  set enabled 1
+		}
+		"debug-threads" {
+		  append gdbserver_command " --debug=threads"
+		  set enabled 1
+		}
+		"debug-remote" {
+		  append gdbserver_command " --debug=remote"
+		  set enabled 1
+		}
+		"debug-event-loop" {
+		  append gdbserver_command " --debug=event-loop"
 		  set enabled 1
 		}
 	      }
@@ -707,11 +721,6 @@  proc gdbserver_debug_enabled { } {
 	}
     }
 
-    # Expand the all option
-    if { $gdbserverdebug == "all" } {
-      set gdbserverdebug "debug,remote,replay"
-    }
-
     # Ensure it is not empty.
     return [expr { $gdbserverdebug != "" }]
 }
@@ -736,7 +745,7 @@  proc gdb_debug_init { } {
 
     if [gdbserver_debug_enabled] {
       foreach entry [split $gdbserverdebug ,] {
-	if { $entry == "replay" } {
+	if { $entry == "replay" || $entry == "all"} {
 	  set replayfile [standard_output_file_with_gdb_instance gdbserver.replay]
           send_gdb "set remotelogfile $replayfile\n" optional
 	  gdb_expect 10 {