diff mbox

Improve trace and ftrace condition testing

Message ID 1461941980-16462-1-git-send-email-antoine.tremblay@ericsson.com
State New
Headers show

Commit Message

Antoine Tremblay April 29, 2016, 2:59 p.m. UTC
This patch improves the trace and ftrace condition testing so that:

- Almost all ftrace emit operations are tested (missing emit_gt_goto,
emit_lt_goto, emit_pop, I could not figure out the condition for those).
- Conditions are tested with 32 and 64 bits integers, signed and unsigned
where relevant.
- Conditions are tested with 8 to 64 bits variables where relevant (emit_ref).

It also merges all trace conditions testing from ftrace.exp in
trace-condition.exp.

gdb/testsuite/ChangeLog:

	* gdb.trace/ftrace.exp (test_ftrace_condition): Remove.
	Remove condition tests.
	* gdb.trace/trace-condition.c (marker): Adapt signature to 8 to 64
	bits types.
	(main): Adapt to 8 to 64 bits types.
	* gdb.trace/trace-condition.exp: Add new tests.
---
 gdb/testsuite/gdb.trace/ftrace.exp          | 74 -----------------------------
 gdb/testsuite/gdb.trace/trace-condition.c   |  8 ++--
 gdb/testsuite/gdb.trace/trace-condition.exp | 68 +++++++++++++++++++++++++-
 3 files changed, 71 insertions(+), 79 deletions(-)

Comments

Yao Qi May 4, 2016, 4:49 p.m. UTC | #1
Antoine Tremblay <antoine.tremblay@ericsson.com> writes:

Hi Antoine,

> This patch improves the trace and ftrace condition testing so that:
>
> - Almost all ftrace emit operations are tested (missing emit_gt_goto,
> emit_lt_goto, emit_pop, I could not figure out the condition for those).
> - Conditions are tested with 32 and 64 bits integers, signed and unsigned
> where relevant.
> - Conditions are tested with 8 to 64 bits variables where relevant (emit_ref).
>
> It also merges all trace conditions testing from ftrace.exp in
> trace-condition.exp.

I go through your patch, and I think it's better to split your patch,
because your single patch include too much changes, which are
independent to each other.
Antoine Tremblay May 9, 2016, 11:07 a.m. UTC | #2
Yao Qi writes:

> Antoine Tremblay <antoine.tremblay@ericsson.com> writes:
>
> Hi Antoine,
>
>> This patch improves the trace and ftrace condition testing so that:
>>
>> - Almost all ftrace emit operations are tested (missing emit_gt_goto,
>> emit_lt_goto, emit_pop, I could not figure out the condition for those).
>> - Conditions are tested with 32 and 64 bits integers, signed and unsigned
>> where relevant.
>> - Conditions are tested with 8 to 64 bits variables where relevant (emit_ref).
>>
>> It also merges all trace conditions testing from ftrace.exp in
>> trace-condition.exp.
>
> I go through your patch, and I think it's better to split your patch,
> because your single patch include too much changes, which are
> independent to each other.

OK will do, thanks.

Antoine
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.trace/ftrace.exp b/gdb/testsuite/gdb.trace/ftrace.exp
index f770bf7..e90485c 100644
--- a/gdb/testsuite/gdb.trace/ftrace.exp
+++ b/gdb/testsuite/gdb.trace/ftrace.exp
@@ -174,43 +174,6 @@  proc test_fast_tracepoints {} {
     }
 }
 
