Commit | Line | Data |
---|---|---|
58a84dcf SA |
1 | # Copyright 2014 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 | ||
21 | load_lib mi-support.exp | |
22 | set MIFLAGS "-i=mi" | |
23 | ||
24 | gdb_exit | |
25 | if [mi_gdb_start] { | |
26 | continue | |
27 | } | |
28 | ||
29 | standard_testfile vla.c | |
30 | ||
31 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" \ | |
32 | "${binfile}" executable {debug}] != "" } { | |
33 | untested mi-vla-basics.exp | |
34 | return -1 | |
35 | } | |
36 | ||
37 | mi_delete_breakpoints | |
38 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
39 | mi_gdb_load ${binfile} | |
40 | ||
41 | set bp_lineno [gdb_get_line_number "vla-filled"] | |
42 | ||
43 | mi_create_breakpoint "-t vla.c:$bp_lineno" 1 "del" "func" \ | |
44 | ".*vla.c" $bp_lineno $hex \ | |
45 | "insert breakpoint at line $bp_lineno after vla is filled" | |
46 | mi_run_cmd | |
47 | mi_expect_stop "breakpoint-hit" "func" "\{name=\"n\",value=\"5\"\}" \ | |
48 | ".*vla.c" "$bp_lineno" { "" "disp=\"del\"" } \ | |
49 | "run to breakpoint at line $bp_lineno" | |
50 | ||
51 | mi_gdb_test "500-data-evaluate-expression vla" \ | |
52 | "500\\^done,value=\"\\{0, 1, 2, 3, 4\\}\"" "evaluate complete vla" | |
53 | ||
54 | mi_gdb_test "501-data-evaluate-expression vla\[0\]" \ | |
55 | "501\\^done,value=\"0\"" "evaluate vla\[0\]" | |
56 | ||
57 | mi_gdb_test "502-data-evaluate-expression vla\[2\]" \ | |
58 | "502\\^done,value=\"2\"" "evaluate vla\[2\]" | |
59 | ||
60 | mi_gdb_test "503-data-evaluate-expression vla\[4\]" \ | |
61 | "503\\^done,value=\"4\"" "evaluate vla\[4\]" | |
62 | ||
63 | mi_create_varobj_checked vla vla "int \\\[5\\\]" \ | |
64 | "create local variable vla" | |
65 | ||
66 | mi_gdb_test "504-var-info-type vla" \ | |
67 | "504\\^done,type=\"int \\\[5\\\]\"" \ | |
68 | "info type variable vla" | |
69 | ||
70 | mi_gdb_test "505-var-show-format vla" \ | |
71 | "505\\^done,format=\"natural\"" \ | |
72 | "show format variable vla" | |
73 | ||
74 | mi_gdb_test "506-var-evaluate-expression vla" \ | |
75 | "506\\^done,value=\"\\\[5\\\]\"" \ | |
76 | "eval variable vla" | |
77 | ||
78 | mi_list_array_varobj_children "vla" "5" "int" \ | |
79 | "get children of vla" | |
80 | ||
81 | mi_gdb_exit | |
82 | return 0 |