Fix gdb.fortran/nested-funcs.exp failure
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.fortran / module.exp
CommitLineData
e2882c85 1# Copyright 2009-2018 Free Software Foundation, Inc.
5d7cb8df
JK
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
cf09b3e4 16standard_testfile .f90
5d7cb8df 17
5b362f04 18if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] } {
5d7cb8df
JK
19 return -1
20}
21
fd5700c7
JK
22# Test automatic language detection before the inferior starts. It tests the
23# effect of expected:
24# (gdb) show language
25# The current source language is "auto; currently fortran".
26gdb_test "p modmany::var_i" " = 14" "stopped language detection"
27
c2b0a229
JK
28gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
29
5d7cb8df
JK
30if ![runto MAIN__] then {
31 perror "couldn't run to breakpoint MAIN__"
32 continue
33}
34
f55ee35c
JK
35# Do not use simple single-letter names as GDB would pick up for expectedly
36# nonexisting symbols some static variables from system libraries debuginfos.
37
38gdb_breakpoint [gdb_get_line_number "i-is-1"]
39gdb_continue_to_breakpoint "i-is-1" ".*i-is-1.*"
40gdb_test "print var_i" " = 1" "print var_i value 1"
41
42gdb_breakpoint [gdb_get_line_number "i-is-2"]
43gdb_continue_to_breakpoint "i-is-2" ".*i-is-2.*"
44gdb_test "print var_i" " = 2" "print var_i value 2"
45
530e8392
KB
46gdb_breakpoint [gdb_get_line_number "i-is-3"]
47gdb_continue_to_breakpoint "i-is-3" ".*i-is-3.*"
48# Ensure that the scope is correctly resolved.
49gdb_test "p mod3" "Attempt to use a type name as an expression" "print mod3"
50gdb_test "p mod2" " = 3" "print mod2"
51gdb_test "p mod1" " = 3" "print mod1"
52
f55ee35c
JK
53gdb_breakpoint [gdb_get_line_number "a-b-c-d"]
54gdb_continue_to_breakpoint "a-b-c-d" ".*a-b-c-d.*"
55gdb_test "print var_a" "No symbol \"var_a\" in current context\\."
56gdb_test "print var_b" " = 11"
57gdb_test "print var_c" "No symbol \"var_c\" in current context\\."
58gdb_test "print var_d" " = 12"
59gdb_test "print var_i" " = 14" "print var_i value 14"
32019081
JK
60gdb_test "print var_x" " = 30" "print var_x value 30"
61gdb_test "print var_y" "No symbol \"var_y\" in current context\\."
62gdb_test "print var_z" " = 31" "print var_x value 31"
f55ee35c 63
530e8392 64gdb_test "ptype modmany" "type = module modmany"
f55ee35c
JK
65
66proc complete {expr list} {
67 set cmd "complete p $expr"
68 set expect [join [concat [list $cmd] $list] "\r\np "]
69 gdb_test $cmd $expect "complete $expr"
70}
71set modmany_list {modmany::var_a modmany::var_b modmany::var_c modmany::var_i}
530e8392
KB
72complete "modm" "modmany $modmany_list"
73complete "modmany" "modmany $modmany_list"
f55ee35c
JK
74complete "modmany::" $modmany_list
75complete "modmany::var" $modmany_list
76
77# Breakpoint would work in language "c".
78gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
79
80# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
81# works. But DWARF DW_TAG_subprogram contains the name specified by
82# the "program" Fortran statement.
83if [gdb_breakpoint "module"] {
84 pass "setting breakpoint at module"
85}
This page took 1.066874 seconds and 4 git commands to generate.