1 # Copyright (C) 1997-2024 Free Software Foundation, Inc.
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.
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.
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/>.
17 standard_testfile langs0.c langs1.c langs2.c
20 remote_download host ${srcdir}/${subdir}/langs1.f
21 remote_download host ${srcdir}/${subdir}/langs2.cxx
25 if {[prepare_for_testing "failed to prepare" ${testfile} \
26 [list $srcfile $srcfile2 $srcfile3] {debug}]} {
30 set oldtimeout $timeout
33 # Some tests require GCC.
34 set gcc_compiled [is_c_compiler_gcc]
36 gdb_test_multiple "b -qualified langs0" "break on nonexistent function" {
37 -re "Function \"langs0\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
39 gdb_test "n" "" "break on nonexistent function"
41 -re "Breakpoint .* (deferred).*$gdb_prompt $" {
42 pass "break on nonexistent function"
46 # TODO: Since there variables are now constants, we can cleanup the test,
47 # remove some dead code.
50 set do_func langs0__2do
54 if { !$isfixed } { set lang c }
55 gdb_test "show language" "currently $lang\".*" \
56 "show language at csub"
58 gdb_test "bt" "#0.*csub.*#1.*(foo|$foo_func) \\(.*#2.*cppsub_ .*#3.*fsub.*#4.*$do_func \\(.*#5 \[0-9a-fx\]* in main.*" "backtrace"
60 if { !$isfixed } { set lang c\\+\\+; set ext cxx }
61 if {!$gcc_compiled} { setup_xfail "rs6000-*-*" }
62 gdb_test "up" ".* in (foo|$foo_func).* at .*langs2\\.$ext.*return csub \\(.*" \
64 gdb_test "show language" "currently $lang.*" \
65 "show language at foo"
67 if {!$gcc_compiled} { setup_xfail "rs6000-*-*" }
68 gdb_test "up" ".* in cppsub_ .* at .*langs2\\.$ext.*return foo \\(.*" \
70 gdb_test "show language" "currently $lang.*" \
71 "show language at cppsub_"
73 if { !$isfixed } { set lang fortran }
74 if {!$gcc_compiled} { setup_xfail "rs6000-*-*" }
75 gdb_test "up" ".* in fsub.* at .*langs1\\.f.*" \
77 gdb_test "show language" "currently $lang.*" \
78 "show language at fsub"
80 if { !$isfixed } { set lang c }
81 gdb_test "up" ".* in $do_func .* at .*langs0\\.c.*return fsub.*" \
83 gdb_test "show language" "currently $lang\".*" \
84 "show language at langs0__2do"
86 gdb_test "up" ".* in main .* at .*langs0\\.c.*if \\(langs0__2do \\(.*" \
88 gdb_test "show language" "currently $lang\".*" \
89 "show language at main"
91 if [target_info exists gdb,noresults] { return }
93 gdb_continue_to_end "first session"
96 clean_restart $binfile
98 # Try exercising the "minimal" language a bit...
101 # Also test warn-language-frame-mismatch.
102 gdb_test_no_output "set warn-language-frame-mismatch off"
103 gdb_test_no_output "set lang minimal" "set lang to minimal"
105 gdb_test "print x" " = 5000" "print parameter value"
107 # Ensure this at least does not crash.
108 gdb_test_no_output "set language unknown"
110 "expression parsing not implemented for language .Unknown." \
111 "expression parsing does not crash for unknown"
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 }
117 if {!$gcc_compiled} { setup_xfail "rs6000-*-*" }
119 ".* in (foo|$foo_func).* at .*langs2\\.$ext.*return csub \\(.*Current language: auto.*" \
120 "up to foo when verbose"
123 set timeout $oldtimeout