public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 5/5 v2] Add tests for 64bit values in trace-condition.exp
  2016-05-27 19:05 [PATCH 1/5] Add counter-cases for trace-condition.exp tests Antoine Tremblay
  2016-05-27 19:05 ` [PATCH 4/5 v2] Add variable length tests for emit_ref in trace-condition.exp Antoine Tremblay
  2016-05-27 19:05 ` [PATCH 2/5 v2] Move trace conditions tests from ftrace.exp to trace-condition.exp Antoine Tremblay
@ 2016-05-27 19:05 ` Antoine Tremblay
  2016-05-30 11:02   ` Pedro Alves
  2016-05-27 19:05 ` [PATCH 3/5 v2] Add emit_less_unsigned test " Antoine Tremblay
  2016-05-30 10:50 ` [PATCH 1/5] Add counter-cases for trace-condition.exp tests Pedro Alves
  4 siblings, 1 reply; 16+ messages in thread
From: Antoine Tremblay @ 2016-05-27 19:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: Antoine Tremblay

This patch adds tests for emit operations with 64 bit values. It takes
special care to avoid mistakes that one could make on a 32bit architecture
using 64bit values.

gdb/testsuite/ChangeLog:

	* gdb.trace/trace-condition.exp: Add 64bit tests.
---
 gdb/testsuite/gdb.trace/trace-condition.exp | 73 +++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
index b7551b1..3f35489 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -187,4 +187,77 @@ foreach trace_command { "trace" "ftrace" } {
     test_tracepoints $trace_command "(66 <= 42 ? 0 : 1) == 0" 0
     test_tracepoints $trace_command "(11 >= 42 ? 0 : 1) == 0" 0
     test_tracepoints $trace_command "(11 > 21 ? 0 : 1) == 0" 0 18955_i386_failure
+
+    # 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
+
+    # Counter-cases test operations with 64 bit operands.
+    test_tracepoints $trace_command "0xabababab00000000 == 0xabababab00000000" 10
+    test_tracepoints $trace_command "!0x0 == 0" 0
+    test_tracepoints $trace_command "0xababababcdcdcdff + 0x1111111143434343 == 0xbcbcbcbd11111110" 0
+    test_tracepoints $trace_command "0xababababcdcdcdff - 0x11111111dc111111 == 0x9a9a9a99f1bcbcbc" 0
+    test_tracepoints $trace_command "0xababababcdcdcdff * 0xababababcdcdcdcd == 0x55320eeb91c3f629" 0
+    test_tracepoints $trace_command "0x00abababcdcdcdff << 1 == 0x15757579b9b9b9a" 0
+    test_tracepoints $trace_command "0x00abababcdcdcdff << 46 == 0x7373400000000000" 0
+    # signed rsh
+    test_tracepoints $trace_command "0x00bcababcdcdcdcd >> 1 == 0x55d5d5e6e6e6e6" 0
+    test_tracepoints $trace_command "0x00bcababcdcdcdcd >> 46 == 0x2ae" 0
+    # unsigned rsh
+    test_tracepoints $trace_command "0xcdabababcdcdcdcdUL >> 1 == 0x55d5d5d5e6e6e6e6UL" 0
+    test_tracepoints $trace_command "0xcdabababcdcdcdcdUL >> 46 == 0x2aeaeUL" 0
+    test_tracepoints $trace_command "-(0x00abababcdcdcdff << 1) == -0x15757579b9b9b9a" 0
+    test_tracepoints $trace_command "-(0x00cdababcdcdcdcd >> 1) == -0x55d5d5e6e6e6e6" 0
+    test_tracepoints $trace_command "(0xababababcdcdcdcd & 0x00000fffffffff00) == 0x00000babcdcdcdcd" 0
+    test_tracepoints $trace_command "(0xababababcdcdcdcd | 0x00000fffffffff00) == 0xababafffffffffff" 0
+    test_tracepoints $trace_command "(0xaaaaaaaaaaaaaaaa ^ 0x5555555555555111) == 0xffffffffffffffff" 0
+    test_tracepoints $trace_command "~0xaaaaaaaaaaaaaaaa == 0x5555555555555111" 0
+    # less unsigned
+    test_tracepoints $trace_command "0xbb999999bbbbbbbb < 0xaaaaaaaaaaaaaaaa" 0
+    test_tracepoints $trace_command "0x99999999eebbbbbb < 0x99999999cccccccc" 0
+    test_tracepoints $trace_command "0xbb999999eebbbbbb <= 0x99999999bbbbbbbb" 0
+    # less signed
+    test_tracepoints $trace_command "0x0bb99999ccbbbbbb < 0x0aaaaaaaaaaaaaaa" 0
+    test_tracepoints $trace_command "0x09999999ddbbbbbb < 0x09999999cccccccc" 0
+    test_tracepoints $trace_command "0x0aa99999bbbbbbbb <= 0x09999999bbbbbbbb" 0
+    test_tracepoints $trace_command "0x088aaaaabbaaaaaa > 0x09999999bbbbbbbb" 0
+    test_tracepoints $trace_command "(0xcdcdcdcd00000000 == 0xcdcdcdcd00000000 ? 1 : 0) == 0" 0
+    test_tracepoints $trace_command "(0xcdcdcdcd00000000 != 0xcdcdcdcd00000000 ? 1 : 0) == 1" 0
+    test_tracepoints $trace_command "(0x09999999eeebbbbb < 0x09999999cccccccc ? 1 : 0) == 1" 0 18955_i386_failure
+    test_tracepoints $trace_command "(0x09999999eeebbbbb <= 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
+    test_tracepoints $trace_command "(0x00099999bbbbbbbb >= 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
+    test_tracepoints $trace_command "(0x00088888ccaaaaaa > 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
+
 }
-- 
2.8.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 4/5 v2] Add variable length tests for emit_ref in trace-condition.exp
  2016-05-27 19:05 [PATCH 1/5] Add counter-cases for trace-condition.exp tests Antoine Tremblay
