+2018-10-12  Sandra Loosemore  <sandra@codesourcery.com>
+
+       * gdb.trace/actions-changed.exp: Check for arch support.
+       * gdb.trace/actions.exp: Likewise.
+       * gdb.trace/ax.exp: Likewise.
+       * gdb.trace/backtrace.exp: Likewise.
+       * gdb.trace/change-loc.exp: Likewise.
+       * gdb.trace/deltrace.exp: Likewise.
+       * gdb.trace/ftrace-lock.exp: Check for shlib and arch support.
+       * gdb.trace/ftrace.exp: Likewise.
+       * gdb.trace/infotrace.exp: Check for arch support.
+       * gdb.trace/mi-trace-frame-collected.exp: Likewise.
+       * gdb.trace/mi-tracepoint-changed.exp: Likewise.
+       * gdb.trace/mi-tsv-changed.exp: Likewise.
+       * gdb.trace/packetlen.exp: Likewise.
+       * gdb.trace/passc-dyn.exp: Likewise.
+       * gdb.trace/passcount.exp: Likewise.
+       * gdb.trace/pending.exp: Likewise.
+       * gdb.trace/range-stepping.exp: Check for shlib support.
+       * gdb.trace/report.exp: Check for arch support.
+       * gdb.trace/save-trace.exp: Likewise.
+       * gdb.trace/signal.exp: Check for signal support.
+       * gdb.trace/tfind.exp: Check for arch support.
+       * gdb.trace/trace-break.exp: Check for arch and shlib support.
+       * gdb.trace/trace-common.h: Add comment.
+       * gdb.trace/trace-condition.exp: Check for shlib and arch support.
+       * gdb.trace/trace-enable-disable.exp: Likewise.
+       * gdb.trace/trace-mt.exp: Likewise.  Remove redundant untested call.
+       * gdb.trace/tracecmd.exp: Check for arch support.
+       * gdb.trace/tspeed.exp: Check for shlib and target support.
+       * gdb.trace/tstatus.exp: Check for arch support.
+       * gdb.trace/tsv.exp: Likewise.
+       * gdb.trace/while-dyn.exp: Likewise.
+       * gdb.trace/while-stepping.exp: Likewise.
+       * lib/trace-support.exp (gdb_trace_common_supports_arch): New.
+
 2018-10-12  Simon Marchi  <simon.marchi@ericsson.com>
 
        * gdb.trace/tspeed.exp: Remove nowarnings.
 
 
 standard_testfile
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
     return -1
 }
 
 gdb_start
 
 standard_testfile
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 gdb_exit
 gdb_start
 standard_testfile actions.c
+
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 set executable $testfile
 set expfile $testfile.exp
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if [prepare_for_testing "failed to prepare" $executable $srcfile \
        [list debug nowarnings]] {
     return -1
 
     return 0
 }
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 standard_testfile
 set libfile1 "change-loc-1"
 set libfile2 "change-loc-2"
 
 gdb_start
 
 standard_testfile actions.c
+
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 
 load_lib "trace-support.exp"
 
+if {[skip_shlib_tests]} {
+    return 0
+}
+
 standard_testfile
 set executable $testfile
 set expfile $testfile.exp
             additional_flags=-DNUM_THREADS=$NUM_THREADS]
 
 # Check that the target supports trace.
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
     untested "failed to compile"
     return -1
 
 
 load_lib "trace-support.exp"
 
+if {[skip_shlib_tests]} {
+    return 0
+}
+
 standard_testfile
 set executable $testfile
 set expfile $testfile.exp
 # Some targets have leading underscores on assembly symbols.
 set additional_flags [gdb_target_symbol_prefix_flags]
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if [prepare_for_testing "failed to prepare" $executable $srcfile \
        [list debug $additional_flags]] {
     return -1
 
 gdb_start
 
 standard_testfile actions.c
+
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 
 standard_testfile actions.c
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug}] } {
     return -1
 }
 
 if {[skip_shlib_tests]} {
     return 0
 }
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 
 standard_testfile pending.c
 set libfile1 "pendshr1"
 
 load_lib mi-support.exp
 
 standard_testfile actions.c
+
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 gdb_start
 
 standard_testfile actions.c
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 gdb_exit
 gdb_start
 standard_testfile actions.c
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 gdb_exit
 gdb_start
 standard_testfile actions.c
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
     return 0
 }
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 standard_testfile
 set libfile1 "pendshr1"
 set libfile2 "pendshr2"
 
 
 range_stepping_with_tracepoint "trace"
 
