Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 1992, 2004, 2005, 2007 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 JM |
19 | |
20 | if $tracelevel { | |
21 | strace $tracelevel | |
22 | } | |
23 | ||
5f579bc5 NS |
24 | if { [skip_cplus_tests] } { continue } |
25 | ||
c1d88655 UW |
26 | # On SPU this test fails because the executable exceeds local storage size. |
27 | if { [istarget "spu*-*-*"] } { | |
28 | return 0 | |
29 | } | |
30 | ||
7be570e7 JM |
31 | set testfile "bs15503" |
32 | set srcfile ${testfile}.cc | |
33 | set binfile ${objdir}/${subdir}/${testfile} | |
34 | ||
afabe08c JL |
35 | if [get_compiler_info ${binfile}] { |
36 | return -1 | |
37 | } | |
38 | ||
7be570e7 JM |
39 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug c++"] != "" } { |
40 | perror "Couldn't compile ${srcfile}" | |
41 | return -1 | |
42 | } | |
43 | ||
7be570e7 JM |
44 | gdb_exit |
45 | gdb_start | |
46 | gdb_reinitialize_dir $srcdir/$subdir | |
77c26ae3 | 47 | gdb_load ${binfile} |
7be570e7 | 48 | |
77c26ae3 MC |
49 | if ![runto_main] then { |
50 | perror "couldn't run to breakpoint" | |
51 | continue | |
7be570e7 | 52 | } |
77c26ae3 MC |
53 | |
54 | # Set breakpoint on template function | |
55 | ||
7be570e7 | 56 | gdb_test "break StringTest<wchar_t>::testFunction" \ |
77c26ae3 | 57 | "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal." |
7be570e7 | 58 | |
77c26ae3 MC |
59 | gdb_test "continue" \ |
60 | ".*Breakpoint $decimal, StringTest<wchar_t>::testFunction \\(this=$hex\\).*" \ | |
61 | "continue to StringTest<wchar_t>" | |
7be570e7 | 62 | |
77c26ae3 MC |
63 | # Run to some random point in the middle of the function. |
64 | ||
65 | gdb_breakpoint [gdb_get_line_number "find position where blank needs to be inserted"] | |
66 | gdb_continue_to_breakpoint "find position where blank needs to be inserted" | |
7be570e7 | 67 | |
77c26ae3 | 68 | # Call some string methods. |
7be570e7 | 69 | |
77c26ae3 MC |
70 | gdb_test "print s.length()" "\\$\[0-9\]+ = 42" |
71 | gdb_test "print s\[0\]" "\\$\[0-9\]+ =.* 'I'" | |
72 | gdb_test "print s\[s.length()-1\]" "\\$\[0-9\]+ =.* 'g'" | |
73 | gdb_test "print (const char *) s" \ | |
74 | "\\$\[0-9\]+ = $hex \"I am a short stringand now a longer string\"" | |
75 | ||
76 | # TODO: tests that do not work with gcc 2.95.3 | |
77 | # -- chastain 2004-01-07 | |
78 | # | |
79 | # gdb_test "print s.compare(s)" "\\$\[0-9\]+ = 0" | |
80 | # gdb_test "print s.compare(\"AAA\")" "\\$\[0-9\]+ = 1" | |
81 | # gdb_test "print s.compare(\"ZZZ\")" "\\$\[0-9\]+ = -1" | |
82 | ||
83 | # TODO: tests that do not work with gcc 2.95.3 and gcc 3.3.2. | |
84 | # cannot call overloaded non-member operator. -- chastain 2004-01-07 | |
85 | # | |
86 | # gdb_test "print s == s" "\\$\[0-9\]+ = true" | |
87 | # gdb_test "print s > "AAA" "\\$\[0-9\]+ = true" | |
88 | # gdb_test "print s < "ZZZ" "\\$\[0-9\]+ = true" | |
89 | ||
16963cb6 DJ |
90 | # TODO: GDB doesn't know to convert the string to a const char *, and |
91 | # instead tries to use the string as a structure initializer. | |
77c26ae3 MC |
92 | # |
93 | # gdb_test "print s == \"I am a short stringand now a longer string\"" \ | |
16963cb6 | 94 | # "\\$\[0-9\]+ = true" |
77c26ae3 MC |
95 | |
96 | gdb_test "print (const char *) s.substr(0,4)" "\\$\[0-9\]+ = $hex \"I am\"" | |
97 | gdb_test "print (const char *) (s=s.substr(0,4))" \ | |
98 | "\\$\[0-9\]+ = $hex \"I am\"" | |
99 | ||
100 | # TODO: cannot call overloaded non-member operator again. | |
101 | # -- chastain 2004-01-07 | |
102 | # | |
103 | # gdb_test "print (const char *) (s + s)" \ | |
104 | # "\\$\[0-9\]+ = $hex \"I amI am\"" | |
105 | # gdb_test "print (const char *) (s + \" \" + s)" \ | |
106 | # "\\$\[0-9\]+ = $hex \"I am I am\"" |