summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.fortran/vla-strings.exp
blob: 484fdcb652adce4ef4ee511cb29fec7ea29976f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Copyright 2016 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

standard_testfile ".f90"

if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
    {debug f90 quiet}] } {
    return -1
}

# check that all fortran standard datatypes will be
# handled correctly when using as VLA's

if ![runto_main] {
    untested "could not run to main"
    return -1
}

gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
gdb_continue_to_breakpoint "var_char-allocated-1"
set test "whatis var_char first time"
gdb_test_multiple "whatis var_char" $test {
    -re "type = PTR TO -> \\( character\\*10 \\)\r\n$gdb_prompt $" {
	    pass $test
    }
    -re "type = character\\*10\r\n$gdb_prompt $" {
	    pass $test
    }
}
set test "ptype var_char first time"
gdb_test_multiple "ptype var_char" $test {
    -re "type = PTR TO -> \\( character\\*10 \\)\r\n$gdb_prompt $" {
	    pass $test
    }
    -re "type = character\\*10\r\n$gdb_prompt $" {
	    pass $test
    }
}


gdb_test "next" "\\d+.*var_char = 'foo'.*" \
  "next to allocation status of var_char"
gdb_test "print l" " = \\.TRUE\\." "print allocation status first time"


gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
gdb_continue_to_breakpoint "var_char-filled-1"
set test "print var_char, var_char-filled-1"
gdb_test_multiple "print var_char" $test {
    -re "= \\(PTR TO -> \\( character\\*3 \\)\\) $hex\r\n$gdb_prompt $" {
        gdb_test "print *var_char" "= 'foo'" "print *var_char, var_char-filled-1"
	    pass $test
    }
    -re "= 'foo'\r\n$gdb_prompt $" {
	    pass $test
    }
}
set test "ptype var_char, var_char-filled-1"
gdb_test_multiple "ptype var_char" $test {
    -re "type = PTR TO -> \\( character\\*3 \\)\r\n$gdb_prompt $" {
	    pass $test
    }
    -re "type = character\\*3\r\n$gdb_prompt $" {
	    pass $test
    }
}
gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"


gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
gdb_continue_to_breakpoint "var_char-filled-2"
set test "print var_char, var_char-filled-2"
gdb_test_multiple "print var_char" $test {
    -re "= \\(PTR TO -> \\( character\\*6 \\)\\) $hex\r\n$gdb_prompt $" {
        gdb_test "print *var_char" "= 'foobar'" "print *var_char, var_char-filled-2"
	    pass $test
    }
    -re "= 'foobar'\r\n$gdb_prompt $" {
	    pass $test
    }
}
set test "ptype var_char, var_char-filled-2"
gdb_test_multiple "ptype var_char" $test {
    -re "type = PTR TO -> \\( character\\*6 \\)\r\n$gdb_prompt $" {
	    pass $test
    }
    -re "type = character\\*6\r\n$gdb_prompt $" {
	    pass $test
    }
}