+if {[skip_shlib_tests]} {
+    return 0
+}
+
 set libipa [get_in_proc_agent]
 set remote_libipa [gdb_load_shlib $libipa]
 
 
 gdb_start
 
 standard_testfile actions.c
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 gdb_start
 
 standard_testfile actions.c
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 
 load_lib "trace-support.exp"
 
+if [target_info exists gdb,nosignals] {
+    verbose "Skipping signal.exp because of nosignals."
+    return -1
+}
+
 standard_testfile
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
 
 
 standard_testfile actions.c
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if { [gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 # Some targets have leading underscores on assembly symbols.
 set additional_flags [gdb_target_symbol_prefix_flags]
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if [prepare_for_testing "failed to prepare" $executable $srcfile \
        [list debug $additional_flags]] {
     return -1
 break_trace_same_addr_6 "trace" "enable" "trace" "disable"
 break_trace_same_addr_6 "trace" "disable" "trace" "enable"
 
+if {[skip_shlib_tests]} {
+    return 0
+}
+
 set libipa [get_in_proc_agent]
 set remote_libipa [gdb_load_shlib $libipa]
 
 
    a fast tracepoint jump.  The parameter is the label where we'll set
    tracepoints and breakpoints.  */
 
+/* Please keep gdb_trace_common_supports_arch in lib/trace-support.exp
+   in sync when adding new targets to this file.  */
+
 #if (defined __x86_64__ || defined __i386__)
 
 static void
 
 
 load_lib "trace-support.exp"
 
+if {[skip_shlib_tests]} {
+    return 0
+}
+
 standard_testfile
 set executable $testfile
 set expfile $testfile.exp
 # Some targets have leading underscores on assembly symbols.
 set additional_flags [gdb_target_symbol_prefix_flags]
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if [prepare_for_testing "failed to prepare" $executable $srcfile \
        [list debug $additional_flags]] {
     return -1
 
 
 load_lib "trace-support.exp"
 
+if {[skip_shlib_tests]} {
+    return 0
+}
+
 standard_testfile
 set executable $testfile
 set expfile $testfile.exp
 set options [list debug [gdb_target_symbol_prefix_flags]]
 
 # Check that the target supports trace.
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
     untested "failed to compile"
     return -1
 
 # Some targets have leading underscores on assembly symbols.
 set additional_flags [gdb_target_symbol_prefix_flags]
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
          executable [list debug $additional_flags] ] != "" } {
-    untested "failed to compile"
+    # gdb_compile_pthreads provides an appropriate unsupported message.
     return -1
 }
 
 
 step_over_tracepoint "trace"
 
+if {[skip_shlib_tests]} {
+    return 0
+}
+
 set libipa [get_in_proc_agent]
 set remote_libipa [gdb_load_shlib $libipa]
 
 
 gdb_exit
 gdb_start
 standard_testfile actions.c
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 
 load_lib "trace-support.exp"
 
+if {[skip_shlib_tests]} {
+    return 0
+}
+
 standard_testfile
 set executable $testfile
 
+# Check that the target supports trace.
+if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
+    untested "failed to compile"
+    return -1
+}
+
+clean_restart ${testfile}
+
+if ![runto_main] {
+    fail "can't run to main to check for trace support"
+    return -1
+}
+
+if ![gdb_target_supports_trace] {
+    unsupported "target does not support trace"
+    return -1
+}
+
+# Compile the test case with the in-process agent library.
 set ipalib [get_in_proc_agent]
 
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
 
 set executable $testfile
 set expfile tstatus.exp
 
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
+
 if [prepare_for_testing "failed to prepare" $executable $srcfile \
        [list debug]] {
     return -1
 
 gdb_exit
 gdb_start
 standard_testfile actions.c
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 
 standard_testfile actions.c
 set executable $testfile
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
 gdb_start
 
 standard_testfile actions.c
+if ![gdb_trace_common_supports_arch] {
+    unsupported "no trace-common.h support for arch"
+    return -1
+}
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" $binfile \
          executable {debug nowarnings}] != "" } {
     untested "failed to compile"
 
     set pcreg "pc"
 }
 
+#
+# Procedure: gdb_trace_common_supports_arch
+# Returns true if gdb.trace/trace-common.h knows about this target.
+# Allows skipping tests that depend on being able to include this file.
+# Please keep this in sync with the supported targets in the header.
+#
+
+proc gdb_trace_common_supports_arch { } {
+  if { [istarget "x86_64*-*-*"]
+       || [istarget "i386*-*-*"]
+       || [istarget "aarch64*-*-*"]
+       || [istarget "powerpc*-*-*"]
+       || [istarget "s390*-*-*"] } {
+       return 1
+    } else {
+       return 0
+    }
+}
+
 #
 # Procedure: gdb_target_supports_trace
 # Returns true if GDB is connected to a target that supports tracing.