xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/langs.exp (revision 1580a27b92f58fcdcb23fdfbc04a7c2b54a0b7c8)
1#   Copyright (C) 1997-2015 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
17standard_testfile langs0.c langs1.c langs2.c
18
19if [is_remote host] {
20    remote_download host ${srcdir}/${subdir}/langs1.f
21    remote_download host ${srcdir}/${subdir}/langs2.cxx
22}
23
24
25if {[prepare_for_testing ${testfile}.exp ${testfile} \
26	 [list $srcfile $srcfile2 $srcfile3] {debug}]} {
27    return -1
28}
29
30set oldtimeout $timeout
31set timeout 10
32
33
34
35# Create and source the file that provides information about the compiler
36# used to compile the test case.
37if [get_compiler_info] {
38    return -1
39}
40
41gdb_test_multiple "b 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
51if {$hp_aCC_compiler} {
52    set isfixed 1
53    set lang c\\+\\+
54    set ext cxx
55    set foo_func foo__Fi__Fi
56    set do_func do::langs0
57} else {
58    if {$hp_cc_compiler} {
59        set isfixed 1
60        set lang c
61        set ext c
62    } else {
63        set isfixed 0
64    }
65    set foo_func foo__Fi
66    set do_func langs0__2do
67}
68
69if [runto csub] then {
70
71    if { !$isfixed } { set lang c }
72    gdb_test "show language" "currently $lang\".*" \
73	"show language at csub in langs.exp"
74    # On some machines, foo doesn't get demangled because the N_SOL for
75    # langs2.cxx is seen only after the function stab for foo.  So
76    # the following regexps are kludged to accept foo__Fi as well as foo,
77    # even though only the latter is correct.  I haven't tried to xfail it
78    # because it depends on details of the compiler.
79
80    # Take out xfail. This test has been passing for some time now.
81    #if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
82    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"
83
84    if { !$isfixed } { set lang c\\+\\+; set ext cxx }
85    if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
86    gdb_test "up" ".* in (foo|$foo_func).* at langs2\\.$ext.*return csub \\(.*" \
87	"up to foo in langs.exp"
88    gdb_test "show language" "currently $lang.*" \
89	"show language at foo in langs.exp"
90
91    if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
92    gdb_test "up" ".* in cppsub_ .* at langs2\\.$ext.*return foo \\(.*" \
93	"up to cppsub_ in langs.exp"
94    gdb_test "show language" "currently $lang.*" \
95	"show language at cppsub_ in langs.exp"
96
97    if { !$isfixed } { set lang fortran }
98    if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
99    gdb_test "up" ".* in fsub.* at langs1\\.f.*" \
100	"up to fsub in langs.exp"
101    gdb_test "show language" "currently $lang.*" \
102	"show language at fsub in langs.exp"
103
104    # Take out xfail. This test has been passing for sometime now.
105    #if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
106    if { !$isfixed } { set lang c }
107    gdb_test "up" ".* in $do_func .* at .*langs0\\.c.*return fsub.*" \
108	"up to langs0__2do in langs.exp"
109    gdb_test "show language" "currently $lang\".*" \
110	"show language at langs0__2do in langs.exp"
111
112    gdb_test "up" ".* in main .* at .*langs0\\.c.*if \\(langs0__2do \\(.*" \
113	"up to main in langs.exp"
114    gdb_test "show language" "currently $lang\".*" \
115	"show language at main in langs.exp"
116
117    if [target_info exists gdb,noresults] { return }
118
119    gdb_continue_to_end "langs.exp"
120}
121
122gdb_exit
123gdb_start
124gdb_reinitialize_dir $srcdir/$subdir
125gdb_load $binfile
126
127# Try exercising the "minimal" language a bit...
128
129if [runto csub] then {
130    gdb_test "set lang minimal" \
131             "Warning: the current language does not match this frame." \
132             "set lang to minimal"
133
134    gdb_test "print x" " = 5000" "print parameter value"
135}
136
137set timeout $oldtimeout
138return 0
139