[v2,1/1] testsuite, trace: add guards if In-Process Agent library is not found

Message ID 20240726085959.50099-2-stephan.rohr@intel.com
State New
Headers
Series testsuite, trace: add guards if In-Process Agent library is not found |

Checks

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

Commit Message

Stephan Rohr July 26, 2024, 8:59 a.m. UTC
  Several tests in gdb.trace trigger TCL errors if the In-Process Agent
library is not found, e.g.:

  Running gdb/testsuite/gdb.trace/change-loc.exp ...
  ERROR: tcl error sourcing gdb/testsuite/gdb.trace/change-loc.exp.
  ERROR: error copying "gdb/gdb/testsuite/../../gdbserver/libinproctrace.so":
	 no such file or directory
      while executing
  "file copy -force $fromfile $tofile"
      (procedure "gdb_remote_download" line 29)
      invoked from within
  "gdb_remote_download target $target_file"
      (procedure "gdb_download_shlib" line 6)
      invoked from within
  "gdb_download_shlib $file"
      (procedure "gdb_load_shlib" line 2)
      invoked from within
  "gdb_load_shlib $libipa"
      (file "gdb/testsuite/gdb.trace/change-loc.exp" line 354)
      invoked from within
  "source gdb/testsuite/gdb.trace/change-loc.exp"
      ("uplevel" body line 1)
      invoked from within
  "uplevel #0 source gdb/testsuite/gdb.trace/change-loc.exp"
      invoked from within
  "catch "uplevel #0 source $test_file_name""

Protect against this error by checking if the library is available.
---
 gdb/testsuite/gdb.trace/change-loc.exp           |  1 +
 gdb/testsuite/gdb.trace/ftrace-lock.exp          |  1 +
 gdb/testsuite/gdb.trace/ftrace.exp               |  1 +
 gdb/testsuite/gdb.trace/pending.exp              |  1 +
 gdb/testsuite/gdb.trace/range-stepping.exp       |  1 +
 gdb/testsuite/gdb.trace/strace.exp               |  1 +
 gdb/testsuite/gdb.trace/trace-break.exp          |  1 +
 gdb/testsuite/gdb.trace/trace-condition.exp      |  1 +
 gdb/testsuite/gdb.trace/trace-enable-disable.exp |  1 +
 gdb/testsuite/gdb.trace/trace-mt.exp             |  1 +
 gdb/testsuite/gdb.trace/tspeed.exp               |  1 +
 gdb/testsuite/lib/trace-support.exp              | 14 ++++++++++++++
 12 files changed, 25 insertions(+)
  

Comments

Andrew Burgess Sept. 4, 2024, 10:03 a.m. UTC | #1
Stephan Rohr <stephan.rohr@intel.com> writes:

> Several tests in gdb.trace trigger TCL errors if the In-Process Agent
> library is not found, e.g.:
>
>   Running gdb/testsuite/gdb.trace/change-loc.exp ...
>   ERROR: tcl error sourcing gdb/testsuite/gdb.trace/change-loc.exp.
>   ERROR: error copying "gdb/gdb/testsuite/../../gdbserver/libinproctrace.so":
> 	 no such file or directory
>       while executing
>   "file copy -force $fromfile $tofile"
>       (procedure "gdb_remote_download" line 29)
>       invoked from within
>   "gdb_remote_download target $target_file"
>       (procedure "gdb_download_shlib" line 6)
>       invoked from within
>   "gdb_download_shlib $file"
>       (procedure "gdb_load_shlib" line 2)
>       invoked from within
>   "gdb_load_shlib $libipa"
>       (file "gdb/testsuite/gdb.trace/change-loc.exp" line 354)
>       invoked from within
>   "source gdb/testsuite/gdb.trace/change-loc.exp"
>       ("uplevel" body line 1)
>       invoked from within
>   "uplevel #0 source gdb/testsuite/gdb.trace/change-loc.exp"
>       invoked from within
>   "catch "uplevel #0 source $test_file_name""
>
> Protect against this error by checking if the library is available.
> ---
>  gdb/testsuite/gdb.trace/change-loc.exp           |  1 +
>  gdb/testsuite/gdb.trace/ftrace-lock.exp          |  1 +
>  gdb/testsuite/gdb.trace/ftrace.exp               |  1 +
>  gdb/testsuite/gdb.trace/pending.exp              |  1 +
>  gdb/testsuite/gdb.trace/range-stepping.exp       |  1 +
>  gdb/testsuite/gdb.trace/strace.exp               |  1 +
>  gdb/testsuite/gdb.trace/trace-break.exp          |  1 +
>  gdb/testsuite/gdb.trace/trace-condition.exp      |  1 +
>  gdb/testsuite/gdb.trace/trace-enable-disable.exp |  1 +
>  gdb/testsuite/gdb.trace/trace-mt.exp             |  1 +
>  gdb/testsuite/gdb.trace/tspeed.exp               |  1 +
>  gdb/testsuite/lib/trace-support.exp              | 14 ++++++++++++++

