[PATCH V2 3/5] Improve tests to allow for targets that support trace but not ftrace

Antoine Tremblay
2016-11-03T14:33:28Z

This patch is in preparation for ARM tracepoints support in GDBServer.
Previously targets that supported tracing also supported fast tracing and
the tests could be somewhat merged without issue. With the introduction of
ARM tracepoints, without fast tracepoints support this changes.

This patch enables the trace tests to be run even if the
target does not support fast tracepoints.

gdb/testsuite/ChangeLog:

* gdb.trace/change-loc.exp: Catch non existing IPA lib case and
set the test to untested.
* gdb.trace/ftrace-lock.exp: Likewise.
* gdb.trace/ftrace.exp: Likewise.
* gdb.trace/pending.exp: Likewise.
* gdb.trace/range-stepping.exp: Likewise.
* gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-condition.exp: Move ftrace tests after testing
for the IPA availability.
(test_trace_command): New function.
* gdb.trace/trace-enable-disable.exp: Move ftrace tests after
testing for the IPA availability.
* gdb.trace/trace-mt.exp (foreach): Catch non existing IPA lib case and
set the test to untested.
---
gdb/testsuite/gdb.trace/change-loc.exp | 5 +-
gdb/testsuite/gdb.trace/ftrace-lock.exp | 6 ++-
gdb/testsuite/gdb.trace/ftrace.exp | 6 ++-
gdb/testsuite/gdb.trace/pending.exp | 5 +-
gdb/testsuite/gdb.trace/range-stepping.exp | 6 ++-
gdb/testsuite/gdb.trace/trace-break.exp | 6 ++-
gdb/testsuite/gdb.trace/trace-condition.exp | 64 ++++++++++++++----------
gdb/testsuite/gdb.trace/trace-enable-disable.exp | 27 ++++++----
gdb/testsuite/gdb.trace/trace-mt.exp | 5 +-
9 files changed, 86 insertions(+), 44 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
index 9fef3f0..1cd5ce7 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -354,7 +354,10 @@ tracepoint_install_in_trace_disabled "trace"

# Re-compile test case with IPA.
set libipa [get_in_proc_agent]
-gdb_load_shlib $libipa
+if { [catch {gdb_load_shlib $libipa}] } {
+ untested "Failed to load $libipa"
+ return -1
+}

if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \
[list debug nowarnings shlib=$libipa shlib=$lib_sl1 shlib_load] ] != "" } {
diff --git a/gdb/testsuite/gdb.trace/ftrace-lock.exp b/gdb/testsuite/gdb.trace/ftrace-lock.exp
index 0b12c8d..179cd0e 100644
--- a/gdb/testsuite/gdb.trace/ftrace-lock.exp
+++ b/gdb/testsuite/gdb.trace/ftrace-lock.exp
@@ -48,7 +48,11 @@ if ![gdb_target_supports_trace] {

# Compile the test case with the in-process agent library.
set libipa [get_in_proc_agent]
-set remote_libipa [gdb_load_shlib $libipa]
+
+if { [catch {gdb_load_shlib $libipa} remote_libipa] } {
+ untested "Failed to load $libipa"
+ return -1
+}

lappend options shlib=$libipa

diff --git a/gdb/testsuite/gdb.trace/ftrace.exp b/gdb/testsuite/gdb.trace/ftrace.exp
index e90485c..8cb0ac6 100644
--- a/gdb/testsuite/gdb.trace/ftrace.exp
+++ b/gdb/testsuite/gdb.trace/ftrace.exp
@@ -38,7 +38,11 @@ if ![gdb_target_supports_trace] {
}

set libipa [get_in_proc_agent]
-set remote_libipa [gdb_load_shlib $libipa]
+
+if { [catch {gdb_load_shlib $libipa} remote_libipa] } {
+ untested "Failed to load $libipa"
+ return -1
+}

# Can't use prepare_for_testing, because that splits compiling into
# building objects and then linking, and we'd fail with "linker input
diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp
index f7905fb..1ba0eec 100644
--- a/gdb/testsuite/gdb.trace/pending.exp
+++ b/gdb/testsuite/gdb.trace/pending.exp
@@ -503,7 +503,10 @@ pending_tracepoint_installed_during_trace "trace"

# Re-compile test case with IPA.
set libipa [get_in_proc_agent]
-gdb_load_shlib $libipa
+if { [catch gdb_load_shlib $libipa] } {
+ untested "Failed to load $libipa"
+ return -1
+}

lappend exec_opts "shlib=$libipa"

diff --git a/gdb/testsuite/gdb.trace/range-stepping.exp b/gdb/testsuite/gdb.trace/range-stepping.exp
index ba8c3d2..a606bd4 100644
--- a/gdb/testsuite/gdb.trace/range-stepping.exp
+++ b/gdb/testsuite/gdb.trace/range-stepping.exp
@@ -67,7 +67,11 @@ proc range_stepping_with_tracepoint { type } {
range_stepping_with_tracepoint "trace"

set libipa [get_in_proc_agent]
-set remote_libipa [gdb_load_shlib $libipa]
+
+if { [catch {gdb_load_shlib $libipa} remote_libipa] } {
+ untested "Failed to load $libipa"
+ return -1
+}

if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
executable [list debug nowarnings shlib=$libipa] ] != "" } {
diff --git a/gdb/testsuite/gdb.trace/trace-break.exp b/gdb/testsuite/gdb.trace/trace-break.exp
index a90d02d..9756d38 100644
--- a/gdb/testsuite/gdb.trace/trace-break.exp
+++ b/gdb/testsuite/gdb.trace/trace-break.exp
@@ -349,7 +349,11 @@ break_trace_same_addr_6 "trace" "enable" "trace" "disable"
break_trace_same_addr_6 "trace" "disable" "trace" "enable"

set libipa [get_in_proc_agent]
-set remote_libipa [gdb_load_shlib $libipa]
+
+if { [catch {gdb_load_shlib $libipa} remote_libipa] } {
+ untested "Failed to load $libipa"
+ return -1
+}

# Can't use prepare_for_testing, because that splits compiling into
# building objects and then linking, and we'd fail with "linker input
diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
index e36dba4..b5f5798 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -37,31 +37,6 @@ if ![gdb_target_supports_trace] {
return -1
}

-set libipa [get_in_proc_agent]
-set remote_libipa [gdb_load_shlib $libipa]
-
-# Can't use prepare_for_testing, because that splits compiling into
-# building objects and then linking, and we'd fail with "linker input
-# file unused because linking not done" when building the object.
-
-if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
- executable [list debug $additional_flags shlib=$libipa] ] != "" } {
- untested "failed to compile ftrace tests"
- return -1
-}
-
-clean_restart ${executable}
-
-if ![runto_main] {
- fail "Can't run to main for ftrace tests"
- return 0
-}
-
-if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
- untested "Could not find IPA lib loaded"
- return 1
-}
-
proc test_tracepoints { trace_command condition num_frames { kfail_proc 0 } } {
global executable gdb_prompt

@@ -126,7 +101,10 @@ proc 18955_i386_failure { trace_command } {
}
}

-foreach trace_command { "trace" "ftrace" } {
+proc test_trace_command { trace_command } {
+
+ global pcreg
+
# This condition is always true as the PC should be set to the tracepoint
# address when hit.
test_tracepoints $trace_command "\$$pcreg == *set_point" 10
@@ -303,3 +281,37 @@ foreach trace_command { "trace" "ftrace" } {
test_tracepoints $trace_command "(0x0aaaaaaaaaaaaaaa > 0x09999999bbbbbbbb ? 1 : 0) == 1" 10
test_tracepoints $trace_command "(0x00088888ccaaaaaa > 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
}
+
+
+test_trace_command "trace"
+
+set libipa [get_in_proc_agent]
+
+if { [catch {gdb_load_shlib $libipa} remote_libipa] } {
+ untested "Failed to load $libipa"
+ return -1
+}
+
+# Can't use prepare_for_testing, because that splits compiling into
+# building objects and then linking, and we'd fail with "linker input
+# file unused because linking not done" when building the object.
+
+if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
+ executable [list debug $additional_flags shlib=$libipa] ] != "" } {
+ untested "failed to compile ftrace tests"
+ return -1
+}
+
+clean_restart ${executable}
+
+if ![runto_main] {
+ fail "Can't run to main for ftrace tests"
+ return 0
+}
+
+if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
+ untested "Could not find IPA lib loaded"
+ return 1
+}
+
+test_trace_command "ftrace"
diff --git a/gdb/testsuite/gdb.trace/trace-enable-disable.exp b/gdb/testsuite/gdb.trace/trace-enable-disable.exp
index 0c35c92..c3d1b7b 100644
--- a/gdb/testsuite/gdb.trace/trace-enable-disable.exp
+++ b/gdb/testsuite/gdb.trace/trace-enable-disable.exp
@@ -39,17 +39,6 @@ if ![gdb_target_supports_trace] {
return -1
}

-# Compile the test case with the in-process agent library.
-set libipa [get_in_proc_agent]
-gdb_load_shlib $libipa
-
-lappend options shlib=$libipa
-
-if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
- untested "Couldn't compile test program with in-process agent library"
- return -1
-}
-
# This test makes sure that disabling and enabling tracepoints works
# correctly. TRACEPOINT_CMD is the command used to set tracepoints
# (e.g. trace or ftrace).
@@ -125,4 +114,20 @@ proc test_tracepoint_enable_disable { tracepoint_cmd } {
}

test_tracepoint_enable_disable trace
+
+# Compile the test case with the in-process agent library.
+set libipa [get_in_proc_agent]
+
+if { [catch {gdb_load_shlib $libipa}] } {
+ untested "Failed to load $libipa"
+ return -1
+}
+
+lappend options shlib=$libipa
+
+if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
+ untested "Couldn't compile test program with in-process agent library"
+ return -1
+}
+
test_tracepoint_enable_disable ftrace
diff --git a/gdb/testsuite/gdb.trace/trace-mt.exp b/gdb/testsuite/gdb.trace/trace-mt.exp
index b580344..15f6c63 100644
--- a/gdb/testsuite/gdb.trace/trace-mt.exp
+++ b/gdb/testsuite/gdb.trace/trace-mt.exp
@@ -107,7 +107,10 @@ foreach break_always_inserted { "on" "off" } {
step_over_tracepoint "trace"

set libipa [get_in_proc_agent]
-set remote_libipa [gdb_load_shlib $libipa]
+if { [catch {gdb_load_shlib $libipa} remote_libipa] } {
+ untested "Failed to load $libipa"
+ return -1
+}

# Compile test case again with IPA.
if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
--
2.9.2