@ 2016-05-27 19:05 ` Antoine Tremblay
  2016-05-30 11:02   ` Pedro Alves
  2016-05-27 19:05 ` [PATCH 2/5 v2] Move trace conditions tests from ftrace.exp to trace-condition.exp Antoine Tremblay
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Antoine Tremblay @ 2016-05-27 19:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: Antoine Tremblay

This patch add variable length tests for emit_ref by reading the variable
passed as argument of 8 to 64 bit.

gdb/testsuite/ChangeLog:

	* 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/trace-condition.c   | 8 +++++---
 gdb/testsuite/gdb.trace/trace-condition.exp | 7 +++++--
 2 files changed, 10 insertions(+), 5 deletions(-)

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 e179828..b7551b1 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -132,9 +132,12 @@ 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
 
     # Test various operations to cover as many opcodes as possible.
     test_tracepoints $trace_command "21 == 21" 10
-- 
2.8.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/5] Add counter-cases for trace-condition.exp tests
@ 2016-05-27 19:05 Antoine Tremblay
  2016-05-27 19:05 ` [PATCH 4/5 v2] Add variable length tests for emit_ref in trace-condition.exp Antoine Tremblay
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Antoine Tremblay @ 2016-05-27 19:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: Antoine Tremblay

In trace-condition.exp, tests are done by doing a conditional tracepoint
and validating that the trace contains all the frames that could be
collected if that condition is true.

E.g. test_tracepoints $trace_command "21 + 21 == 42" 10

This will always return true and collect the 10 frames possible to collect
with the test program.

However, if the condition evaluation is broken such that the condition is
unconditional we will not notice this problem.

This patch adds counter-cases to such conditions like so:

$trace_command "21 + 11 == 42" 0

This way such a problem would be noticed.

gdb/testsuite/ChangeLog:

	* gdb.trace/trace-condition.exp: Add counter-case tests.
---
 gdb/testsuite/gdb.trace/trace-condition.exp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
index b7427ca..f9eaf31 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -157,4 +157,25 @@ 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
+
+    # Counter-cases tests.
+    test_tracepoints $trace_command "21 + 21 == 11" 0
+    test_tracepoints $trace_command "42 - 21 == 11" 0
+    test_tracepoints $trace_command "21 * 2 == 11" 0
+    test_tracepoints $trace_command "21 << 1 == 11" 0
+    test_tracepoints $trace_command "42 >> 1 == 11" 0
+    test_tracepoints $trace_command "-(21 << 1) == -11" 0
+    test_tracepoints $trace_command "-42 >> 1 == -11" 0
+    test_tracepoints $trace_command "(0xabababab & 0x0000ffff) == 0xffff" 0
+    test_tracepoints $trace_command "(0xabababab | 0x0000ffff) == 0xeeeedddd" 0
+    test_tracepoints $trace_command "(0xaaaaaaaa ^ 0x55555555) == 0xaaaaaaaa" 0
+    test_tracepoints $trace_command "~0xaaaaaaaa == 0x11111111" 0
+    test_tracepoints $trace_command "61 < 42" 0
+    test_tracepoints $trace_command "42 <= 11" 0
+    test_tracepoints $trace_command "11 >= 42" 0
+    test_tracepoints $trace_command "11 > 21" 0
+    test_tracepoints $trace_command "(66 < 42 ? 0 : 1) == 0" 0 18955_i386_failure
+    test_tracepoints $trace_command "(66 <= 42 ? 0 : 1) == 0" 0
+    test_tracepoints $trace_command "(11 >= 42 ? 0 : 1) == 0" 0
+    test_tracepoints $trace_command "(11 > 21 ? 0 : 1) == 0" 0 18955_i386_failure
 }
-- 
2.8.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/5 v2] Add emit_less_unsigned test in trace-condition.exp
  2016-05-27 19:05 [PATCH 1/5] Add counter-cases for trace-condition.exp tests Antoine Tremblay
                   ` (2 preceding siblings ...)
  2016-05-27 19:05 ` [PATCH 5/5 v2] Add tests for 64bit values in trace-condition.exp Antoine Tremblay
@ 2016-05-27 19:05 ` Antoine Tremblay
  2016-05-30 11:02   ` Pedro Alves
  2016-05-30 10:50 ` [PATCH 1/5] Add counter-cases for trace-condition.exp tests Pedro Alves
  4 siblings, 1 reply; 16+ messages in thread
From: Antoine Tremblay @ 2016-05-27 19:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: Antoine Tremblay

This patch adds coverage for emit_less_unsigned.

gdb/testsuite/ChangeLog:

	* gdb.trace/trace-condition.exp: Add emit_less_unsigned test.
---
 gdb/testsuite/gdb.trace/trace-condition.exp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
index c4dc5fe..e179828 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -151,6 +151,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
@@ -175,6 +176,7 @@ foreach trace_command { "trace" "ftrace" } {
     test_tracepoints $trace_command "(0xaaaaaaaa ^ 0x55555555) == 0xaaaaaaaa" 0
     test_tracepoints $trace_command "~0xaaaaaaaa == 0x11111111" 0
     test_tracepoints $trace_command "61 < 42" 0
+    test_tracepoints $trace_command "61U < 42U" 0
     test_tracepoints $trace_command "42 <= 11" 0
     test_tracepoints $trace_command "11 >= 42" 0
     test_tracepoints $trace_command "11 > 21" 0
-- 
2.8.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/5 v2] Move trace conditions tests from ftrace.exp to trace-condition.exp
  2016-05-27 19:05 [PATCH 1/5] Add counter-cases for trace-condition.exp tests Antoine Tremblay
  2016-05-27 19:05 ` [PATCH 4/5 v2] Add variable length tests for emit_ref in trace-condition.exp Antoine Tremblay
