Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] testcase: Fix spurious structs.exp FAILs
@ 2009-11-29 13:50 Jan Kratochvil
  2009-12-01 20:46 ` Tom Tromey
  2009-12-21  5:52 ` Joel Brobecker
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Kratochvil @ 2009-11-29 13:50 UTC (permalink / raw)
  To: gdb-patches

Hi,

There were some rare unreproducible fuzzy FAILs seen on i386 (32-bit) inferiors:

 return foo2
 The location at which to store the function's return value is unknown.
 If you continue, the return value that you specified will be ignored.
 Make fun2 return now? (y or n) y
 #0  main () at /rpmbuild/BUILD/gdb-7.0/gdb/testsuite/gdb.base/structs.c:435
 435          L2  = fun2();     
 (gdb) next
 436          L3  = fun3();     
 (gdb) PASS: gdb.base/structs.exp: return foo<n>; return 2 structs-tf-td
 p/c L2
-$4 = {a = -16 '\360', b = 0 '\000'}
-(gdb) PASS: gdb.base/structs.exp: value foo<n> returned; return 2 structs-tf-td
+$4 = {a = 44 ',', b = 0 '\000'}
+(gdb) FAIL: gdb.base/structs.exp: value foo<n> returned; return 2 structs-tf-td

Apparently
	a = 44 ',',
does not match
	a = \[^,\}\]*,
which is needed for cases where L2 (L*) remains uninitialized with random
content.

Alternative patch would just use regex `.*' and the whole new `chartest' and
`anychar_re' parts can be dropped.

Formerly 9s, now 11s, without the $first optimization it would cost 47s.

Testcase has been run on {x86_64,x86_64-m32}-fedora12-linux-gnu.


Thanks,
Jan


gdb/testsuite/
2009-11-29  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix spurious false FAILs.
	* gdb.base/structs.c (chartest): New.
	(main): Fill-in chartest.
	* gdb.base/structs.exp (anychar_re, first): New.
	(start_structs_test): Import global anychar_re and first.
	New gdb_test call "set print elements 300; ${testfile}"
	(start_structs_test <$first>): New block.
	(any): Import global anychar_re.  New variable ac.  Use ${ac}.

--- a/gdb/testsuite/gdb.base/structs.c
+++ b/gdb/testsuite/gdb.base/structs.c
@@ -396,6 +396,8 @@ zed ()
   L18.r = 'Z';
 }
 
+static struct { char c; } chartest[256];
+
 int main()
 {
 #ifdef usestubs
@@ -404,6 +406,10 @@ int main()
 #endif
   int i;
 
+  for (i = 0; i < 256; i++)
+    chartest[i].c = i;
+  chartest[0].c = 0;  /* chartest-done */
+
   Fun1(foo1);	
   Fun2(foo2);	
   Fun3(foo3);	
--- a/gdb/testsuite/gdb.base/structs.exp
+++ b/gdb/testsuite/gdb.base/structs.exp
@@ -36,6 +36,9 @@ set testfile "structs"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
 
+# Regex matching any value of `char' type like: a = 65 'A'
+set anychar_re {-?[0-9]{1,3} '(.|\\([0-7]{3}|[a-z]|\\|'))'}
+
 # Create and source the file that provides information about the
 # compiler used to compile the test case.
 
