[binutils-gdb] testsuite, trace: add guards if In-Process Agent library is not found

Stephan Rohr srohr@sourceware.org
Fri Sep 13 11:21:37 GMT 2024


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

commit a1371f3288f2d84cea90a9157ed9a359226969e2
Author: Stephan Rohr <stephan.rohr@intel.com>
Date:   Wed Feb 21 01:55:37 2024 -0800

    testsuite, trace: add guards if In-Process Agent library is not found
    
    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.

Diff:
---
 gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp     |  1 +
 gdb/testsuite/gdb.trace/basic-libipa.exp         |  6 +-----
 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 ++++++++++++++
 14 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp b/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
index 9549b597045..4ea86b4a395 100644
--- a/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
+++ b/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
@@ -33,6 +33,7 @@ if ![gdb_target_supports_trace] {
     return -1
 }
 
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 
 # Can't use prepare_for_testing, because that splits compiling into
diff --git a/gdb/testsuite/gdb.trace/basic-libipa.exp b/gdb/testsuite/gdb.trace/basic-libipa.exp
index e28f61e5f96..c49192a5c35 100644
--- a/gdb/testsuite/gdb.trace/basic-libipa.exp
+++ b/gdb/testsuite/gdb.trace/basic-libipa.exp
@@ -25,13 +25,9 @@ require allow_shlib_tests
 
 standard_testfile
 
+require allow_in_proc_agent
 set libipa [get_in_proc_agent]
 
-if { ![file exists $libipa] } {
-    unsupported "missing libinproctrace.so"
-    return -1
-}
-
 gdb_download_shlib $libipa
 
 if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
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 {} {


More information about the Gdb-cvs mailing list