Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / langs.exp
1 # Copyright (C) 1997-2022 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
17 standard_testfile langs0.c langs1.c langs2.c
18
19 if [is_remote host] {
20 remote_download host ${srcdir}/${subdir}/langs1.f
21 remote_download host ${srcdir}/${subdir}/langs2.cxx
22 }
23
24
25 if {[prepare_for_testing "failed to prepare" ${testfile} \
26 [list $srcfile $srcfile2 $srcfile3] {debug}]} {
27 return -1
28 }
29
30 set oldtimeout $timeout
31 set timeout 10
32
33
34
35 # Create and source the file that provides information about the compiler
36 # used to compile the test case.
37 if [get_compiler_info] {
38 return -1
39 }
40
41 gdb_test_multiple "b -qualified langs0" "break on nonexistent function in langs.exp" {
42 -re "Function \"langs0\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
43
44 gdb_test "n" "" "break on nonexistent function in langs.exp"
45 }
46 -re "Breakpoint .* (deferred).*$gdb_prompt $" {
47 pass "break on nonexistent function in langs.exp"
48 }
49 }
50
51 # TODO: Since there variables are now constants, we can cleanup the test,
52 # remove some dead code.
53 set isfixed 0
54 set foo_func foo__Fi
55 set do_func langs0__2do
56
57 if [runto csub] then {
58
59 if { !$isfixed } { set lang c }
60 gdb_test "show language" "currently $lang\".*" \
61 "show language at csub in langs.exp"
62
63 gdb_test "bt" "#0.*csub.*#1.*(foo|$foo_func) \\(.*#2.*cppsub_ .*#3.*fsub.*#4.*$do_func \\(.*#5 \[0-9a-fx\]* in main.*" "backtrace in langs.exp"
64
65 if { !$isfixed } { set lang c\\+\\+; set ext cxx }
66 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
67 gdb_test "up" ".* in (foo|$foo_func).* at langs2\\.$ext.*return csub \\(.*" \
68 "up to foo in langs.exp"
69 gdb_test "show language" "currently $lang.*" \
70 "show language at foo in langs.exp"
71
72 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
73 gdb_test "up" ".* in cppsub_ .* at langs2\\.$ext.*return foo \\(.*" \
74 "up to cppsub_ in langs.exp"
75 gdb_test "show language" "currently $lang.*" \
76 "show language at cppsub_ in langs.exp"
77
78 if { !$isfixed } { set lang fortran }
79 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
80 gdb_test "up" ".* in fsub.* at langs1\\.f.*" \
81 "up to fsub in langs.exp"
82 gdb_test "show language" "currently $lang.*" \
83 "show language at fsub in langs.exp"
84
85 if { !$isfixed } { set lang c }
86 gdb_test "up" ".* in $do_func .* at .*langs0\\.c.*return fsub.*" \
87 "up to langs0__2do in langs.exp"
88 gdb_test "show language" "currently $lang\".*" \
89 "show language at langs0__2do in langs.exp"
90
91 gdb_test "up" ".* in main .* at .*langs0\\.c.*if \\(langs0__2do \\(.*" \
92 "up to main in langs.exp"
93 gdb_test "show language" "currently $lang\".*" \
94 "show language at main in langs.exp"
95
96 if [target_info exists gdb,noresults] { return }
97
98 gdb_continue_to_end "langs.exp"
99 }
100
101 gdb_exit
102 gdb_start
103 gdb_reinitialize_dir $srcdir/$subdir
104 gdb_load $binfile
105
106 # Try exercising the "minimal" language a bit...
107
108 if [runto csub] then {
109 gdb_test "set lang minimal" \
110 "Warning: the current language does not match this frame." \
111 "set lang to minimal"
112
113 gdb_test "print x" " = 5000" "print parameter value"
114
115 # Ensure this at least does not crash.
116 gdb_test_no_output "set language unknown"
117 gdb_test "print x" \
118 "expression parsing not implemented for language .Unknown." \
119 "expression parsing does not crash for unknown"
120 }
121
122 set timeout $oldtimeout
123 return 0
This page took 0.052658 seconds and 4 git commands to generate.