]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/langs.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / langs.exp
CommitLineData
1d506c26 1# Copyright (C) 1997-2024 Free Software Foundation, Inc.
c906108c
SS
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
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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#
c906108c 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/>.
c906108c 15
c906108c 16
f8b41b00 17standard_testfile langs0.c langs1.c langs2.c
c906108c
SS
18
19if [is_remote host] {
20 remote_download host ${srcdir}/${subdir}/langs1.f
21 remote_download host ${srcdir}/${subdir}/langs2.cxx
22}
23
24
5b362f04 25if {[prepare_for_testing "failed to prepare" ${testfile} \
f8b41b00
TT
26 [list $srcfile $srcfile2 $srcfile3] {debug}]} {
27 return -1
c906108c
SS
28}
29
085dd6e6
JM
30set oldtimeout $timeout
31set timeout 10
c906108c 32
ef7a6b97
AB
33# Some tests require GCC.
34set gcc_compiled [is_c_compiler_gcc]
c906108c 35
2939f92a 36gdb_test_multiple "b -qualified langs0" "break on nonexistent function" {
9b50c11b 37 -re "Function \"langs0\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
18fe2033 38
2939f92a 39 gdb_test "n" "" "break on nonexistent function"
18fe2033
JJ
40 }
41 -re "Breakpoint .* (deferred).*$gdb_prompt $" {
2939f92a 42 pass "break on nonexistent function"
18fe2033
JJ
43 }
44}
c906108c 45
b6304613
SM
46# TODO: Since there variables are now constants, we can cleanup the test,
47# remove some dead code.
48set isfixed 0
49set foo_func foo__Fi
50set do_func langs0__2do
085dd6e6 51
65a33d75 52if {[runto csub]} {
c906108c 53
085dd6e6
JM
54 if { !$isfixed } { set lang c }
55 gdb_test "show language" "currently $lang\".*" \
2939f92a 56 "show language at csub"
b6304613 57
2939f92a 58 gdb_test "bt" "#0.*csub.*#1.*(foo|$foo_func) \\(.*#2.*cppsub_ .*#3.*fsub.*#4.*$do_func \\(.*#5 \[0-9a-fx\]* in main.*" "backtrace"
c906108c 59
085dd6e6 60 if { !$isfixed } { set lang c\\+\\+; set ext cxx }
65a33d75 61 if {!$gcc_compiled} { setup_xfail "rs6000-*-*" }
d8504344 62 gdb_test "up" ".* in (foo|$foo_func).* at .*langs2\\.$ext.*return csub \\(.*" \
2939f92a 63 "up to foo"
085dd6e6 64 gdb_test "show language" "currently $lang.*" \
2939f92a 65 "show language at foo"
c906108c 66
65a33d75 67 if {!$gcc_compiled} { setup_xfail "rs6000-*-*" }
d8504344 68 gdb_test "up" ".* in cppsub_ .* at .*langs2\\.$ext.*return foo \\(.*" \
2939f92a 69 "up to cppsub_"
085dd6e6 70 gdb_test "show language" "currently $lang.*" \
2939f92a 71 "show language at cppsub_"
c906108c 72
085dd6e6 73 if { !$isfixed } { set lang fortran }
65a33d75 74 if {!$gcc_compiled} { setup_xfail "rs6000-*-*" }
d8504344 75 gdb_test "up" ".* in fsub.* at .*langs1\\.f.*" \
2939f92a 76 "up to fsub"
085dd6e6 77 gdb_test "show language" "currently $lang.*" \
2939f92a 78 "show language at fsub"
c906108c 79
085dd6e6
JM
80 if { !$isfixed } { set lang c }
81 gdb_test "up" ".* in $do_func .* at .*langs0\\.c.*return fsub.*" \
2939f92a 82 "up to langs0__2do"
085dd6e6 83 gdb_test "show language" "currently $lang\".*" \
2939f92a 84 "show language at langs0__2do"
c906108c
SS
85
86 gdb_test "up" ".* in main .* at .*langs0\\.c.*if \\(langs0__2do \\(.*" \
2939f92a 87 "up to main"
085dd6e6 88 gdb_test "show language" "currently $lang\".*" \
2939f92a 89 "show language at main"
c906108c
SS
90
91 if [target_info exists gdb,noresults] { return }
92
2939f92a 93 gdb_continue_to_end "first session"
c906108c
SS
94}
95
c95d486d 96clean_restart $binfile
f125c9a4
JB
97
98# Try exercising the "minimal" language a bit...
99
65a33d75 100if {[runto csub]} {
f125c9a4
JB
101 gdb_test "set lang minimal" \
102 "Warning: the current language does not match this frame." \
103 "set lang to minimal"
104
105 gdb_test "print x" " = 5000" "print parameter value"
dcd482c1
TT
106
107 # Ensure this at least does not crash.
108 gdb_test_no_output "set language unknown"
109 gdb_test "print x" \
110 "expression parsing not implemented for language .Unknown." \
111 "expression parsing does not crash for unknown"
5220f61a
TT
112
113 gdb_test_no_output "set lang auto" \
114 "set lang back to auto for verbose test"
115 gdb_test_no_output "set verbose on"
116 if { !$isfixed } { set lang c\\+\\+; set ext cxx }
65a33d75 117 if {!$gcc_compiled} { setup_xfail "rs6000-*-*" }
5220f61a
TT
118 gdb_test "up" \
119 ".* in (foo|$foo_func).* at .*langs2\\.$ext.*return csub \\(.*Current language: auto.*" \
2939f92a 120 "up to foo when verbose"
f125c9a4
JB
121}
122
085dd6e6 123set timeout $oldtimeout