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