@@ -48,6 +51,7 @@ if [get_compiler_info ${binfile}] {
 # the last TYPES field).  Run the compmiled program up to "main".
 # Also updates the global "testfile" to reflect the most recent build.
 
+set first 1
 proc start_structs_test { types } {
     global testfile
     global srcfile
@@ -56,6 +60,8 @@ proc start_structs_test { types } {
     global subdir
     global srcdir
     global gdb_prompt
+    global anychar_re
+    global first
 
     # Create the additional flags
     set flags "debug"
@@ -91,6 +97,8 @@ proc start_structs_test { types } {
 	    "set print address off; ${testfile}"
     gdb_test "set width 0" "" \
 	    "set width 0; ${testfile}"
+    gdb_test "set print elements 300" "" \
+	    "set print elements 300; ${testfile}"
 
     # Advance to main
     if { ![runto_main] } then {
@@ -100,6 +108,16 @@ proc start_structs_test { types } {
     # Get the debug format
     get_debug_format
 
+    # Limit the slow $anychar_re{256} matching for better performance.
+    if $first {
+	set first 0
+
+	# Verify $anychar_re can match all the values of `char' type.
+	gdb_breakpoint [gdb_get_line_number "chartest-done"]
+	gdb_continue_to_breakpoint "chartest-done" ".*chartest-done.*"
+	gdb_test "p chartest" "= {({c = ${anychar_re}}, ){255}{c = ${anychar_re}}}"
+    }
+
     # check that at the struct containing all the relevant types is correct
     set foo_t "type = struct struct[llength ${types}] \{"
     for {set n 0} {$n<[llength ${types}]} {incr n} {
@@ -161,26 +179,28 @@ proc zed { n } {
 }
 
 proc any { n } {
-    return [lindex {
-	"{}"
-	"{a = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*, p = \[^,\}\]*}"
-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*, p = \[^,\}\]*, q = \[^,\}\]*}"
-    } $n]
+    global anychar_re
+    set ac $anychar_re
+    return [lindex [list \
+	"{}" \
+	"{a = ${ac}}" \
+	"{a = ${ac}, b = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}, o = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}, o = ${ac}, p = ${ac}}" \
+	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}, o = ${ac}, p = ${ac}, q = ${ac}}" \
+    ] $n]
 }
 
 # Given N (0..25), return the corresponding alphabetic letter in lower


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

* Re: [patch] testcase: Fix spurious structs.exp FAILs
  2009-11-29 13:50 [patch] testcase: Fix spurious structs.exp FAILs Jan Kratochvil
@ 2009-12-01 20:46 ` Tom Tromey
  2009-12-03 11:41   ` Jan Kratochvil
  2009-12-21  5:52 ` Joel Brobecker
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2009-12-01 20:46 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> gdb/testsuite/
Jan> 2009-11-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan> 	Fix spurious false FAILs.
Jan> 	* gdb.base/structs.c (chartest): New.
Jan> 	(main): Fill-in chartest.
Jan> 	* gdb.base/structs.exp (anychar_re, first): New.
Jan> 	(start_structs_test): Import global anychar_re and first.
Jan> 	New gdb_test call "set print elements 300; ${testfile}"
Jan> 	(start_structs_test <$first>): New block.
Jan> 	(any): Import global anychar_re.  New variable ac.  Use ${ac}.

Ok.

Tom


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

* Re: [patch] testcase: Fix spurious structs.exp FAILs
  2009-12-01 20:46 ` Tom Tromey
@ 2009-12-03 11:41   ` Jan Kratochvil
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2009-12-03 11:41 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Tue, 01 Dec 2009 21:45:56 +0100, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> Jan> gdb/testsuite/
> Jan> 2009-11-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
> Jan> 	Fix spurious false FAILs.
> Jan> 	* gdb.base/structs.c (chartest): New.
> Jan> 	(main): Fill-in chartest.
> Jan> 	* gdb.base/structs.exp (anychar_re, first): New.
> Jan> 	(start_structs_test): Import global anychar_re and first.
> Jan> 	New gdb_test call "set print elements 300; ${testfile}"
> Jan> 	(start_structs_test <$first>): New block.
> Jan> 	(any): Import global anychar_re.  New variable ac.  Use ${ac}.
> 
> Ok.

Checked-in:
	http://sourceware.org/ml/gdb-cvs/2009-12/msg00013.html


Thanks,
Jan


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

* Re: [patch] testcase: Fix spurious structs.exp FAILs
  2009-11-29 13:50 [patch] testcase: Fix spurious structs.exp FAILs Jan Kratochvil
  2009-12-01 20:46 ` Tom Tromey
@ 2009-12-21  5:52 ` Joel Brobecker
  1 sibling, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2009-12-21  5:52 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> gdb/testsuite/
> 2009-11-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	Fix spurious false FAILs.
> 	* gdb.base/structs.c (chartest): New.
> 	(main): Fill-in chartest.
> 	* gdb.base/structs.exp (anychar_re, first): New.
> 	(start_structs_test): Import global anychar_re and first.
> 	New gdb_test call "set print elements 300; ${testfile}"
> 	(start_structs_test <$first>): New block.
> 	(any): Import global anychar_re.  New variable ac.  Use ${ac}.

FYI: Checked in the gdb-7.0 branch.


-- 
Joel


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

end of thread, other threads:[~2009-12-21  5:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-29 13:50 [patch] testcase: Fix spurious structs.exp FAILs Jan Kratochvil
2009-12-01 20:46 ` Tom Tromey
2009-12-03 11:41   ` Jan Kratochvil
2009-12-21  5:52 ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox