| 1 | # Copyright 2014-2019 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" \ |
| 44 | "insert breakpoint at line $bp_lineno after vla is filled" \ |
| 45 | -function func -line $bp_lineno -file ".*vla.c" -disp del |
| 46 | |
| 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" |
| 51 | |
| 52 | mi_gdb_test "500-data-evaluate-expression vla" \ |
| 53 | "500\\^done,value=\"\\{0, 1, 2, 3, 4\\}\"" "evaluate complete vla" |
| 54 | |
| 55 | mi_gdb_test "501-data-evaluate-expression vla\[0\]" \ |
| 56 | "501\\^done,value=\"0\"" "evaluate vla\[0\]" |
| 57 | |
| 58 | mi_gdb_test "502-data-evaluate-expression vla\[2\]" \ |
| 59 | "502\\^done,value=\"2\"" "evaluate vla\[2\]" |
| 60 | |
| 61 | mi_gdb_test "503-data-evaluate-expression vla\[4\]" \ |
| 62 | "503\\^done,value=\"4\"" "evaluate vla\[4\]" |
| 63 | |
| 64 | mi_create_varobj_checked vla vla "int \\\[5\\\]" \ |
| 65 | "create local variable vla" |
| 66 | |
| 67 | mi_gdb_test "504-var-info-type vla" \ |
| 68 | "504\\^done,type=\"int \\\[5\\\]\"" \ |
| 69 | "info type variable vla" |
| 70 | |
| 71 | mi_gdb_test "505-var-show-format vla" \ |
| 72 | "505\\^done,format=\"natural\"" \ |
| 73 | "show format variable vla" |
| 74 | |
| 75 | mi_gdb_test "506-var-evaluate-expression vla" \ |
| 76 | "506\\^done,value=\"\\\[5\\\]\"" \ |
| 77 | "eval variable vla" |
| 78 | |
| 79 | mi_list_array_varobj_children "vla" "5" "int" \ |
| 80 | "get children of vla" |
| 81 | |
| 82 | mi_gdb_exit |
| 83 | return 0 |