Automatic date update in version.in
[binutils-gdb/blckswan.git] / gdb / testsuite / gdb.mi / mi-vla-c99.exp
blob3c24ea77a40721b08a6e157df31fc60034b8f380
1 # Copyright 2014-2022 Free Software Foundation, Inc.
3 # Contributed by Intel Corp. <keven.boell@intel.com>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Verify that, using the MI, we can evaluate a simple C Variable Length
19 # Array (VLA).
21 load_lib mi-support.exp
22 set MIFLAGS "-i=mi"
24 gdb_exit
25 if [mi_gdb_start] {
26 return
29 standard_testfile vla.c
31 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" \
32 "${binfile}" executable {debug}] != "" } {
33 untested "failed to compile"
34 return -1
37 mi_delete_breakpoints
38 mi_gdb_reinitialize_dir $srcdir/$subdir
39 mi_gdb_load ${binfile}
41 set bp_lineno [gdb_get_line_number "vla-filled"]
43 mi_create_breakpoint "-t vla.c:$bp_lineno" \
44 "insert breakpoint at line $bp_lineno after vla is filled" \
45 -function func -line $bp_lineno -file ".*vla.c" -disp del
47 mi_run_cmd
48 mi_expect_stop "breakpoint-hit" "func" "\{name=\"n\",value=\"5\"\}" \
49 ".*vla.c" "$bp_lineno" { "" "disp=\"del\"" } \
50 "run to breakpoint at line $bp_lineno"
52 mi_gdb_test "500-data-evaluate-expression vla" \
53 "500\\^done,value=\"\\{0, 1, 2, 3, 4\\}\"" "evaluate complete vla"
55 mi_gdb_test "501-data-evaluate-expression vla\[0\]" \
56 "501\\^done,value=\"0\"" "evaluate vla\[0\]"
58 mi_gdb_test "502-data-evaluate-expression vla\[2\]" \
59 "502\\^done,value=\"2\"" "evaluate vla\[2\]"
61 mi_gdb_test "503-data-evaluate-expression vla\[4\]" \
62 "503\\^done,value=\"4\"" "evaluate vla\[4\]"
64 mi_create_varobj_checked vla vla "int \\\[5\\\]" \
65 "create local variable vla"
67 mi_gdb_test "504-var-info-type vla" \
68 "504\\^done,type=\"int \\\[5\\\]\"" \
69 "info type variable vla"
71 mi_gdb_test "505-var-show-format vla" \
72 "505\\^done,format=\"natural\"" \
73 "show format variable vla"
75 mi_gdb_test "506-var-evaluate-expression vla" \
76 "506\\^done,value=\"\\\[5\\\]\"" \
77 "eval variable vla"
79 mi_list_array_varobj_children "vla" "5" "int" \
80 "get children of vla"
82 mi_gdb_exit
83 return 0