@ 2016-05-27 19:05 ` Antoine Tremblay
  2016-05-30 11:02   ` Pedro Alves
  2016-05-27 19:05 ` [PATCH 5/5 v2] Add tests for 64bit values in trace-condition.exp Antoine Tremblay
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Antoine Tremblay @ 2016-05-27 19:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: Antoine Tremblay

This patch moves conditional tests that were done in ftrace.exp to
trace-condition.exp.

Note that emit_ref is now tested by the anarg local variable there is no
need to test the register directly.

All emit calls have been tested using asserts before / after the move, so
that the tests cover the same functions.

Note that these function were not covered before and are still not:
emit_gt_goto, emit_lt_goto, emit_pop, emit_unsigned_less.

gdb/testsuite/ChangeLog:

	* gdb.trace/ftrace.exp (test_ftrace_condition): Remove.
	Move condition tests...
	* gdb.trace/trace-condition.exp: Here.
---
 gdb/testsuite/gdb.trace/ftrace.exp          | 74 -----------------------------
 gdb/testsuite/gdb.trace/trace-condition.exp |  4 ++
 2 files changed, 4 insertions(+), 74 deletions(-)

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.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
index f9eaf31..c4dc5fe 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -137,6 +137,8 @@ foreach trace_command { "trace" "ftrace" } {
     test_tracepoints $trace_command "anarg == 100 && globvar == 1" 1 18955_x86_64_failure
 
     # 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
@@ -159,6 +161,8 @@ foreach trace_command { "trace" "ftrace" } {
     test_tracepoints $trace_command "\$trace_timestamp >= 0" 10
 
     # Counter-cases tests.
+    test_tracepoints $trace_command "11 == 21" 0
+    test_tracepoints $trace_command "42 != 42" 0
     test_tracepoints $trace_command "21 + 21 == 11" 0
     test_tracepoints $trace_command "42 - 21 == 11" 0
     test_tracepoints $trace_command "21 * 2 == 11" 0
-- 
2.8.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] Add counter-cases for trace-condition.exp tests
  2016-05-27 19:05 [PATCH 1/5] Add counter-cases for trace-condition.exp tests Antoine Tremblay
                   ` (3 preceding siblings ...)
  2016-05-27 19:05 ` [PATCH 3/5 v2] Add emit_less_unsigned test " Antoine Tremblay
@ 2016-05-30 10:50 ` Pedro Alves
  2016-05-30 14:20   ` Antoine Tremblay
  2016-05-30 14:48   ` [PATCH 1/5 v3] " Antoine Tremblay
  4 siblings, 2 replies; 16+ messages in thread
From: Pedro Alves @ 2016-05-30 10:50 UTC (permalink / raw)
  To: Antoine Tremblay, gdb-patches

On 05/27/2016 08:05 PM, Antoine Tremblay wrote:
> In trace-condition.exp, tests are done by doing a conditional tracepoint
> and validating that the trace contains all the frames that could be
> collected if that condition is true.
> 
> E.g. test_tracepoints $trace_command "21 + 21 == 42" 10
> 
> This will always return true and collect the 10 frames possible to collect
> with the test program.
> 
> However, if the condition evaluation is broken such that the condition is
> unconditional we will not notice this problem.
> 
> This patch adds counter-cases to such conditions like so:
> 
> $trace_command "21 + 11 == 42" 0
> 
> This way such a problem would be noticed.

Thanks for doing this.

> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.trace/trace-condition.exp: Add counter-case tests.
> ---
>  gdb/testsuite/gdb.trace/trace-condition.exp | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
> index b7427ca..f9eaf31 100644
> --- a/gdb/testsuite/gdb.trace/trace-condition.exp
> +++ b/gdb/testsuite/gdb.trace/trace-condition.exp
> @@ -157,4 +157,25 @@ 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
> +
> +    # Counter-cases tests.
> +    test_tracepoints $trace_command "21 + 21 == 11" 0
> +    test_tracepoints $trace_command "42 - 21 == 11" 0
> +    test_tracepoints $trace_command "21 * 2 == 11" 0
> +    test_tracepoints $trace_command "21 << 1 == 11" 0
> +    test_tracepoints $trace_command "42 >> 1 == 11" 0
> +    test_tracepoints $trace_command "-(21 << 1) == -11" 0
> +    test_tracepoints $trace_command "-42 >> 1 == -11" 0
> +    test_tracepoints $trace_command "(0xabababab & 0x0000ffff) == 0xffff" 0
> +    test_tracepoints $trace_command "(0xabababab | 0x0000ffff) == 0xeeeedddd" 0
> +    test_tracepoints $trace_command "(0xaaaaaaaa ^ 0x55555555) == 0xaaaaaaaa" 0
> +    test_tracepoints $trace_command "~0xaaaaaaaa == 0x11111111" 0
> +    test_tracepoints $trace_command "61 < 42" 0
> +    test_tracepoints $trace_command "42 <= 11" 0
> +    test_tracepoints $trace_command "11 >= 42" 0
> +    test_tracepoints $trace_command "11 > 21" 0
> +    test_tracepoints $trace_command "(66 < 42 ? 0 : 1) == 0" 0 18955_i386_failure
> +    test_tracepoints $trace_command "(66 <= 42 ? 0 : 1) == 0" 0
> +    test_tracepoints $trace_command "(11 >= 42 ? 0 : 1) == 0" 0
> +    test_tracepoints $trace_command "(11 > 21 ? 0 : 1) == 0" 0 18955_i386_failure

I'm surprised to see these split into their own section though.
I'd think it'd be better to keep each along side the corresponding test,
to make it easier to keep them in sync:

     test_tracepoints $trace_command "21 + 21 == 42" 10
+    test_tracepoints $trace_command "21 + 21 == 11" 0
     test_tracepoints $trace_command "42 - 21 == 21" 10
+    test_tracepoints $trace_command "42 - 21 == 11" 0

etc.

Could you do that?

