]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.cp/bs15503.exp
gdb/
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / bs15503.exp
1 # Copyright 1992, 2004, 2005 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17 # Test case for CLLbs15503
18 # This file was written by Sue Kimura (sue_kimura@hp.com)
19 # Rewritten by Michael Chastain (mec.gnu@mindspring.com)
20
21 if $tracelevel {
22 strace $tracelevel
23 }
24
25 if { [skip_cplus_tests] } { continue }
26
27 set testfile "bs15503"
28 set srcfile ${testfile}.cc
29 set binfile ${objdir}/${subdir}/${testfile}
30
31 if [get_compiler_info ${binfile}] {
32 return -1
33 }
34
35 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug c++"] != "" } {
36 perror "Couldn't compile ${srcfile}"
37 return -1
38 }
39
40 gdb_exit
41 gdb_start
42 gdb_reinitialize_dir $srcdir/$subdir
43 gdb_load ${binfile}
44
45 if ![runto_main] then {
46 perror "couldn't run to breakpoint"
47 continue
48 }
49
50 # Set breakpoint on template function
51
52 gdb_test "break StringTest<wchar_t>::testFunction" \
53 "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal."
54
55 gdb_test "continue" \
56 ".*Breakpoint $decimal, StringTest<wchar_t>::testFunction \\(this=$hex\\).*" \
57 "continue to StringTest<wchar_t>"
58
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"
63
64 # Call some string methods.
65
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
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.
88 #
89 # gdb_test "print s == \"I am a short stringand now a longer string\"" \
90 # "\\$\[0-9\]+ = true"
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\""