gdb/
[binutils-gdb.git] / gdb / testsuite / gdb.fortran / module.exp
1 # Copyright 2009, 2010 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 set testfile "module"
17 set srcfile ${testfile}.f90
18
19 if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f77}] } {
20 return -1
21 }
22
23 if ![runto MAIN__] then {
24 perror "couldn't run to breakpoint MAIN__"
25 continue
26 }
27
28 # Do not use simple single-letter names as GDB would pick up for expectedly
29 # nonexisting symbols some static variables from system libraries debuginfos.
30
31 gdb_breakpoint [gdb_get_line_number "i-is-1"]
32 gdb_continue_to_breakpoint "i-is-1" ".*i-is-1.*"
33 gdb_test "print var_i" " = 1" "print var_i value 1"
34
35 gdb_breakpoint [gdb_get_line_number "i-is-2"]
36 gdb_continue_to_breakpoint "i-is-2" ".*i-is-2.*"
37 gdb_test "print var_i" " = 2" "print var_i value 2"
38
39 gdb_breakpoint [gdb_get_line_number "a-b-c-d"]
40 gdb_continue_to_breakpoint "a-b-c-d" ".*a-b-c-d.*"
41 gdb_test "print var_a" "No symbol \"var_a\" in current context\\."
42 gdb_test "print var_b" " = 11"
43 gdb_test "print var_c" "No symbol \"var_c\" in current context\\."
44 gdb_test "print var_d" " = 12"
45 gdb_test "print var_i" " = 14" "print var_i value 14"
46
47 gdb_test "ptype modmany" {No symbol "modmany" in current context.}
48
49 proc complete {expr list} {
50 set cmd "complete p $expr"
51 set expect [join [concat [list $cmd] $list] "\r\np "]
52 gdb_test $cmd $expect "complete $expr"
53 }
54 set modmany_list {modmany::var_a modmany::var_b modmany::var_c modmany::var_i}
55 complete "modm" $modmany_list
56 complete "modmany" $modmany_list
57 complete "modmany::" $modmany_list
58 complete "modmany::var" $modmany_list
59
60 # Breakpoint would work in language "c".
61 gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
62
63 # gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
64 # works. But DWARF DW_TAG_subprogram contains the name specified by
65 # the "program" Fortran statement.
66 if [gdb_breakpoint "module"] {
67 pass "setting breakpoint at module"
68 }