I think you should add the check to gdb.arch/ftrace-insn-reloc.exp and
gdb.trace/basic-libipa.exp too.

In gdb.trace/basic-libipa.exp we have:

  set libipa [get_in_proc_agent]
  
  if { ![file exists $libipa] } {
      unsupported "missing libinproctrace.so"
      return -1
  }

I think you should drop the 'if' block here and replace it with an
earlier 'requires' check like you have in the other scripts.

I'm not sure why you're not hitting a failure with
ftrace-insn-reloc.exp, I guess one of the earlier checks is causing you
to bail out?  But I think you should still add the 'requires' check.

With those two changes made:

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew



>  12 files changed, 25 insertions(+)
>
> diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
> index fb55153bfcb..1316d92b116 100644
> --- a/gdb/testsuite/gdb.trace/change-loc.exp
> +++ b/gdb/testsuite/gdb.trace/change-loc.exp
> @@ -346,6 +346,7 @@ tracepoint_change_loc_2 "trace"
>  tracepoint_install_in_trace_disabled "trace"
>  
>  # Re-compile test case with IPA.
> +require allow_in_proc_agent
>  set libipa [get_in_proc_agent]
>  gdb_load_shlib $libipa
>  
> diff --git a/gdb/testsuite/gdb.trace/ftrace-lock.exp b/gdb/testsuite/gdb.trace/ftrace-lock.exp
> index ce2b890229a..637d5eb53bb 100644
> --- a/gdb/testsuite/gdb.trace/ftrace-lock.exp
> +++ b/gdb/testsuite/gdb.trace/ftrace-lock.exp
> @@ -48,6 +48,7 @@ with_test_prefix "runtime trace support check" {
>  }
>  
>  # Compile the test case with the in-process agent library.
> +require allow_in_proc_agent
>  set libipa [get_in_proc_agent]
>  set remote_libipa [gdb_load_shlib $libipa]
>  
> diff --git a/gdb/testsuite/gdb.trace/ftrace.exp b/gdb/testsuite/gdb.trace/ftrace.exp
> index 9b100ced8f5..408cd372bfa 100644
> --- a/gdb/testsuite/gdb.trace/ftrace.exp
> +++ b/gdb/testsuite/gdb.trace/ftrace.exp
> @@ -39,6 +39,7 @@ if ![gdb_target_supports_trace] {
>      return -1
>  }
>  
> +require allow_in_proc_agent
>  set libipa [get_in_proc_agent]
>  set remote_libipa [gdb_load_shlib $libipa]
>  
> diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp
> index b836be05533..66209adaec2 100644
> --- a/gdb/testsuite/gdb.trace/pending.exp
> +++ b/gdb/testsuite/gdb.trace/pending.exp
> @@ -494,6 +494,7 @@ pending_tracepoint_with_action_resolved "trace"
>  pending_tracepoint_installed_during_trace "trace"
>  
>  # Re-compile test case with IPA.
> +require allow_in_proc_agent
>  set libipa [get_in_proc_agent]
>  gdb_load_shlib $libipa
>  
> diff --git a/gdb/testsuite/gdb.trace/range-stepping.exp b/gdb/testsuite/gdb.trace/range-stepping.exp
> index e3af2e5c77c..373a0bf3463 100644
> --- a/gdb/testsuite/gdb.trace/range-stepping.exp
> +++ b/gdb/testsuite/gdb.trace/range-stepping.exp
> @@ -67,6 +67,7 @@ range_stepping_with_tracepoint "trace"
>  
>  require allow_shlib_tests
>  
> +require allow_in_proc_agent
>  set libipa [get_in_proc_agent]
>  set remote_libipa [gdb_load_shlib $libipa]
>  
> diff --git a/gdb/testsuite/gdb.trace/strace.exp b/gdb/testsuite/gdb.trace/strace.exp
> index 99b199ef5f1..ef243a4ef46 100644
> --- a/gdb/testsuite/gdb.trace/strace.exp
> +++ b/gdb/testsuite/gdb.trace/strace.exp
> @@ -19,6 +19,7 @@ require allow_shlib_tests
>  standard_testfile
>  set executable $testfile
>  
> +require allow_in_proc_agent
>  set libipa [get_in_proc_agent]
>  
>  set lib_opts debug
> diff --git a/gdb/testsuite/gdb.trace/trace-break.exp b/gdb/testsuite/gdb.trace/trace-break.exp
> index 7e5820cb0cf..cac4aa561c0 100644
> --- a/gdb/testsuite/gdb.trace/trace-break.exp
> +++ b/gdb/testsuite/gdb.trace/trace-break.exp
> @@ -344,6 +344,7 @@ break_trace_same_addr_6 "trace" "disable" "trace" "enable"
>  
>  require allow_shlib_tests
>  
> +require allow_in_proc_agent
>  set libipa [get_in_proc_agent]
>  set remote_libipa [gdb_load_shlib $libipa]
>  
> diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
> index 42453bc61c7..17acda87ecf 100644
> --- a/gdb/testsuite/gdb.trace/trace-condition.exp
> +++ b/gdb/testsuite/gdb.trace/trace-condition.exp
> @@ -39,6 +39,7 @@ if ![gdb_target_supports_trace] {
>      return -1
>  }
>  
> +require allow_in_proc_agent
>  set libipa [get_in_proc_agent]
>  set remote_libipa [gdb_load_shlib $libipa]
>  
> diff --git a/gdb/testsuite/gdb.trace/trace-enable-disable.exp b/gdb/testsuite/gdb.trace/trace-enable-disable.exp
> index 280f2e4501a..c2c838121df 100644
> --- a/gdb/testsuite/gdb.trace/trace-enable-disable.exp
> +++ b/gdb/testsuite/gdb.trace/trace-enable-disable.exp
> @@ -42,6 +42,7 @@ if ![gdb_target_supports_trace] {
>  }
>  
>  # Compile the test case with the in-process agent library.
> +require allow_in_proc_agent
>  set libipa [get_in_proc_agent]
>  gdb_load_shlib $libipa
>  
> diff --git a/gdb/testsuite/gdb.trace/trace-mt.exp b/gdb/testsuite/gdb.trace/trace-mt.exp
> index e56064bbe8b..7246ddc8a8e 100644
> --- a/gdb/testsuite/gdb.trace/trace-mt.exp
> +++ b/gdb/testsuite/gdb.trace/trace-mt.exp
> @@ -103,6 +103,7 @@ step_over_tracepoint $binfile "trace"
>  
>  require allow_shlib_tests
>  
> +require allow_in_proc_agent
>  set libipa [get_in_proc_agent]
>  set remote_libipa [gdb_load_shlib $libipa]
>  
> diff --git a/gdb/testsuite/gdb.trace/tspeed.exp b/gdb/testsuite/gdb.trace/tspeed.exp
> index 7ade5c2eedf..c74680b9818 100644
> --- a/gdb/testsuite/gdb.trace/tspeed.exp
> +++ b/gdb/testsuite/gdb.trace/tspeed.exp
> @@ -43,6 +43,7 @@ if ![gdb_target_supports_trace] {
>  }
>  
>  # Compile the test case with the in-process agent library.
> +require allow_in_proc_agent
>  set ipalib [get_in_proc_agent]
>  
>  if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
> diff --git a/gdb/testsuite/lib/trace-support.exp b/gdb/testsuite/lib/trace-support.exp
> index c9c9697e180..770a930eda7 100644
> --- a/gdb/testsuite/lib/trace-support.exp
> +++ b/gdb/testsuite/lib/trace-support.exp
> @@ -366,6 +366,20 @@ proc gdb_find_recursion_test_baseline { filename } {
>      return $baseline
>  }
>  
> +# Return 1 if the IPA library is available and 0 otherwise.
> +
> +proc allow_in_proc_agent {} {
> +    global objdir
> +
> +    if [target_info exists in_proc_agent] {
> +	return 1
> +    } elseif [file exists "$objdir/../../gdbserver/libinproctrace.so"] {
> +	return 1
> +    } else {
> +	return 0
> +    }
> +}
> +
>  # Return the location of the IPA library.
>  
>  proc get_in_proc_agent {} {
> -- 
> 2.34.1
>
> 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/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
index fb55153bfcb..1316d92b116 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -346,6 +346,7 @@  tracepoint_change_loc_2 "trace"
 tracepoint_install_in_trace_disabled "trace"
 
 # Re-compile test case with IPA.
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 gdb_load_shlib $libipa
 
diff --git a/gdb/testsuite/gdb.trace/ftrace-lock.exp b/gdb/testsuite/gdb.trace/ftrace-lock.exp
index ce2b890229a..637d5eb53bb 100644
--- a/gdb/testsuite/gdb.trace/ftrace-lock.exp
+++ b/gdb/testsuite/gdb.trace/ftrace-lock.exp
@@ -48,6 +48,7 @@  with_test_prefix "runtime trace support check" {
 }
 
 # Compile the test case with the in-process agent library.
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 set remote_libipa [gdb_load_shlib $libipa]
 
diff --git a/gdb/testsuite/gdb.trace/ftrace.exp b/gdb/testsuite/gdb.trace/ftrace.exp
index 9b100ced8f5..408cd372bfa 100644
--- a/gdb/testsuite/gdb.trace/ftrace.exp
+++ b/gdb/testsuite/gdb.trace/ftrace.exp
@@ -39,6 +39,7 @@  if ![gdb_target_supports_trace] {
     return -1
 }
 
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 set remote_libipa [gdb_load_shlib $libipa]
 
diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp
index b836be05533..66209adaec2 100644
--- a/gdb/testsuite/gdb.trace/pending.exp
+++ b/gdb/testsuite/gdb.trace/pending.exp
@@ -494,6 +494,7 @@  pending_tracepoint_with_action_resolved "trace"
 pending_tracepoint_installed_during_trace "trace"
 
 # Re-compile test case with IPA.
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 gdb_load_shlib $libipa
 
diff --git a/gdb/testsuite/gdb.trace/range-stepping.exp b/gdb/testsuite/gdb.trace/range-stepping.exp
index e3af2e5c77c..373a0bf3463 100644
--- a/gdb/testsuite/gdb.trace/range-stepping.exp
+++ b/gdb/testsuite/gdb.trace/range-stepping.exp
@@ -67,6 +67,7 @@  range_stepping_with_tracepoint "trace"
 
 require allow_shlib_tests
 
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 set remote_libipa [gdb_load_shlib $libipa]
 
diff --git a/gdb/testsuite/gdb.trace/strace.exp b/gdb/testsuite/gdb.trace/strace.exp
index 99b199ef5f1..ef243a4ef46 100644
--- a/gdb/testsuite/gdb.trace/strace.exp
+++ b/gdb/testsuite/gdb.trace/strace.exp
@@ -19,6 +19,7 @@  require allow_shlib_tests
 standard_testfile
 set executable $testfile
 
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 
 set lib_opts debug
diff --git a/gdb/testsuite/gdb.trace/trace-break.exp b/gdb/testsuite/gdb.trace/trace-break.exp
index 7e5820cb0cf..cac4aa561c0 100644
--- a/gdb/testsuite/gdb.trace/trace-break.exp
+++ b/gdb/testsuite/gdb.trace/trace-break.exp
@@ -344,6 +344,7 @@  break_trace_same_addr_6 "trace" "disable" "trace" "enable"
 
 require allow_shlib_tests
 
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 set remote_libipa [gdb_load_shlib $libipa]
 
diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
index 42453bc61c7..17acda87ecf 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -39,6 +39,7 @@  if ![gdb_target_supports_trace] {
     return -1
 }
 
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 set remote_libipa [gdb_load_shlib $libipa]
 
diff --git a/gdb/testsuite/gdb.trace/trace-enable-disable.exp b/gdb/testsuite/gdb.trace/trace-enable-disable.exp
index 280f2e4501a..c2c838121df 100644
--- a/gdb/testsuite/gdb.trace/trace-enable-disable.exp
+++ b/gdb/testsuite/gdb.trace/trace-enable-disable.exp
@@ -42,6 +42,7 @@  if ![gdb_target_supports_trace] {
 }
 
 # Compile the test case with the in-process agent library.
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 gdb_load_shlib $libipa
 
diff --git a/gdb/testsuite/gdb.trace/trace-mt.exp b/gdb/testsuite/gdb.trace/trace-mt.exp
index e56064bbe8b..7246ddc8a8e 100644
--- a/gdb/testsuite/gdb.trace/trace-mt.exp
+++ b/gdb/testsuite/gdb.trace/trace-mt.exp
@@ -103,6 +103,7 @@  step_over_tracepoint $binfile "trace"
 
 require allow_shlib_tests
 
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 set remote_libipa [gdb_load_shlib $libipa]
 
diff --git a/gdb/testsuite/gdb.trace/tspeed.exp b/gdb/testsuite/gdb.trace/tspeed.exp
index 7ade5c2eedf..c74680b9818 100644
--- a/gdb/testsuite/gdb.trace/tspeed.exp
+++ b/gdb/testsuite/gdb.trace/tspeed.exp
@@ -43,6 +43,7 @@  if ![gdb_target_supports_trace] {
 }
 
 # Compile the test case with the in-process agent library.
+require allow_in_proc_agent
 set ipalib [get_in_proc_agent]
 
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
diff --git a/gdb/testsuite/lib/trace-support.exp b/gdb/testsuite/lib/trace-support.exp
index c9c9697e180..770a930eda7 100644
--- a/gdb/testsuite/lib/trace-support.exp
+++ b/gdb/testsuite/lib/trace-support.exp
@@ -366,6 +366,20 @@  proc gdb_find_recursion_test_baseline { filename } {
     return $baseline
 }
 
+# Return 1 if the IPA library is available and 0 otherwise.
+
+proc allow_in_proc_agent {} {
+    global objdir
+
+    if [target_info exists in_proc_agent] {
+	return 1
+    } elseif [file exists "$objdir/../../gdbserver/libinproctrace.so"] {
+	return 1
+    } else {
+	return 0
+    }
+}
+
 # Return the location of the IPA library.
 
 proc get_in_proc_agent {} {