1# Copyright 1992, 2004, 2005, 2007 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 3 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, see <http://www.gnu.org/licenses/>. */ 15 16# Test case for CLLbs15503 17# This file was written by Sue Kimura (sue_kimura@hp.com) 18# Rewritten by Michael Chastain (mec.gnu@mindspring.com) 19 20if $tracelevel { 21 strace $tracelevel 22} 23 24if { [skip_cplus_tests] } { continue } 25 26# On SPU this test fails because the executable exceeds local storage size. 27if { [istarget "spu*-*-*"] } { 28 return 0 29} 30 31set testfile "bs15503" 32set srcfile ${testfile}.cc 33set binfile ${objdir}/${subdir}/${testfile} 34 35if [get_compiler_info ${binfile}] { 36 return -1 37} 38 39if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug c++"] != "" } { 40 perror "Couldn't compile ${srcfile}" 41 return -1 42} 43 44gdb_exit 45gdb_start 46gdb_reinitialize_dir $srcdir/$subdir 47gdb_load ${binfile} 48 49if ![runto_main] then { 50 perror "couldn't run to breakpoint" 51 continue 52} 53 54# Set breakpoint on template function 55 56gdb_test "break StringTest<wchar_t>::testFunction" \ 57 "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal." 58 59gdb_test "continue" \ 60 ".*Breakpoint $decimal, StringTest<wchar_t>::testFunction \\(this=$hex\\).*" \ 61 "continue to StringTest<wchar_t>" 62 63# Run to some random point in the middle of the function. 64 65gdb_breakpoint [gdb_get_line_number "find position where blank needs to be inserted"] 66gdb_continue_to_breakpoint "find position where blank needs to be inserted" 67 68# Call some string methods. 69 70gdb_test "print s.length()" "\\$\[0-9\]+ = 42" 71gdb_test "print s\[0\]" "\\$\[0-9\]+ =.* 'I'" 72gdb_test "print s\[s.length()-1\]" "\\$\[0-9\]+ =.* 'g'" 73gdb_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 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. 92# 93# gdb_test "print s == \"I am a short stringand now a longer string\"" \ 94# "\\$\[0-9\]+ = true" 95 96gdb_test "print (const char *) s.substr(0,4)" "\\$\[0-9\]+ = $hex \"I am\"" 97gdb_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\"" 107