>  }
> 

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/5 v2] Add emit_less_unsigned test in trace-condition.exp
  2016-05-27 19:05 ` [PATCH 3/5 v2] Add emit_less_unsigned test " Antoine Tremblay
@ 2016-05-30 11:02   ` Pedro Alves
  0 siblings, 0 replies; 16+ messages in thread
From: Pedro Alves @ 2016-05-30 11:02 UTC (permalink / raw)
  To: Antoine Tremblay, gdb-patches

On 05/27/2016 08:05 PM, Antoine Tremblay wrote:
> This patch adds coverage for emit_less_unsigned.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.trace/trace-condition.exp: Add emit_less_unsigned test.

"tests" :-)

LGTM.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 5/5 v2] Add tests for 64bit values in trace-condition.exp
  2016-05-27 19:05 ` [PATCH 5/5 v2] Add tests for 64bit values in trace-condition.exp Antoine Tremblay
@ 2016-05-30 11:02   ` Pedro Alves
  2016-05-30 14:50     ` [PATCH 5/5 v3] " Antoine Tremblay
  0 siblings, 1 reply; 16+ messages in thread
From: Pedro Alves @ 2016-05-30 11:02 UTC (permalink / raw)
  To: Antoine Tremblay, gdb-patches

On 05/27/2016 08:05 PM, Antoine Tremblay wrote:
> This patch adds tests for emit operations with 64 bit values. It takes
> special care to avoid mistakes that one could make on a 32bit architecture
> using 64bit values.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.trace/trace-condition.exp: Add 64bit tests.
> ---
>  gdb/testsuite/gdb.trace/trace-condition.exp | 73 +++++++++++++++++++++++++++++
>  1 file changed, 73 insertions(+)
> 
> diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
> index b7551b1..3f35489 100644
> --- a/gdb/testsuite/gdb.trace/trace-condition.exp
> +++ b/gdb/testsuite/gdb.trace/trace-condition.exp
> @@ -187,4 +187,77 @@ foreach trace_command { "trace" "ftrace" } {
>      test_tracepoints $trace_command "(66 <= 42 ? 0 : 1) == 0" 0
>      test_tracepoints $trace_command "(11 >= 42 ? 0 : 1) == 0" 0
>      test_tracepoints $trace_command "(11 > 21 ? 0 : 1) == 0" 0 18955_i386_failure
> +
> +    # 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
> +
> +    # Counter-cases test operations with 64 bit operands.
> +    test_tracepoints $trace_command "0xabababab00000000 == 0xabababab00000000" 10
> +    test_tracepoints $trace_command "!0x0 == 0" 0
> +    test_tracepoints $trace_command "0xababababcdcdcdff + 0x1111111143434343 == 0xbcbcbcbd11111110" 0
> +    test_tracepoints $trace_command "0xababababcdcdcdff - 0x11111111dc111111 == 0x9a9a9a99f1bcbcbc" 0
> +    test_tracepoints $trace_command "0xababababcdcdcdff * 0xababababcdcdcdcd == 0x55320eeb91c3f629" 0
> +    test_tracepoints $trace_command "0x00abababcdcdcdff << 1 == 0x15757579b9b9b9a" 0
> +    test_tracepoints $trace_command "0x00abababcdcdcdff << 46 == 0x7373400000000000" 0
> +    # signed rsh
> +    test_tracepoints $trace_command "0x00bcababcdcdcdcd >> 1 == 0x55d5d5e6e6e6e6" 0
> +    test_tracepoints $trace_command "0x00bcababcdcdcdcd >> 46 == 0x2ae" 0
> +    # unsigned rsh
> +    test_tracepoints $trace_command "0xcdabababcdcdcdcdUL >> 1 == 0x55d5d5d5e6e6e6e6UL" 0
> +    test_tracepoints $trace_command "0xcdabababcdcdcdcdUL >> 46 == 0x2aeaeUL" 0
> +    test_tracepoints $trace_command "-(0x00abababcdcdcdff << 1) == -0x15757579b9b9b9a" 0
> +    test_tracepoints $trace_command "-(0x00cdababcdcdcdcd >> 1) == -0x55d5d5e6e6e6e6" 0
> +    test_tracepoints $trace_command "(0xababababcdcdcdcd & 0x00000fffffffff00) == 0x00000babcdcdcdcd" 0
> +    test_tracepoints $trace_command "(0xababababcdcdcdcd | 0x00000fffffffff00) == 0xababafffffffffff" 0
> +    test_tracepoints $trace_command "(0xaaaaaaaaaaaaaaaa ^ 0x5555555555555111) == 0xffffffffffffffff" 0
> +    test_tracepoints $trace_command "~0xaaaaaaaaaaaaaaaa == 0x5555555555555111" 0
> +    # less unsigned
> +    test_tracepoints $trace_command "0xbb999999bbbbbbbb < 0xaaaaaaaaaaaaaaaa" 0
> +    test_tracepoints $trace_command "0x99999999eebbbbbb < 0x99999999cccccccc" 0
> +    test_tracepoints $trace_command "0xbb999999eebbbbbb <= 0x99999999bbbbbbbb" 0
> +    # less signed
> +    test_tracepoints $trace_command "0x0bb99999ccbbbbbb < 0x0aaaaaaaaaaaaaaa" 0
> +    test_tracepoints $trace_command "0x09999999ddbbbbbb < 0x09999999cccccccc" 0
> +    test_tracepoints $trace_command "0x0aa99999bbbbbbbb <= 0x09999999bbbbbbbb" 0
> +    test_tracepoints $trace_command "0x088aaaaabbaaaaaa > 0x09999999bbbbbbbb" 0
> +    test_tracepoints $trace_command "(0xcdcdcdcd00000000 == 0xcdcdcdcd00000000 ? 1 : 0) == 0" 0
> +    test_tracepoints $trace_command "(0xcdcdcdcd00000000 != 0xcdcdcdcd00000000 ? 1 : 0) == 1" 0
> +    test_tracepoints $trace_command "(0x09999999eeebbbbb < 0x09999999cccccccc ? 1 : 0) == 1" 0 18955_i386_failure
> +    test_tracepoints $trace_command "(0x09999999eeebbbbb <= 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
> +    test_tracepoints $trace_command "(0x00099999bbbbbbbb >= 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
> +    test_tracepoints $trace_command "(0x00088888ccaaaaaa > 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
> +
>  }
> 

Same comment on splitting the counter-cases to their own section.
It's very hard to match the counter-case with the corresponding "case" 
test this way IMO.  Could you resort please?  Maybe even add an empty
line between each pair of case/counter-case, for added legibility.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5 v2] Move trace conditions tests from ftrace.exp to trace-condition.exp
  2016-05-27 19:05 ` [PATCH 2/5 v2] Move trace conditions tests from ftrace.exp to trace-condition.exp Antoine Tremblay
