Home | History | Annotate | Line # | Download | only in gdb.mi
      1  1.1.1.6  christos # Copyright 2015-2024 Free Software Foundation, Inc.
      2      1.1  christos 
      3      1.1  christos # This program is free software; you can redistribute it and/or modify
      4      1.1  christos # it under the terms of the GNU General Public License as published by
      5      1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6      1.1  christos # (at your option) any later version.
      7      1.1  christos #
      8      1.1  christos # This program is distributed in the hope that it will be useful,
      9      1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10      1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11      1.1  christos # GNU General Public License for more details.
     12      1.1  christos #
     13      1.1  christos # You should have received a copy of the GNU General Public License
     14      1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15      1.1  christos 
     16  1.1.1.5  christos # Verify that, using the MI, we can evaluate a simple Fortran Variable
     17  1.1.1.5  christos # Length Array (VLA).
     18  1.1.1.5  christos 
     19  1.1.1.6  christos require allow_fortran_tests
     20      1.1  christos 
     21      1.1  christos load_lib mi-support.exp
     22  1.1.1.3  christos load_lib fortran.exp
     23      1.1  christos set MIFLAGS "-i=mi"
     24      1.1  christos 
     25      1.1  christos standard_testfile vla.f90
     26      1.1  christos 
     27      1.1  christos if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
     28      1.1  christos      {debug f90}] != "" } {
     29  1.1.1.2  christos      untested "failed to compile"
     30      1.1  christos      return -1
     31      1.1  christos }
     32      1.1  christos 
     33  1.1.1.3  christos # Depending on the compiler being used,
     34  1.1.1.3  christos # the type names can be printed differently.
     35  1.1.1.3  christos set real [fortran_real4]
     36  1.1.1.3  christos 
     37  1.1.1.6  christos if {[mi_clean_restart $binfile]} {
     38  1.1.1.6  christos     return
     39  1.1.1.6  christos }
     40      1.1  christos 
     41      1.1  christos set bp_lineno [gdb_get_line_number "vla1-not-allocated"]
     42  1.1.1.3  christos mi_create_breakpoint "-t vla.f90:$bp_lineno" \
     43  1.1.1.3  christos     "insert breakpoint at line $bp_lineno (vla not allocated)" \
     44  1.1.1.7  christos     -number 1 -disp del -func vla
     45      1.1  christos mi_run_cmd
     46      1.1  christos mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
     47      1.1  christos   { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
     48      1.1  christos mi_gdb_test "500-data-evaluate-expression vla1" \
     49  1.1.1.3  christos   "500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla, before allocation"
     50      1.1  christos 
     51  1.1.1.4  christos mi_create_varobj_checked vla1_not_allocated vla1 "$real, allocatable \\(:\\)" \
     52      1.1  christos   "create local variable vla1_not_allocated"
     53      1.1  christos mi_gdb_test "501-var-info-type vla1_not_allocated" \
     54  1.1.1.4  christos   "501\\^done,type=\"$real, allocatable \\(:\\)\"" \
     55      1.1  christos   "info type variable vla1_not_allocated"
     56      1.1  christos mi_gdb_test "502-var-show-format vla1_not_allocated" \
     57      1.1  christos   "502\\^done,format=\"natural\"" \
     58      1.1  christos   "show format variable vla1_not_allocated"
     59      1.1  christos mi_gdb_test "503-var-evaluate-expression vla1_not_allocated" \
     60      1.1  christos   "503\\^done,value=\"\\\[0\\\]\"" \
     61      1.1  christos   "eval variable vla1_not_allocated"
     62      1.1  christos mi_list_array_varobj_children_with_index "vla1_not_allocated" "0" "1" \
     63  1.1.1.3  christos     "$real" "get children of vla1_not_allocated"
     64      1.1  christos 
     65      1.1  christos 
     66      1.1  christos 
     67      1.1  christos set bp_lineno [gdb_get_line_number "vla1-allocated"]
     68  1.1.1.3  christos mi_create_breakpoint "-t vla.f90:$bp_lineno" \
     69  1.1.1.3  christos     "insert breakpoint at line $bp_lineno (vla allocated)" \
     70  1.1.1.7  christos     -number 2 -disp del -func vla
     71      1.1  christos mi_run_cmd
     72      1.1  christos mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
     73      1.1  christos   { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
     74      1.1  christos mi_gdb_test "510-data-evaluate-expression vla1" \
     75      1.1  christos   "510\\^done,value=\"\\(.*\\)\"" "evaluate allocated vla"
     76      1.1  christos 
     77  1.1.1.4  christos mi_create_varobj_checked vla1_allocated vla1 "$real, allocatable \\\(5\\\)" \
     78      1.1  christos   "create local variable vla1_allocated"
     79      1.1  christos mi_gdb_test "511-var-info-type vla1_allocated" \
     80  1.1.1.4  christos   "511\\^done,type=\"$real, allocatable \\\(5\\\)\"" \
     81      1.1  christos   "info type variable vla1_allocated"
     82      1.1  christos mi_gdb_test "512-var-show-format vla1_allocated" \
     83      1.1  christos   "512\\^done,format=\"natural\"" \
     84      1.1  christos   "show format variable vla1_allocated"
     85      1.1  christos mi_gdb_test "513-var-evaluate-expression vla1_allocated" \
     86      1.1  christos   "513\\^done,value=\"\\\[5\\\]\"" \
     87      1.1  christos   "eval variable vla1_allocated"
     88      1.1  christos mi_list_array_varobj_children_with_index "vla1_allocated" "5" "1" \
     89  1.1.1.3  christos     "$real" "get children of vla1_allocated"
     90      1.1  christos 
     91      1.1  christos 
     92      1.1  christos set bp_lineno [gdb_get_line_number "vla1-filled"]
     93  1.1.1.3  christos mi_create_breakpoint "-t vla.f90:$bp_lineno" \
     94  1.1.1.3  christos     "insert breakpoint at line $bp_lineno" \
     95  1.1.1.7  christos     -number 3 -disp del -func vla
     96      1.1  christos mi_run_cmd
     97      1.1  christos mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
     98      1.1  christos   { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
     99      1.1  christos mi_gdb_test "520-data-evaluate-expression vla1" \
    100  1.1.1.3  christos   "520\\^done,value=\"\\(1, 1, 1, 1, 1\\)\"" "evaluate filled vla, filled all 1s"
    101      1.1  christos 
    102      1.1  christos 
    103      1.1  christos set bp_lineno [gdb_get_line_number "vla1-modified"]
    104  1.1.1.3  christos mi_create_breakpoint "-t vla.f90:$bp_lineno" \
    105  1.1.1.3  christos     "insert breakpoint at line $bp_lineno" \
    106  1.1.1.7  christos     -number 4 -disp del -func vla
    107      1.1  christos mi_run_cmd
    108      1.1  christos mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
    109      1.1  christos   { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
    110      1.1  christos mi_gdb_test "530-data-evaluate-expression vla1" \
    111  1.1.1.3  christos   "530\\^done,value=\"\\(1, 42, 1, 24, 1\\)\"" "evaluate filled vla, contents modified"
    112      1.1  christos mi_gdb_test "540-data-evaluate-expression vla1(1)" \
    113  1.1.1.3  christos   "540\\^done,value=\"1\"" "evaluate filled vla(1)"
    114      1.1  christos mi_gdb_test "550-data-evaluate-expression vla1(2)" \
    115  1.1.1.3  christos   "550\\^done,value=\"42\"" "evaluate filled vla(2)"
    116      1.1  christos mi_gdb_test "560-data-evaluate-expression vla1(4)" \
    117  1.1.1.3  christos   "560\\^done,value=\"24\"" "evaluate filled vla(4)"
    118      1.1  christos 
    119      1.1  christos 
    120      1.1  christos set bp_lineno [gdb_get_line_number "vla1-deallocated"]
    121  1.1.1.3  christos mi_create_breakpoint "-t vla.f90:$bp_lineno" \
    122  1.1.1.3  christos     "insert breakpoint at line $bp_lineno" \
    123  1.1.1.7  christos     -number 5 -disp del -func vla
    124      1.1  christos mi_run_cmd
    125      1.1  christos mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
    126      1.1  christos   { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
    127      1.1  christos mi_gdb_test "570-data-evaluate-expression vla1" \
    128  1.1.1.3  christos   "570\\^done,value=\"<not allocated>\"" "evaluate not allocated vla, after deallocation"
    129      1.1  christos 
    130      1.1  christos 
    131      1.1  christos set bp_lineno [gdb_get_line_number "pvla2-not-associated"]
    132  1.1.1.3  christos mi_create_breakpoint "-t vla.f90:$bp_lineno" \
    133  1.1.1.3  christos     "insert breakpoint at line $bp_lineno" \
    134  1.1.1.7  christos     -number 6 -disp "del" -func "vla"
    135      1.1  christos mi_run_cmd
    136      1.1  christos mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
    137      1.1  christos   { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
    138      1.1  christos 
    139      1.1  christos 
    140      1.1  christos set test "evaluate not associated vla"
    141      1.1  christos send_gdb "580-data-evaluate-expression pvla2\n"
    142      1.1  christos gdb_expect {
    143      1.1  christos     -re "580\\^done,value=\"<not associated>\".*${mi_gdb_prompt}$" {
    144      1.1  christos 	pass $test
    145      1.1  christos 
    146  1.1.1.4  christos 	mi_create_varobj_checked pvla2_not_associated pvla2 "$real \\(:,:\\)" \
    147      1.1  christos 	    "create local variable pvla2_not_associated"
    148      1.1  christos 	mi_gdb_test "581-var-info-type pvla2_not_associated" \
    149  1.1.1.4  christos 	    "581\\^done,type=\"$real \\(:,:\\)\"" \
    150      1.1  christos 	    "info type variable pvla2_not_associated"
    151      1.1  christos 	mi_gdb_test "582-var-show-format pvla2_not_associated" \
    152      1.1  christos 	    "582\\^done,format=\"natural\"" \
    153      1.1  christos 	    "show format variable pvla2_not_associated"
    154      1.1  christos 	mi_gdb_test "583-var-evaluate-expression pvla2_not_associated" \
    155      1.1  christos 	    "583\\^done,value=\"\\\[0\\\]\"" \
    156      1.1  christos 	    "eval variable pvla2_not_associated"
    157      1.1  christos 	mi_list_array_varobj_children_with_index "pvla2_not_associated" "0" "1" \
    158  1.1.1.3  christos 	    "$real" "get children of pvla2_not_associated"
    159      1.1  christos     }
    160      1.1  christos     -re "580\\^error,msg=\"value contents too large \\(\[0-9\]+ bytes\\).*${mi_gdb_prompt}$" {
    161  1.1.1.7  christos 	# Undefined behavior in gfortran.
    162      1.1  christos 	xfail $test
    163      1.1  christos     }
    164      1.1  christos     -re "${mi_gdb_prompt}$" {
    165      1.1  christos 	fail $test
    166      1.1  christos     }
    167      1.1  christos     timeout {
    168      1.1  christos 	fail "$test (timeout)"
    169      1.1  christos     }
    170      1.1  christos }
    171      1.1  christos 
    172      1.1  christos set bp_lineno [gdb_get_line_number "pvla2-associated"]
    173  1.1.1.3  christos mi_create_breakpoint "-t vla.f90:$bp_lineno" \
    174  1.1.1.3  christos     "insert breakpoint at line $bp_lineno" \
    175  1.1.1.7  christos     -number 7 -disp del -func vla
    176      1.1  christos mi_run_cmd
    177      1.1  christos mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
    178      1.1  christos   { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
    179      1.1  christos mi_gdb_test "590-data-evaluate-expression pvla2" \
    180  1.1.1.5  christos   "590\\^done,value=\"\\(\\(2, 2, 2, 2, 2\\) \\(2, 2, 2, 2, 2\\)\\)\"" \
    181      1.1  christos   "evaluate associated vla"
    182      1.1  christos 
    183      1.1  christos mi_create_varobj_checked pvla2_associated pvla2 \
    184  1.1.1.3  christos   "$real \\\(5,2\\\)" "create local variable pvla2_associated"
    185      1.1  christos mi_gdb_test "591-var-info-type pvla2_associated" \
    186  1.1.1.3  christos   "591\\^done,type=\"$real \\\(5,2\\\)\"" \
    187      1.1  christos   "info type variable pvla2_associated"
    188      1.1  christos mi_gdb_test "592-var-show-format pvla2_associated" \
    189      1.1  christos   "592\\^done,format=\"natural\"" \
    190      1.1  christos   "show format variable pvla2_associated"
    191      1.1  christos mi_gdb_test "593-var-evaluate-expression pvla2_associated" \
    192      1.1  christos   "593\\^done,value=\"\\\[2\\\]\"" \
    193      1.1  christos   "eval variable pvla2_associated"
    194      1.1  christos 
    195      1.1  christos 
    196      1.1  christos set bp_lineno [gdb_get_line_number "pvla2-set-to-null"]
    197  1.1.1.3  christos mi_create_breakpoint "-t vla.f90:$bp_lineno" \
    198  1.1.1.3  christos     "insert breakpoint at line $bp_lineno" \
    199  1.1.1.7  christos     -number 8 -disp del -func vla
    200      1.1  christos mi_run_cmd
    201      1.1  christos mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
    202      1.1  christos   { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
    203      1.1  christos mi_gdb_test "600-data-evaluate-expression pvla2" \
    204      1.1  christos   "600\\^done,value=\"<not associated>\"" "evaluate vla pointer set to null"
    205      1.1  christos 
    206      1.1  christos mi_gdb_exit
    207