Index: gdb/testsuite/gdb.base/bitfields.exp |
diff --git a/gdb/testsuite/gdb.base/bitfields.exp b/gdb/testsuite/gdb.base/bitfields.exp |
index f5777d68629e32000d3f1898fa388c96aadc66d2..ceba529892c1ae73e26977cec0b2bb923db740d7 100644 |
--- a/gdb/testsuite/gdb.base/bitfields.exp |
+++ b/gdb/testsuite/gdb.base/bitfields.exp |
@@ -1,5 +1,4 @@ |
-# Copyright 1992, 1994-1995, 1997, 2007-2012 Free Software Foundation, |
-# Inc. |
+# Copyright 1992-2013 Free Software Foundation, Inc. |
# This program is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by |
@@ -17,11 +16,10 @@ |
# This file was written by Fred Fish. (fnf@cygnus.com) |
-set testfile "bitfields" |
-set srcfile ${testfile}.c |
-set binfile ${objdir}/${subdir}/${testfile} |
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
- untested bitfields.exp |
+standard_testfile |
+ |
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { |
+ untested $testfile.exp |
return -1 |
} |
@@ -38,48 +36,48 @@ proc bitfield_uniqueness {} { |
global srcfile |
if { ! [runto break1] } { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "print flags" ".*uc = 1 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #1"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
# Note that we check for s1 as either 1 or -1, so that failure to |
# treat it correctly as a signed 1bit field (values 0 or -1) while |
# printing its value does not cause a spurious failure. We do the |
# signedness preservation test later. |
if [gdb_test "print flags" ".*uc = 0 .*, s1 = (1|-1), u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (s1)"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #2"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 1, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (u1)"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #3"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 1, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (s2)"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #4"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 1, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (u2)"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #5"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 1, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (s3)"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #6"] { |
- gdb_suppress_tests; |
+ gdb_suppress_tests |
} |
if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 1, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (u3)"] { |
gdb_suppress_tests |
@@ -103,7 +101,7 @@ proc bitfield_uniqueness {} { |
gdb_suppress_tests |
} |
# Hmmmm? |
- gdb_stop_suppressing_tests; |
+ gdb_stop_suppressing_tests |
} |
@@ -139,7 +137,7 @@ proc bitfield_containment {} { |
if [gdb_test "print/x flags" "= {uc = 0x0, s1 = 0x(1|f*), u1 = 0x0, s2 = 0x(3|f*), u2 = 0x0, s3 = 0x(7|f*), u3 = 0x0, s9 = 0x(1ff|f*), u9 = 0x0, sc = 0xff}" "bitfield containment #2"] { |
gdb_suppress_tests |
} |
- gdb_stop_suppressing_tests; |
+ gdb_stop_suppressing_tests |
} |
# Test unsigned bitfields for unsignedness and range. |
@@ -161,7 +159,7 @@ proc bitfield_unsignedness {} { |
if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 1, s2 = 0, u2 = 3, s3 = 0, u3 = 7, s9 = 0, u9 = 511, sc = 0.*" "unsigned bitfield ranges"] { |
gdb_suppress_tests |
} |
- gdb_stop_suppressing_tests; |
+ gdb_stop_suppressing_tests |
} |
# |
@@ -206,8 +204,8 @@ proc bitfield_signedness {} { |
gdb_suppress_tests |
} |
default { |
- fail "determining signed-ness of bitfields" ; |
- gdb_suppress_tests; |
+ fail "determining signed-ness of bitfields" |
+ gdb_suppress_tests |
} |
} |
@@ -223,7 +221,7 @@ proc bitfield_signedness {} { |
gdb_suppress_tests |
} |
# Hmmmm??? |
- gdb_stop_suppressing_tests; |
+ gdb_stop_suppressing_tests |
} |
# Test bitfields at non-zero offsets in a struct. |
@@ -246,9 +244,30 @@ proc bitfield_at_offset {} { |
gdb_test "print container.two.u3" ".* = 3" |
} |
-gdb_start |
-gdb_reinitialize_dir $srcdir/$subdir |
-gdb_load ${binfile} |
+proc bitfield_internalvar {} { |
+ global gdb_prompt |
+ |
+ # First, we create an internal var holding an instance of |
+ # the struct (zeroed out). |
+ gdb_test "set \$myvar = (struct internalvartest) \{0\}" "" \ |
+ "set internal var" |
+ |
+ # Now, we set the proper bits. |
+ gdb_test_no_output "set \$myvar.a = 0" |
+ gdb_test_no_output "set \$myvar.inner.b = 1" |
+ gdb_test_no_output "set \$myvar.inner.deep.c = 0" |
+ gdb_test_no_output "set \$myvar.inner.deep.d = -1" |
+ gdb_test_no_output "set \$myvar.inner.e = 1" |
+ gdb_test_no_output "set \$myvar.f = 1" |
+ |
+ # Here comes the true testing. |
+ gdb_test "print \$myvar.a" "\\$\[0-9\]\+ = 0" |
+ gdb_test "print \$myvar.inner.b" "\\$\[0-9\]\+ = 1" |
+ gdb_test "print \$myvar.inner.deep.c" "\\$\[0-9\]\+ = 0" |
+ gdb_test "print \$myvar.inner.deep.d" "\\$\[0-9\]\+ = -1" |
+ gdb_test "print \$myvar.inner.e" "\\$\[0-9\]\+ = -1" |
+ gdb_test "print \$myvar.f" "\\$\[0-9\]\+ = -1" |
+} |
gdb_test_no_output "set print sevenbit-strings" |
@@ -257,3 +276,4 @@ bitfield_containment |
bitfield_unsignedness |
bitfield_signedness |
bitfield_at_offset |
+bitfield_internalvar |