@ 2016-05-30 11:02   ` Pedro Alves
  0 siblings, 0 replies; 16+ messages in thread
From: Pedro Alves @ 2016-05-30 11:02 UTC (permalink / raw)
  To: Antoine Tremblay, gdb-patches

On 05/27/2016 08:05 PM, Antoine Tremblay wrote:
> This patch moves conditional tests that were done in ftrace.exp to
> trace-condition.exp.
> 
> Note that emit_ref is now tested by the anarg local variable there is no
> need to test the register directly.
> 
> All emit calls have been tested using asserts before / after the move, so
> that the tests cover the same functions.

ITYM s/so that/to ensure that/

LGTM.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 4/5 v2] Add variable length tests for emit_ref in trace-condition.exp
  2016-05-27 19:05 ` [PATCH 4/5 v2] Add variable length tests for emit_ref in trace-condition.exp Antoine Tremblay
@ 2016-05-30 11:02   ` Pedro Alves
  0 siblings, 0 replies; 16+ messages in thread
From: Pedro Alves @ 2016-05-30 11:02 UTC (permalink / raw)
  To: Antoine Tremblay, gdb-patches

On 05/27/2016 08:05 PM, Antoine Tremblay wrote:
> This patch add variable length tests for emit_ref by reading the variable
> passed as argument of 8 to 64 bit.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* 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.

LGTM.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] Add counter-cases for trace-condition.exp tests
  2016-05-30 10:50 ` [PATCH 1/5] Add counter-cases for trace-condition.exp tests Pedro Alves
@ 2016-05-30 14:20   ` Antoine Tremblay
  2016-05-30 14:48   ` [PATCH 1/5 v3] " Antoine Tremblay
  1 sibling, 0 replies; 16+ messages in thread
From: Antoine Tremblay @ 2016-05-30 14:20 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Antoine Tremblay, gdb-patches


Pedro Alves writes:

> On 05/27/2016 08:05 PM, Antoine Tremblay wrote:
>> In trace-condition.exp, tests are done by doing a conditional tracepoint
>> and validating that the trace contains all the frames that could be
>> collected if that condition is true.
>> 
>> E.g. test_tracepoints $trace_command "21 + 21 == 42" 10
>> 
>> This will always return true and collect the 10 frames possible to collect
>> with the test program.
>> 
>> However, if the condition evaluation is broken such that the condition is
>> unconditional we will not notice this problem.
>> 
>> This patch adds counter-cases to such conditions like so:
>> 
>> $trace_command "21 + 11 == 42" 0
>> 
>> This way such a problem would be noticed.
>
> Thanks for doing this.
>
>> 
>> gdb/testsuite/ChangeLog:
>> 
>> 	* gdb.trace/trace-condition.exp: Add counter-case tests.
>> ---
>>  gdb/testsuite/gdb.trace/trace-condition.exp | 21 +++++++++++++++++++++
>>  1 file changed, 21 insertions(+)
>> 
>> diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
>> index b7427ca..f9eaf31 100644
>> --- a/gdb/testsuite/gdb.trace/trace-condition.exp
>> +++ b/gdb/testsuite/gdb.trace/trace-condition.exp
>> @@ -157,4 +157,25 @@ 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
>> +
>> +    # Counter-cases tests.
>> +    test_tracepoints $trace_command "21 + 21 == 11" 0
>> +    test_tracepoints $trace_command "42 - 21 == 11" 0
>> +    test_tracepoints $trace_command "21 * 2 == 11" 0
>> +    test_tracepoints $trace_command "21 << 1 == 11" 0
>> +    test_tracepoints $trace_command "42 >> 1 == 11" 0
>> +    test_tracepoints $trace_command "-(21 << 1) == -11" 0
>> +    test_tracepoints $trace_command "-42 >> 1 == -11" 0
>> +    test_tracepoints $trace_command "(0xabababab & 0x0000ffff) == 0xffff" 0
>> +    test_tracepoints $trace_command "(0xabababab | 0x0000ffff) == 0xeeeedddd" 0
>> +    test_tracepoints $trace_command "(0xaaaaaaaa ^ 0x55555555) == 0xaaaaaaaa" 0
>> +    test_tracepoints $trace_command "~0xaaaaaaaa == 0x11111111" 0
>> +    test_tracepoints $trace_command "61 < 42" 0
>> +    test_tracepoints $trace_command "42 <= 11" 0
>> +    test_tracepoints $trace_command "11 >= 42" 0
>> +    test_tracepoints $trace_command "11 > 21" 0
>> +    test_tracepoints $trace_command "(66 < 42 ? 0 : 1) == 0" 0 18955_i386_failure
>> +    test_tracepoints $trace_command "(66 <= 42 ? 0 : 1) == 0" 0
>> +    test_tracepoints $trace_command "(11 >= 42 ? 0 : 1) == 0" 0
>> +    test_tracepoints $trace_command "(11 > 21 ? 0 : 1) == 0" 0 18955_i386_failure
>
> I'm surprised to see these split into their own section though.
> I'd think it'd be better to keep each along side the corresponding test,
> to make it easier to keep them in sync:
>
>      test_tracepoints $trace_command "21 + 21 == 42" 10
> +    test_tracepoints $trace_command "21 + 21 == 11" 0
>      test_tracepoints $trace_command "42 - 21 == 21" 10
> +    test_tracepoints $trace_command "42 - 21 == 11" 0
>
> etc.
>
> Could you do that?
>

Yes actually I did that at first, but found it very confusing with so
many similar lines together so I continued using another block.

But like you sugested in patch 5 review I can add a line between each
test case/counter.

I'll do that and repost.

Thanks,
Antoine

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/5 v3] Add counter-cases for trace-condition.exp tests
  2016-05-30 10:50 ` [PATCH 1/5] Add counter-cases for trace-condition.exp tests Pedro Alves
  2016-05-30 14:20   ` Antoine Tremblay
@ 2016-05-30 14:48   ` Antoine Tremblay
  2016-05-30 15:06     ` Pedro Alves
  1 sibling, 1 reply; 16+ messages in thread
From: Antoine Tremblay @ 2016-05-30 14:48 UTC (permalink / raw)
  To: palves, gdb-patches; +Cc: Antoine Tremblay

In this v3:

- Fixed test interleaving

Note that I also fixed patch 3/5 to match this new setting.

--

In trace-condition.exp, tests are done by doing a conditional tracepoint
and validating that the trace contains all the frames that could be
collected if that condition is true.

E.g. test_tracepoints $trace_command "21 + 21 == 42" 10

This will always return true and collect the 10 frames possible to collect
with the test program.

However, if the condition evaluation is broken such that the condition is
unconditional we will not notice this problem.

This patch adds counter-cases to such conditions like so:

$trace_command "21 + 11 == 42" 0

This way such a problem would be noticed.

gdb/testsuite/ChangeLog:

	* gdb.trace/trace-condition.exp: Add counter-case tests.
---
 gdb/testsuite/gdb.trace/trace-condition.exp | 38 +++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
index b7427ca..ca3232f 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -138,23 +138,61 @@ foreach trace_command { "trace" "ftrace" } {
 
     # Test various operations to cover as many opcodes as possible.
     test_tracepoints $trace_command "21 + 21 == 42" 10
+    test_tracepoints $trace_command "21 + 21 == 11" 0
+
     test_tracepoints $trace_command "42 - 21 == 21" 10
+    test_tracepoints $trace_command "42 - 21 == 11" 0
+
     test_tracepoints $trace_command "21 * 2 == 42" 10
+    test_tracepoints $trace_command "21 * 2 == 11" 0
+
     test_tracepoints $trace_command "21 << 1 == 42" 10
+    test_tracepoints $trace_command "21 << 1 == 11" 0
+
     test_tracepoints $trace_command "42 >> 1 == 21" 10
+    test_tracepoints $trace_command "42 >> 1 == 11" 0
+
     test_tracepoints $trace_command "-(21 << 1) == -42" 10
+    test_tracepoints $trace_command "-(21 << 1) == -11" 0
+
     test_tracepoints $trace_command "-42 >> 1 == -21" 10
+    test_tracepoints $trace_command "-42 >> 1 == -11" 0
+
     test_tracepoints $trace_command "(0xabababab & 0x0000ffff) == 0xabab" 10
+    test_tracepoints $trace_command "(0xabababab & 0x0000ffff) == 0xffff" 0
+
     test_tracepoints $trace_command "(0xabababab | 0x0000ffff) == 0xababffff" 10
+    test_tracepoints $trace_command "(0xabababab | 0x0000ffff) == 0xeeeedddd" 0
+
     test_tracepoints $trace_command "(0xaaaaaaaa ^ 0x55555555) == 0xffffffff" 10
+    test_tracepoints $trace_command "(0xaaaaaaaa ^ 0x55555555) == 0xaaaaaaaa" 0
+
     test_tracepoints $trace_command "~0xaaaaaaaa == 0x55555555" 10
+    test_tracepoints $trace_command "~0xaaaaaaaa == 0x11111111" 0
+
     test_tracepoints $trace_command "21 < 42" 10
+    test_tracepoints $trace_command "61 < 42" 0
+
     test_tracepoints $trace_command "42 <= 42" 10
+    test_tracepoints $trace_command "42 <= 11" 0
+
     test_tracepoints $trace_command "42 >= 42" 10
+    test_tracepoints $trace_command "11 >= 42" 0
+
     test_tracepoints $trace_command "42 > 21" 10
+    test_tracepoints $trace_command "11 > 21" 0
+
     test_tracepoints $trace_command "(21 < 42 ? 0 : 1) == 0" 10 18955_i386_failure
+    test_tracepoints $trace_command "(66 < 42 ? 0 : 1) == 0" 0 18955_i386_failure
+
     test_tracepoints $trace_command "(42 <= 42 ? 0 : 1) == 0" 10
+    test_tracepoints $trace_command "(66 <= 42 ? 0 : 1) == 0" 0
+
     test_tracepoints $trace_command "(42 >= 42 ? 0 : 1) == 0" 10
+    test_tracepoints $trace_command "(11 >= 42 ? 0 : 1) == 0" 0
+
     test_tracepoints $trace_command "(42 > 21 ? 0 : 1) == 0" 10 18955_i386_failure
+    test_tracepoints $trace_command "(11 > 21 ? 0 : 1) == 0" 0 18955_i386_failure
+
     test_tracepoints $trace_command "\$trace_timestamp >= 0" 10
 }
-- 
2.8.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 5/5 v3] Add tests for 64bit values in trace-condition.exp
  2016-05-30 11:02   ` Pedro Alves
@ 2016-05-30 14:50     ` Antoine Tremblay
  2016-05-30 15:06       ` Pedro Alves
  0 siblings, 1 reply; 16+ messages in thread
From: Antoine Tremblay @ 2016-05-30 14:50 UTC (permalink / raw)
  To: palves, gdb-patches; +Cc: Antoine Tremblay

This patch adds tests for emit operations with 64 bit values. It takes
special care to avoid mistakes that one could make on a 32bit architecture
using 64bit values.

gdb/testsuite/ChangeLog:

	* gdb.trace/trace-condition.exp: Add 64bit tests.
---
 gdb/testsuite/gdb.trace/trace-condition.exp | 95 +++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/gdb/testsuite/gdb.trace/trace-condition.exp b/gdb/testsuite/gdb.trace/trace-condition.exp
index 6f4413d..e36dba4 100644
--- a/gdb/testsuite/gdb.trace/trace-condition.exp
+++ b/gdb/testsuite/gdb.trace/trace-condition.exp
@@ -207,4 +207,99 @@ foreach trace_command { "trace" "ftrace" } {
     test_tracepoints $trace_command "(11 > 21 ? 0 : 1) == 0" 0 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 == 0xabababab00000000" 10
+
+    test_tracepoints $trace_command "!0xabababab00000000 == 0" 10
+    test_tracepoints $trace_command "!0x0 == 0" 0
+
+    test_tracepoints $trace_command "0xababababcdcdcdcd + 0x1111111143434343 == 0xbcbcbcbd11111110" 10
+    test_tracepoints $trace_command "0xababababcdcdcdff + 0x1111111143434343 == 0xbcbcbcbd11111110" 0
+
+    test_tracepoints $trace_command "0xababababcdcdcdcd - 0x11111111dc111111 == 0x9a9a9a99f1bcbcbc" 10
+    test_tracepoints $trace_command "0xababababcdcdcdff - 0x11111111dc111111 == 0x9a9a9a99f1bcbcbc" 0
+
+    test_tracepoints $trace_command "0xababababcdcdcdcd * 0xababababcdcdcdcd == 0x55320eeb91c3f629" 10
+    test_tracepoints $trace_command "0xababababcdcdcdff * 0xababababcdcdcdcd == 0x55320eeb91c3f629" 0
+
+    test_tracepoints $trace_command "0x00abababcdcdcdcd << 1 == 0x15757579b9b9b9a" 10
+    test_tracepoints $trace_command "0x00abababcdcdcdff << 1 == 0x15757579b9b9b9a" 0
+
+    test_tracepoints $trace_command "0x00abababcdcdcdcd << 46 == 0x7373400000000000" 10
+    test_tracepoints $trace_command "0x00abababcdcdcdff << 46 == 0x7373400000000000" 0
+
+    # signed rsh
+    test_tracepoints $trace_command "0x00abababcdcdcdcd >> 1 == 0x55d5d5e6e6e6e6" 10
+    test_tracepoints $trace_command "0x00bcababcdcdcdcd >> 1 == 0x55d5d5e6e6e6e6" 0
+
+    test_tracepoints $trace_command "0x00abababcdcdcdcd >> 46 == 0x2ae" 10
+    test_tracepoints $trace_command "0x00bcababcdcdcdcd >> 46 == 0x2ae" 0
+
+    # unsigned rsh
+    test_tracepoints $trace_command "0xababababcdcdcdcdUL >> 1 == 0x55d5d5d5e6e6e6e6UL" 10
+    test_tracepoints $trace_command "0xcdabababcdcdcdcdUL >> 1 == 0x55d5d5d5e6e6e6e6UL" 0
+
+    test_tracepoints $trace_command "0xababababcdcdcdcdUL >> 46 == 0x2aeaeUL" 10
+    test_tracepoints $trace_command "0xcdabababcdcdcdcdUL >> 46 == 0x2aeaeUL" 0
+
+    test_tracepoints $trace_command "-(0x00abababcdcdcdcd << 1) == -0x15757579b9b9b9a" 10
+    test_tracepoints $trace_command "-(0x00abababcdcdcdff << 1) == -0x15757579b9b9b9a" 0
+
+    test_tracepoints $trace_command "-(0x00abababcdcdcdcd >> 1) == -0x55d5d5e6e6e6e6" 10
+    test_tracepoints $trace_command "-(0x00cdababcdcdcdcd >> 1) == -0x55d5d5e6e6e6e6" 0
+
+    test_tracepoints $trace_command "(0xababababcdcdcdcd & 0x00000fffffffffff) == 0x00000babcdcdcdcd" 10
+    test_tracepoints $trace_command "(0xababababcdcdcdcd & 0x00000fffffffff00) == 0x00000babcdcdcdcd" 0
+
+    test_tracepoints $trace_command "(0xababababcdcdcdcd | 0x00000fffffffffff) == 0xababafffffffffff" 10
+    test_tracepoints $trace_command "(0xababababcdcdcdcd | 0x00000fffffffff00) == 0xababafffffffffff" 0
+
+    test_tracepoints $trace_command "(0xaaaaaaaaaaaaaaaa ^ 0x5555555555555555) == 0xffffffffffffffff" 10
+    test_tracepoints $trace_command "(0xaaaaaaaaaaaaaaaa ^ 0x5555555555555111) == 0xffffffffffffffff" 0
+
+    test_tracepoints $trace_command "~0xaaaaaaaaaaaaaaaa == 0x5555555555555555" 10
+    test_tracepoints $trace_command "~0xaaaaaaaaaaaaaaaa == 0x5555555555555111" 0
+
+    # less unsigned
+    test_tracepoints $trace_command "0x99999999bbbbbbbb < 0xaaaaaaaaaaaaaaaa" 10
+    test_tracepoints $trace_command "0xbb999999bbbbbbbb < 0xaaaaaaaaaaaaaaaa" 0
+
+    test_tracepoints $trace_command "0x99999999bbbbbbbb < 0x99999999cccccccc" 10
+    test_tracepoints $trace_command "0x99999999eebbbbbb < 0x99999999cccccccc" 0
+
+    test_tracepoints $trace_command "0x99999999bbbbbbbb <= 0x99999999bbbbbbbb" 10
+    test_tracepoints $trace_command "0xbb999999eebbbbbb <= 0x99999999bbbbbbbb" 0
+
+    # less signed
+    test_tracepoints $trace_command "0x09999999bbbbbbbb < 0x0aaaaaaaaaaaaaaa" 10
+    test_tracepoints $trace_command "0x0bb99999ccbbbbbb < 0x0aaaaaaaaaaaaaaa" 0
+
+    test_tracepoints $trace_command "0x09999999bbbbbbbb < 0x09999999cccccccc" 10
+    test_tracepoints $trace_command "0x09999999ddbbbbbb < 0x09999999cccccccc" 0
+
+    test_tracepoints $trace_command "0x09999999bbbbbbbb <= 0x09999999bbbbbbbb" 10
+    test_tracepoints $trace_command "0x0aa99999bbbbbbbb <= 0x09999999bbbbbbbb" 0
+
+    test_tracepoints $trace_command "0x0aaaaaaaaaaaaaaa > 0x09999999bbbbbbbb" 10
+    test_tracepoints $trace_command "0x088aaaaabbaaaaaa > 0x09999999bbbbbbbb" 0
+
+    test_tracepoints $trace_command "(0xabababab00000000 == 0xcdcdcdcd00000000 ? 1 : 0) == 0" 10
+    test_tracepoints $trace_command "(0xcdcdcdcd00000000 == 0xcdcdcdcd00000000 ? 1 : 0) == 0" 0
+
+    test_tracepoints $trace_command "(0xabababab00000000 != 0xcdcdcdcd00000000 ? 1 : 0) == 1" 10
+    test_tracepoints $trace_command "(0xcdcdcdcd00000000 != 0xcdcdcdcd00000000 ? 1 : 0) == 1" 0
+
+    test_tracepoints $trace_command "(0x09999999bbbbbbbb < 0x09999999cccccccc ? 1 : 0) == 1" 10 18955_i386_failure
+    test_tracepoints $trace_command "(0x09999999eeebbbbb < 0x09999999cccccccc ? 1 : 0) == 1" 0 18955_i386_failure
+
+    test_tracepoints $trace_command "(0x09999999bbbbbbbb <= 0x09999999bbbbbbbb ? 1 : 0) == 1" 10
+    test_tracepoints $trace_command "(0x09999999eeebbbbb <= 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
+
+    test_tracepoints $trace_command "(0x09999999bbbbbbbb >= 0x09999999bbbbbbbb ? 1 : 0) == 1" 10
+    test_tracepoints $trace_command "(0x00099999bbbbbbbb >= 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
+
+    test_tracepoints $trace_command "(0x0aaaaaaaaaaaaaaa > 0x09999999bbbbbbbb ? 1 : 0) == 1" 10
+    test_tracepoints $trace_command "(0x00088888ccaaaaaa > 0x09999999bbbbbbbb ? 1 : 0) == 1" 0
 }
-- 
2.8.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 5/5 v3] Add tests for 64bit values in trace-condition.exp
  2016-05-30 14:50     ` [PATCH 5/5 v3] " Antoine Tremblay
