1 # Copyright 2022-2023 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Test print the value, and type, of Fortran string variables declared in
17 # different ways in the test program.
19 standard_testfile .f90
22 if {[skip_fortran_tests]} { return -1 }
24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
29 if { ![fortran_runto_main] } {
33 gdb_breakpoint [gdb_get_line_number "First breakpoint"]
34 gdb_breakpoint [gdb_get_line_number "Second breakpoint"]
35 gdb_breakpoint [gdb_get_line_number "Third breakpoint"]
37 with_test_prefix "first breakpoint" {
38 # Continue to the first breakpoint.
39 gdb_continue_to_breakpoint "continue"
40 gdb_test "print s" " = 'foo'"
41 gdb_test "ptype s" "type = character\\*3"
44 with_test_prefix "second breakpoint" {
45 # Continue to the second breakpoint.
46 gdb_continue_to_breakpoint "continue"
47 gdb_test "print s" " = 'foo'"
48 gdb_test "ptype s" "type = character\\*3"
51 with_test_prefix "third breakpoint, first time" {
52 # Continue to the third breakpoint.
53 gdb_continue_to_breakpoint "continue"
54 gdb_test "print s" " = 'foo'"
55 gdb_test "ptype s" "type = character \\(3\\)"
58 with_test_prefix "third breakpoint, second time" {
59 # Continue to the third breakpoint again. The string we print
60 # this time includes some embedded special characters (newline,
61 # tab, carriage-return, and an embedded null byte). Currently GDB
62 # prints these as C style backslash sequences, which isn't valid
63 # Fortran code, but is more compact than the Fortran way of doing
64 # it (see the test source for details), and is likely understood
65 # by most users, so seems good enough.
66 gdb_continue_to_breakpoint "continue"
67 gdb_test "print s" " = 'foo\\\\n\\\\t\\\\r\\\\000bar'"
68 gdb_test "ptype s" "type = character \\(10\\)"