Commit | Line | Data |
---|---|---|
0b302171 | 1 | # Copyright 1992, 2004-2005, 2007-2012 Free Software Foundation, Inc. |
7be570e7 JM |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
7be570e7 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
7be570e7 JM |
8 | # This program is distributed in the hope that it will be useful, |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
e22f8b7c | 12 | # |
7be570e7 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
7be570e7 JM |
15 | |
16 | # Test case for CLLbs15503 | |
17 | # This file was written by Sue Kimura (sue_kimura@hp.com) | |
77c26ae3 | 18 | # Rewritten by Michael Chastain (mec.gnu@mindspring.com) |
7be570e7 | 19 | |
759f0f0b | 20 | if { [skip_stl_tests] } { continue } |
5f579bc5 | 21 | |
c1d88655 UW |
22 | # On SPU this test fails because the executable exceeds local storage size. |
23 | if { [istarget "spu*-*-*"] } { | |
24 | return 0 | |
25 | } | |
26 | ||
7be570e7 JM |
27 | set testfile "bs15503" |
28 | set srcfile ${testfile}.cc | |
29 | set binfile ${objdir}/${subdir}/${testfile} | |
30 | ||
afabe08c JL |
31 | if [get_compiler_info ${binfile}] { |
32 | return -1 | |
33 | } | |
34 | ||
7be570e7 | 35 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug c++"] != "" } { |
759f0f0b | 36 | untested bs15503.exp |
7be570e7 JM |
37 | return -1 |
38 | } | |
39 | ||
7be570e7 JM |
40 | gdb_exit |
41 | gdb_start | |
42 | gdb_reinitialize_dir $srcdir/$subdir | |
77c26ae3 | 43 | gdb_load ${binfile} |
7be570e7 | 44 | |
77c26ae3 MC |
45 | if ![runto_main] then { |
46 | perror "couldn't run to breakpoint" | |
47 | continue | |
7be570e7 | 48 | } |
77c26ae3 MC |
49 | |
50 | # Set breakpoint on template function | |
51 | ||
7be570e7 | 52 | gdb_test "break StringTest<wchar_t>::testFunction" \ |
77c26ae3 | 53 | "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal." |
7be570e7 | 54 | |
77c26ae3 MC |
55 | gdb_test "continue" \ |
56 | ".*Breakpoint $decimal, StringTest<wchar_t>::testFunction \\(this=$hex\\).*" \ | |
57 | "continue to StringTest<wchar_t>" | |
7be570e7 | 58 | |
77c26ae3 MC |
59 | # Run to some random point in the middle of the function. |
60 | ||
61 | gdb_breakpoint [gdb_get_line_number "find position where blank needs to be inserted"] | |
62 | gdb_continue_to_breakpoint "find position where blank needs to be inserted" | |
7be570e7 | 63 | |
77c26ae3 | 64 | # Call some string methods. |
7be570e7 | 65 | |
77c26ae3 MC |
66 | gdb_test "print s.length()" "\\$\[0-9\]+ = 42" |
67 | gdb_test "print s\[0\]" "\\$\[0-9\]+ =.* 'I'" | |
68 | gdb_test "print s\[s.length()-1\]" "\\$\[0-9\]+ =.* 'g'" | |
69 | gdb_test "print (const char *) s" \ | |
70 | "\\$\[0-9\]+ = $hex \"I am a short stringand now a longer string\"" | |
71 | ||
72 | # TODO: tests that do not work with gcc 2.95.3 | |
73 | # -- chastain 2004-01-07 | |
74 | # | |
75 | # gdb_test "print s.compare(s)" "\\$\[0-9\]+ = 0" | |
76 | # gdb_test "print s.compare(\"AAA\")" "\\$\[0-9\]+ = 1" | |
77 | # gdb_test "print s.compare(\"ZZZ\")" "\\$\[0-9\]+ = -1" | |
78 | ||
79 | # TODO: tests that do not work with gcc 2.95.3 and gcc 3.3.2. | |
80 | # cannot call overloaded non-member operator. -- chastain 2004-01-07 | |
81 | # | |
82 | # gdb_test "print s == s" "\\$\[0-9\]+ = true" | |
83 | # gdb_test "print s > "AAA" "\\$\[0-9\]+ = true" | |
84 | # gdb_test "print s < "ZZZ" "\\$\[0-9\]+ = true" | |
85 | ||
16963cb6 DJ |
86 | # TODO: GDB doesn't know to convert the string to a const char *, and |
87 | # instead tries to use the string as a structure initializer. | |
77c26ae3 MC |
88 | # |
89 | # gdb_test "print s == \"I am a short stringand now a longer string\"" \ | |
16963cb6 | 90 | # "\\$\[0-9\]+ = true" |
77c26ae3 MC |
91 | |
92 | gdb_test "print (const char *) s.substr(0,4)" "\\$\[0-9\]+ = $hex \"I am\"" | |
93 | gdb_test "print (const char *) (s=s.substr(0,4))" \ | |
94 | "\\$\[0-9\]+ = $hex \"I am\"" | |
95 | ||
96 | # TODO: cannot call overloaded non-member operator again. | |
97 | # -- chastain 2004-01-07 | |
98 | # | |
99 | # gdb_test "print (const char *) (s + s)" \ | |
100 | # "\\$\[0-9\]+ = $hex \"I amI am\"" | |
101 | # gdb_test "print (const char *) (s + \" \" + s)" \ | |
102 | # "\\$\[0-9\]+ = $hex \"I am I am\"" |