@ 2016-05-30 15:06       ` Pedro Alves
  2016-05-30 16:55         ` Antoine Tremblay
  0 siblings, 1 reply; 16+ messages in thread
From: Pedro Alves @ 2016-05-30 15:06 UTC (permalink / raw)
  To: Antoine Tremblay, gdb-patches

OK.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5 v3] Add counter-cases for trace-condition.exp tests
  2016-05-30 14:48   ` [PATCH 1/5 v3] " Antoine Tremblay
@ 2016-05-30 15:06     ` Pedro Alves
  0 siblings, 0 replies; 16+ messages in thread
From: Pedro Alves @ 2016-05-30 15:06 UTC (permalink / raw)
  To: Antoine Tremblay, gdb-patches

On 05/30/2016 03:48 PM, Antoine Tremblay wrote:
> In this v3:
> 
> - Fixed test interleaving

Thanks, much more readable, IMO.

This is OK.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 5/5 v3] Add tests for 64bit values in trace-condition.exp
  2016-05-30 15:06       ` Pedro Alves
@ 2016-05-30 16:55         ` Antoine Tremblay
  0 siblings, 0 replies; 16+ messages in thread
From: Antoine Tremblay @ 2016-05-30 16:55 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Antoine Tremblay, gdb-patches


Pedro Alves writes:

> OK.
>
> Thanks,
> Pedro Alves

Patches 1-5 are pushed in.

Thanks,
Antoine

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-05-30 16:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-27 19:05 [PATCH 1/5] Add counter-cases for trace-condition.exp tests Antoine Tremblay
2016-05-27 19:05 ` [PATCH 4/5 v2] Add variable length tests for emit_ref in trace-condition.exp Antoine Tremblay
2016-05-30 11:02   ` Pedro Alves
2016-05-27 19:05 ` [PATCH 2/5 v2] Move trace conditions tests from ftrace.exp to trace-condition.exp Antoine Tremblay
2016-05-30 11:02   ` Pedro Alves
2016-05-27 19:05 ` [PATCH 5/5 v2] Add tests for 64bit values in trace-condition.exp Antoine Tremblay
2016-05-30 11:02   ` Pedro Alves
2016-05-30 14:50     ` [PATCH 5/5 v3] " Antoine Tremblay
2016-05-30 15:06       ` Pedro Alves
2016-05-30 16:55         ` Antoine Tremblay
2016-05-27 19:05 ` [PATCH 3/5 v2] Add emit_less_unsigned test " Antoine Tremblay
2016-05-30 11:02   ` Pedro Alves
2016-05-30 10:50 ` [PATCH 1/5] Add counter-cases for trace-condition.exp tests Pedro Alves
2016-05-30 14:20   ` Antoine Tremblay
2016-05-30 14:48   ` [PATCH 1/5 v3] " Antoine Tremblay
2016-05-30 15:06     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).