xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.mi/mi-vla-c99.exp (revision 901e7e84758515fbf39dfc064cb0b45ab146d8b0)
1# Copyright 2014-2020 Free Software Foundation, Inc.
2
3# Contributed by Intel Corp. <keven.boell@intel.com>
4#
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.
9#
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.
14#
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/>.
17
18# Verify that, using the MI, we can evaluate a simple C Variable Length
19# Array (VLA).
20
21load_lib mi-support.exp
22set MIFLAGS "-i=mi"
23
24gdb_exit
25if [mi_gdb_start] {
26    continue
27}
28
29standard_testfile vla.c
30
31if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" \
32                  "${binfile}" executable {debug}] != "" } {
33     untested mi-vla-basics.exp
34     return -1
35}
36
37mi_delete_breakpoints
38mi_gdb_reinitialize_dir $srcdir/$subdir
39mi_gdb_load ${binfile}
40
41set bp_lineno [gdb_get_line_number "vla-filled"]
42
43mi_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
46
47mi_run_cmd
48mi_expect_stop "breakpoint-hit" "func" "\{name=\"n\",value=\"5\"\}" \
49               ".*vla.c" "$bp_lineno" { "" "disp=\"del\"" } \
50               "run to breakpoint at line $bp_lineno"
51
52mi_gdb_test "500-data-evaluate-expression vla" \
53    "500\\^done,value=\"\\{0, 1, 2, 3, 4\\}\"" "evaluate complete vla"
54
55mi_gdb_test "501-data-evaluate-expression vla\[0\]" \
56    "501\\^done,value=\"0\"" "evaluate vla\[0\]"
57
58mi_gdb_test "502-data-evaluate-expression vla\[2\]" \
59    "502\\^done,value=\"2\"" "evaluate vla\[2\]"
60
61mi_gdb_test "503-data-evaluate-expression vla\[4\]" \
62    "503\\^done,value=\"4\"" "evaluate vla\[4\]"
63
64mi_create_varobj_checked vla vla "int \\\[5\\\]" \
65                                 "create local variable vla"
66
67mi_gdb_test "504-var-info-type vla" \
68    "504\\^done,type=\"int \\\[5\\\]\"" \
69    "info type variable vla"
70
71mi_gdb_test "505-var-show-format vla" \
72    "505\\^done,format=\"natural\"" \
73    "show format variable vla"
74
75mi_gdb_test "506-var-evaluate-expression vla" \
76    "506\\^done,value=\"\\\[5\\\]\"" \
77    "eval variable vla"
78
79mi_list_array_varobj_children "vla" "5" "int" \
80    "get children of vla"
81
82mi_gdb_exit
83return 0
84