Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2009-2020 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 | ||
0b54364d AB |
16 | load_lib "fortran.exp" |
17 | ||
cf09b3e4 | 18 | standard_testfile .f90 |
5d7cb8df | 19 | |
5b362f04 | 20 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] } { |
5d7cb8df JK |
21 | return -1 |
22 | } | |
23 | ||
fd5700c7 JK |
24 | # Test automatic language detection before the inferior starts. It tests the |
25 | # effect of expected: | |
26 | # (gdb) show language | |
27 | # The current source language is "auto; currently fortran". | |
28 | gdb_test "p modmany::var_i" " = 14" "stopped language detection" | |
29 | ||
c2b0a229 JK |
30 | gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant" |
31 | ||
5d7cb8df JK |
32 | if ![runto MAIN__] then { |
33 | perror "couldn't run to breakpoint MAIN__" | |
34 | continue | |
35 | } | |
36 | ||
0b54364d AB |
37 | set int_type [fortran_int4] |
38 | ||
39 | # Test 'info variables' can find module variables. | |
40 | gdb_test "info variables -n" \ | |
41 | [multi_line \ | |
42 | "All defined variables:" \ | |
43 | "" \ | |
44 | "File .*$srcfile:" \ | |
45 | "18:\[ \t\]+${int_type} mod1::var_const;" \ | |
46 | "17:\[ \t\]+${int_type} mod1::var_i;" \ | |
47 | "23:\[ \t\]+${int_type} mod2::var_i;" \ | |
48 | "28:\[ \t\]+${int_type} mod3::mod1;" \ | |
49 | "27:\[ \t\]+${int_type} mod3::mod2;" \ | |
50 | "29:\[ \t\]+${int_type} mod3::var_i;" \ | |
51 | "33:\[ \t\]+${int_type} modmany::var_a;" \ | |
52 | "33:\[ \t\]+${int_type} modmany::var_b;" \ | |
53 | "33:\[ \t\]+${int_type} modmany::var_c;" \ | |
54 | "33:\[ \t\]+${int_type} modmany::var_i;" \ | |
55 | "37:\[ \t\]+${int_type} moduse::var_x;" \ | |
062f1fc1 TV |
56 | "37:\[ \t\]+${int_type} moduse::var_y;(" \ |
57 | "" \ | |
58 | "File .*:(" \ | |
59 | "$decimal:.*)+)*"] | |
0b54364d AB |
60 | |
61 | ||
f55ee35c JK |
62 | # Do not use simple single-letter names as GDB would pick up for expectedly |
63 | # nonexisting symbols some static variables from system libraries debuginfos. | |
64 | ||
65 | gdb_breakpoint [gdb_get_line_number "i-is-1"] | |
66 | gdb_continue_to_breakpoint "i-is-1" ".*i-is-1.*" | |
67 | gdb_test "print var_i" " = 1" "print var_i value 1" | |
68 | ||
69 | gdb_breakpoint [gdb_get_line_number "i-is-2"] | |
70 | gdb_continue_to_breakpoint "i-is-2" ".*i-is-2.*" | |
71 | gdb_test "print var_i" " = 2" "print var_i value 2" | |
72 | ||
530e8392 KB |
73 | gdb_breakpoint [gdb_get_line_number "i-is-3"] |
74 | gdb_continue_to_breakpoint "i-is-3" ".*i-is-3.*" | |
75 | # Ensure that the scope is correctly resolved. | |
76 | gdb_test "p mod3" "Attempt to use a type name as an expression" "print mod3" | |
77 | gdb_test "p mod2" " = 3" "print mod2" | |
78 | gdb_test "p mod1" " = 3" "print mod1" | |
79 | ||
f55ee35c JK |
80 | gdb_breakpoint [gdb_get_line_number "a-b-c-d"] |
81 | gdb_continue_to_breakpoint "a-b-c-d" ".*a-b-c-d.*" | |
82 | gdb_test "print var_a" "No symbol \"var_a\" in current context\\." | |
83 | gdb_test "print var_b" " = 11" | |
84 | gdb_test "print var_c" "No symbol \"var_c\" in current context\\." | |
85 | gdb_test "print var_d" " = 12" | |
86 | gdb_test "print var_i" " = 14" "print var_i value 14" | |
32019081 JK |
87 | gdb_test "print var_x" " = 30" "print var_x value 30" |
88 | gdb_test "print var_y" "No symbol \"var_y\" in current context\\." | |
89 | gdb_test "print var_z" " = 31" "print var_x value 31" | |
f55ee35c | 90 | |
530e8392 | 91 | gdb_test "ptype modmany" "type = module modmany" |
f55ee35c JK |
92 | |
93 | proc complete {expr list} { | |
94 | set cmd "complete p $expr" | |
95 | set expect [join [concat [list $cmd] $list] "\r\np "] | |
96 | gdb_test $cmd $expect "complete $expr" | |
97 | } | |
98 | set modmany_list {modmany::var_a modmany::var_b modmany::var_c modmany::var_i} | |
530e8392 KB |
99 | complete "modm" "modmany $modmany_list" |
100 | complete "modmany" "modmany $modmany_list" | |
f55ee35c JK |
101 | complete "modmany::" $modmany_list |
102 | complete "modmany::var" $modmany_list | |
103 | ||
104 | # Breakpoint would work in language "c". | |
105 | gdb_test "show language" {The current source language is "(auto; currently )?fortran".} | |
106 | ||
107 | # gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above | |
108 | # works. But DWARF DW_TAG_subprogram contains the name specified by | |
109 | # the "program" Fortran statement. | |
110 | if [gdb_breakpoint "module"] { | |
111 | pass "setting breakpoint at module" | |
112 | } |