]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/gdb.base/structs.exp
Updated copyright notices for most files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / structs.exp
index 5c4d4adfdcd2087e40d4c39383dc19ca299107fb..edc8d4220e6e28930ece4a0cb270bff88e0161be 100644 (file)
@@ -1,20 +1,20 @@
 # This testcase is part of GDB, the GNU debugger.
 
-# Copyright 1996, 1997, 1999, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 1996, 1997, 1999, 2003, 2004, 2007, 2008
+# 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
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Please email any bugs, comments, and/or additions to this file to:
 # bug-gdb@prep.ai.mit.edu
@@ -76,7 +76,8 @@ proc start_structs_test { types } {
        # built the second test case since we can't use prototypes
        warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
        if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags} additional_flags=-DNO_PROTOTYPES"] != "" } {
-           gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+           untested structs.exp
+           return -1
        }
     }
 
@@ -162,6 +163,29 @@ proc zed { n } {
     } $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]
+}
+
 # Given N (0..25), return the corresponding alphabetic letter in lower
 # or upper case.  This is ment to be i18n proof.
 
@@ -218,7 +242,8 @@ proc test_struct_calls { n } {
     set tests "call $n ${testfile}"
 
     # Call fun${n}, checking the printed return-value.
-    setup_compiler_kfails structs-tc-* gcc-3-3 "DWARF 2" i*86-*-* gdb/1455
+    setup_compiler_kfails structs-tc-tll gcc-3-3-* "DWARF 2" i*86-*-* gdb/1455
+    setup_compiler_kfails structs-tc-td gcc-3-3-* "DWARF 2" i*86-*-* gdb/1455
     gdb_test "p/c fun${n}()"  "[foo ${n}]" "p/c fun<n>(); ${tests}"
 
     # Check that GDB can always pass a structure to an inferior function.
@@ -229,7 +254,8 @@ proc test_struct_calls { n } {
     # examining that global to confirm that the value is as expected.
 
     gdb_test "call Fun${n}(foo${n})" "" "call Fun<n>(foo<n>); ${tests}"
-    setup_compiler_kfails structs-tc-* gcc-3-3 "DWARF 2" i*86-*-* gdb/1455
+    setup_compiler_kfails structs-tc-tll gcc-3-3-* "DWARF 2" i*86-*-* gdb/1455
+    setup_compiler_kfails structs-tc-td gcc-3-3-* "DWARF 2" i*86-*-* gdb/1455
     gdb_test "p/c L${n}" [foo ${n}] "p/c L<n>; ${tests}"
 }
 
@@ -328,28 +354,43 @@ proc test_struct_returns { n } {
     # Check that the return-value is as expected.  At this stage we're
     # just checking that GDB has returned a value consistent with
     # "return_value_known" set above.
+    #
+    # Note that, when return_value_known is false, we can't make any
+    # assumptions at all about the value L<n>:
+    #
+    # - If the caller passed the address of L<n> directly as fun<n>'s
+    #   return value buffer, then L<n> will be unchanged, because we
+    #   forced fun<n> to return before it could store anything in it.
+    #
+    # - If the caller passed the address of some temporary buffer to
+    #   fun<n>, and then copied the buffer into L<n>, then L<n> will
+    #   have been overwritten with whatever garbage was in the
+    #   uninitialized buffer.
+    #
+    # - However, if the temporary buffer just happened to have the
+    #   "right" value of foo<n> in it, then L<n> will, in fact, have
+    #   the value you'd expect to see if the 'return' had worked!
+    #   This has actually been observed to happen on the Renesas M32C.
+    #
+    # So, really, anything is acceptable unless return_value_known is
+    # true.
 
     set test "value foo<n> returned; ${tests}"
     gdb_test_multiple "p/c L${n}" "${test}" {
        -re " = [foo ${n}].*${gdb_prompt} $" {
-           if $return_value_known {
-               pass "${test}"
-               # This contradicts the above claim that GDB didn't
-               # know the location of the return-value.
-           } else {
-               fail "${test}"
-           }
+            # This answer is okay regardless of whether GDB claims to
+            # have set the return value: if it did, then this is what
+            # we expected; and if it didn't, then any answer is okay.
+            pass "${test}"
        }
-       -re " = [zed ${n}].*${gdb_prompt} $" {
+       -re " = [any $n].*${gdb_prompt} $" {
            if $return_value_known {
                # This contradicts the above claim that GDB knew
-               # the location of the return-value.
+               # the location of the return value.
                fail "${test}"
            } else {
-               # The struct return case.  Since any modification
-               # would be by reference, and that can't happen, the
-               # value should be unmodified and hence Z is expected.
-               # Is this a reasonable assumption?
+                # We expected L${n} to be set to garbage, so any
+                # answer is acceptable.
                pass "${test}"
            }
        }