-# Test compiled-condition
-# CONDEXP is the condition expression to be compiled.
-# VAR is the variable to be collected for testing.
-# LIST is a list of expected values of VAR should be collected
-# based on the CONDEXP.
-proc test_ftrace_condition { condexp var list } \
-{ with_test_prefix "cond $condexp" \
-{
-    global executable
-    global hex
-
-    clean_restart ${executable}
-    if ![runto_main] {
-	fail "Can't run to main to check for trace support"
-	return -1
-    }
-
-    gdb_test "break end" ".*" ""
-    gdb_test "tvariable \$tsv = 0"
-    gdb_test "ftrace set_point if $condexp" "Fast tracepoint .*"
-    gdb_trace_setactions "set action for tracepoint .*" "" \
-	"collect $var" "^$"
-
-    gdb_test_no_output "tstart" ""
-    gdb_test "continue" \
-	"Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" ""
-    gdb_test_no_output "tstop" ""
-
-    set i 0
-    foreach expval $list {
-	gdb_test "tfind" "Found trace frame $i, tracepoint .*" "tfind frame $i"
-	gdb_test "print $var" "\\$\[0-9\]+ = $expval\[\r\n\]" "expect $expval"
-	set i [expr $i + 1]
-    }
-    gdb_test "tfind" "Target failed to find requested trace frame\."
-}}
-
 gdb_reinitialize_dir $srcdir/$subdir
 
 if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
@@ -219,40 +182,3 @@  if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 }
 }
 
 test_fast_tracepoints
-
-# Test conditional goto and simple expression.
-test_ftrace_condition "globvar > 7" "globvar" { 8 9 10 }
-test_ftrace_condition "globvar < 4" "globvar" { 1 2 3 }
-test_ftrace_condition "globvar >= 7" "globvar" { 7 8 9 10 }
-test_ftrace_condition "globvar <= 4" "globvar" { 1 2 3 4 }
-test_ftrace_condition "globvar == 5" "globvar" { 5 }
-test_ftrace_condition "globvar != 5" "globvar" { 1 2 3 4 6 7 8 9 10 }
-test_ftrace_condition "globvar > 3 && globvar < 7" "globvar" { 4 5 6 }
-test_ftrace_condition "globvar < 3 || globvar > 7" "globvar" { 1 2 8 9 10 }
-test_ftrace_condition "(globvar << 2) + 1 == 29" "globvar" { 7 }
-test_ftrace_condition "(globvar >> 2) == 2" "globvar" { 8 9 10 }
-
-# Test emit_call by accessing trace state variables.
-test_ftrace_condition "(\$tsv = \$tsv + 2) > 10" "globvar" { 6 7 8 9 10 }
-
-# This expression is used for testing emit_reg.
-if [is_amd64_regs_target] {
-    set arg0exp "\$rdi"
-} elseif [is_x86_like_target] {
-    set arg0exp "*(int *) (\$ebp + 8)"
-} elseif { [istarget "aarch64*-*-*"] } {
-    set arg0exp "\$x0"
-} elseif [istarget "powerpc*-*-*"] {
-    set arg0exp "\$r3"
-} elseif { [istarget "s390x-*-*"] } {
-    set arg0exp "\$r2"
-} elseif { [istarget "s390-*-*"] } {
-    # On targets with 64-bit GPRs, avoid the high part.
-    set arg0exp "(\$r2 & 0xffffffff)"
-} else {
-    set arg0exp ""
-}
-
-if { "$arg0exp" != "" } {
-    test_ftrace_condition "($arg0exp > 500)" "globvar" { 6 7 8 9 10 }
-}
diff --git a/gdb/testsuite/gdb.trace/trace-condition.c b/gdb/testsuite/gdb.trace/trace-condition.c
index 94bb30c..f0b1863 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.c
+++ b/gdb/testsuite/gdb.trace/trace-condition.c
@@ -16,8 +16,9 @@ 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "trace-common.h"
+#include <inttypes.h>
 
-int globvar;
+int64_t globvar;
 
 static void
 begin (void)
@@ -25,7 +26,7 @@  begin (void)
 }
 
 static void
-marker (int anarg)
+marker (int8_t arg8, int16_t arg16, int32_t arg32, int64_t arg64)
 {
   FAST_TRACEPOINT_LABEL(set_point);
 }
@@ -41,7 +42,8 @@  main ()
   begin ();
 
   for (globvar = 1; globvar < 11; ++globvar)
-    marker (globvar * 100);
+    marker (globvar, globvar + (1 << 8), globvar + (1 << 16),
+	    globvar + (1LL << 32));
 
   end ();
   return 0;
diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
index b7427ca..0e84f7e 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -132,11 +132,38 @@  foreach trace_command { "trace" "ftrace" } {
     test_tracepoints $trace_command "\$$pcreg == *set_point" 10
 
     # Can we read local variables?
-    test_tracepoints $trace_command "anarg == 100 || anarg == 200" 2 18955_x86_64_failure
+    test_tracepoints $trace_command "arg8 == 1 || arg8 == 2" 2 18955_x86_64_failure
+    test_tracepoints $trace_command "arg16 == 257 || arg16 == 258" 2 18955_x86_64_failure
+    test_tracepoints $trace_command "arg32 == 65537 || arg32 == 65538" 2 18955_x86_64_failure
+    test_tracepoints $trace_command "arg64 == 4294967297 || arg64 == 4294967298" 2 18955_x86_64_failure
     # Can we read global variables?
-    test_tracepoints $trace_command "anarg == 100 && globvar == 1" 1 18955_x86_64_failure
+    test_tracepoints $trace_command "arg16 == 257 && globvar == 1" 1 18955_x86_64_failure
+
+    # This expression is used for testing emit_reg.
+    if [is_amd64_regs_target] {
+	set arg0exp "\$rdi"
+    } elseif [is_x86_like_target] {
+	set arg0exp "*(int *) (\$ebp + 8)"
+    } elseif { [istarget "aarch64*-*-*"] } {
+	set arg0exp "\$x0"
+    } elseif [istarget "powerpc*-*-*"] {
+	set arg0exp "\$r3"
+    } elseif { [istarget "s390x-*-*"] } {
+	set arg0exp "\$r2"
+    } elseif { [istarget "s390-*-*"] } {
+	# On targets with 64-bit GPRs, avoid the high part.
+	set arg0exp "(\$r2 & 0xffffffff)"
+    } else {
+	set arg0exp ""
+    }
+
+    if { "$arg0exp" != "" } {
+	test_tracepoints $trace_command "$arg0exp > 5" 5
+    }
 
     # Test various operations to cover as many opcodes as possible.
+    test_tracepoints $trace_command "21 == 21" 10
+    test_tracepoints $trace_command "21 != 42" 10
     test_tracepoints $trace_command "21 + 21 == 42" 10
     test_tracepoints $trace_command "42 - 21 == 21" 10
     test_tracepoints $trace_command "21 * 2 == 42" 10
@@ -149,6 +176,7 @@  foreach trace_command { "trace" "ftrace" } {
     test_tracepoints $trace_command "(0xaaaaaaaa ^ 0x55555555) == 0xffffffff" 10
     test_tracepoints $trace_command "~0xaaaaaaaa == 0x55555555" 10
     test_tracepoints $trace_command "21 < 42" 10
+    test_tracepoints $trace_command "21U < 42U" 10
     test_tracepoints $trace_command "42 <= 42" 10
     test_tracepoints $trace_command "42 >= 42" 10
     test_tracepoints $trace_command "42 > 21" 10
@@ -157,4 +185,40 @@  foreach trace_command { "trace" "ftrace" } {
     test_tracepoints $trace_command "(42 >= 42 ? 0 : 1) == 0" 10
     test_tracepoints $trace_command "(42 > 21 ? 0 : 1) == 0" 10 18955_i386_failure
     test_tracepoints $trace_command "\$trace_timestamp >= 0" 10
+
+    #Test operations with 64 bit operands.
+    test_tracepoints $trace_command "0xabababab00000000 == 0xcdcdcdcd00000000" 0
+    test_tracepoints $trace_command "!0xabababab00000000 == 0" 10
+    test_tracepoints $trace_command "0xababababcdcdcdcd + 0x1111111143434343 == 0xbcbcbcbd11111110" 10
+    test_tracepoints $trace_command "0xababababcdcdcdcd - 0x11111111dc111111 == 0x9a9a9a99f1bcbcbc" 10
+    test_tracepoints $trace_command "0xababababcdcdcdcd * 0xababababcdcdcdcd == 0x55320eeb91c3f629" 10
+    test_tracepoints $trace_command "0x00abababcdcdcdcd << 1 == 0x15757579b9b9b9a" 10
+    test_tracepoints $trace_command "0x00abababcdcdcdcd << 46 == 0x7373400000000000" 10
+    #signed rsh
+    test_tracepoints $trace_command "0x00abababcdcdcdcd >> 1 == 0x55d5d5e6e6e6e6" 10
+    test_tracepoints $trace_command "0x00abababcdcdcdcd >> 46 == 0x2ae" 10
+    #unsigned rsh
+    test_tracepoints $trace_command "0xababababcdcdcdcdUL >> 1 == 0x55d5d5d5e6e6e6e6UL" 10
+    test_tracepoints $trace_command "0xababababcdcdcdcdUL >> 46 == 0x2aeaeUL" 10
+    test_tracepoints $trace_command "-(0x00abababcdcdcdcd << 1) == -0x15757579b9b9b9a" 10
+    test_tracepoints $trace_command "-(0x00abababcdcdcdcd >> 1) == -0x55d5d5e6e6e6e6" 10
+    test_tracepoints $trace_command "(0xababababcdcdcdcd & 0x00000fffffffffff) == 0x00000babcdcdcdcd" 10
+    test_tracepoints $trace_command "(0xababababcdcdcdcd | 0x00000fffffffffff) == 0xababafffffffffff" 10
+    test_tracepoints $trace_command "(0xaaaaaaaaaaaaaaaa ^ 0x5555555555555555) == 0xffffffffffffffff" 10
+    test_tracepoints $trace_command "~0xaaaaaaaaaaaaaaaa == 0x5555555555555555" 10
+    #less unsigned
+    test_tracepoints $trace_command "0x99999999bbbbbbbb < 0xaaaaaaaaaaaaaaaa" 10
+    test_tracepoints $trace_command "0x99999999bbbbbbbb < 0x99999999cccccccc" 10
+    test_tracepoints $trace_command "0x99999999bbbbbbbb <= 0x99999999bbbbbbbb" 10
+    #less signed
+    test_tracepoints $trace_command "0x09999999bbbbbbbb < 0x0aaaaaaaaaaaaaaa" 10
+    test_tracepoints $trace_command "0x09999999bbbbbbbb < 0x09999999cccccccc" 10
+    test_tracepoints $trace_command "0x09999999bbbbbbbb <= 0x09999999bbbbbbbb" 10
+    test_tracepoints $trace_command "0x0aaaaaaaaaaaaaaa > 0x09999999bbbbbbbb" 10
+    test_tracepoints $trace_command "(0xabababab00000000 == 0xcdcdcdcd00000000 ? 1 : 0) == 0" 10
+    test_tracepoints $trace_command "(0xabababab00000000 != 0xcdcdcdcd00000000 ? 1 : 0) == 1" 10
+    test_tracepoints $trace_command "(0x09999999bbbbbbbb < 0x09999999cccccccc ? 1 : 0) == 1" 10 18955_i386_failure
+    test_tracepoints $trace_command "(0x09999999bbbbbbbb <= 0x09999999bbbbbbbb ? 1 : 0) == 1" 10
+    test_tracepoints $trace_command "(0x09999999bbbbbbbb >= 0x09999999bbbbbbbb ? 1 : 0) == 1" 10
+    test_tracepoints $trace_command "(0x0aaaaaaaaaaaaaaa > 0x09999999bbbbbbbb ? 1 : 0) == 1" 10
 }