Home | History | Annotate | Line # | Download | only in gdb.fortran
      1 # Copyright 2021-2024 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 # Place a non-dynamic array into an internal variable, then show that
     17 # modifications to either the internal variable, or to the original
     18 # array are independent.
     19 
     20 standard_testfile ".f90"
     21 load_lib "fortran.exp"
     22 
     23 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     24     {debug f90 quiet}] } {
     25     return -1
     26 }
     27 
     28 if ![fortran_runto_main] {
     29     return -1
     30 }
     31 
     32 gdb_breakpoint [gdb_get_line_number "Break here"]
     33 gdb_continue_to_breakpoint "Break here"
     34 
     35 # Take a copy of the array into an internal variable.
     36 gdb_test_no_output "set \$a=arr" "set \$a internal variable"
     37 
     38 # Validate the original contents.
     39 gdb_test "print arr" \
     40     " = \\(1, 1, 1, 1, 1, 1, 1, 1, 1, 1\\)" \
     41     "print arr contents"
     42 gdb_test "print \$a" \
     43     " = \\(1, 1, 1, 1, 1, 1, 1, 1, 1, 1\\)" \
     44     "print \$a contents"
     45 
     46 # Modify the original array in memory.
     47 gdb_test_no_output "set arr(5) = 5"
     48 
     49 # Modify the internal variable copy.
     50 gdb_test_no_output "set \$a(3) = 3"
     51 
     52 # Now check that the two values have been updated independently.
     53 gdb_test "print arr" \
     54     " = \\(1, 1, 1, 1, 5, 1, 1, 1, 1, 1\\)" \
     55     "print arr contents after change"
     56 gdb_test "print \$a" \
     57     " = \\(1, 1, 3, 1, 1, 1, 1, 1, 1, 1\\)" \
     58     "print \$a contents after change"
     59