1# Copyright 1999-2020 Free Software Foundation, Inc. 2# 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16# Test essential Machine interface (MI) operations 17# 18# Verify that, using the MI, we can create, update, delete variables. 19# 20 21 22load_lib mi-support.exp 23set MIFLAGS "-i=mi" 24 25gdb_exit 26if [mi_gdb_start] { 27 continue 28} 29 30standard_testfile var-cmd.c 31 32if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { 33 untested "failed to compile" 34 return -1 35} 36 37mi_delete_breakpoints 38mi_gdb_reinitialize_dir $srcdir/$subdir 39mi_gdb_load ${binfile} 40 41mi_runto do_block_tests 42 43# Test: c_variable-3.2 44# Desc: create cb and foo 45mi_create_varobj "cb" "cb" "create local variable cb" 46 47mi_gdb_test "-var-create foo * foo" \ 48 "\\^error,msg=\"-var-create: unable to create variable object\"" \ 49 "try to create local variable foo" 50 51# step to "foo = 123;" 52mi_step_to "do_block_tests" "" "var-cmd.c" \ 53 [gdb_get_line_number "foo = 123;"] \ 54 "step at do_block_test 1" 55 56 57# Be paranoid and assume 3.2 created foo 58mi_gdb_test "-var-delete foo" \ 59 "\\^error,msg=\"Variable object not found\"" \ 60 "delete var foo 1" 61 62 63# Test: c_variable-3.3 64# Desc: create foo 65mi_create_varobj "foo" "foo" "create local variable foo" 66 67# step to "foo2 = 123;" 68mi_step_to "do_block_tests" "" "var-cmd.c" \ 69 [gdb_get_line_number "foo2 = 123;"] \ 70 "step at do_block_test 2" 71 72# Test: c_variable-3.4 73# Desc: check foo, cb changed 74mi_gdb_test "-var-update *" \ 75 "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \ 76 "update all vars: cb foo changed" 77 78# step to "foo = 321;" 79mi_step_to "do_block_tests" "" "var-cmd.c" \ 80 [gdb_get_line_number "foo = 321;"] \ 81 "step at do_block_test 3" 82 83# Test: c_variable-3.5 84# Desc: create inner block foo 85mi_create_varobj "inner_foo" "foo" "create local variable inner_foo" 86 87# step to "foo2 = 0;" 88mi_step_to "do_block_tests" "" "var-cmd.c" \ 89 [gdb_get_line_number "foo2 = 0;"] \ 90 "step at do_block_test 4" 91 92# Test: c_variable-3.6 93# Desc: create foo2 94mi_create_varobj "foo2" "foo2" "create local variable foo2" 95 96# Test: c_variable-3.7 97# Desc: check that outer foo in scope and inner foo out of scope 98# Note: also a known gdb problem 99setup_xfail *-*-* 100mi_gdb_test "-var-update inner_foo" \ 101 "\\^done,changelist=\{FIXME\}" \ 102 "update inner_foo: should be out of scope: KNOWN PROBLEM" 103clear_xfail *-*-* 104 105setup_xfail *-*-* 106mi_gdb_test "-var-evaluate-expression inner_foo" \ 107 "\\^done,value=\{FIXME\}" \ 108 "evaluate inner_foo: should be out of scope: KNOWN PROBLEM" 109clear_xfail *-*-* 110 111mi_gdb_test "-var-update foo" \ 112 "\\^done,changelist=\\\[\\\]" \ 113 "update foo: did not change" 114 115mi_gdb_test "-var-delete inner_foo" \ 116 "\\^done,ndeleted=\"1\"" \ 117 "delete var inner_foo" 118 119# step to "foo = 0;" 120mi_step_to "do_block_tests" "" "var-cmd.c" \ 121 [gdb_get_line_number "foo = 0;"] \ 122 "step at do_block_test 5" 123 124# Test: c_variable-3.8 125# Desc: check that foo2 out of scope (known gdb problem) 126setup_xfail *-*-* 127mi_gdb_test "-var-update foo2" \ 128 "\\^done,changelist=\{FIXME\}" \ 129 "update foo2: should be out of scope: KNOWN PROBLEM" 130clear_xfail *-*-* 131 132# step to "cb = 21;" 133mi_step_to "do_block_tests" "" "var-cmd.c" \ 134 [gdb_get_line_number "cb = 21;"] \ 135 "step at do_block_test 6" 136 137# Test: c_variable-3.9 138# Desc: check that only cb is in scope (known gdb problem) 139setup_xfail *-*-* 140mi_gdb_test "-var-update foo2" \ 141 "\\^done,changelist=\\\[FIXME\\\]" \ 142 "update foo2 should be out of scope: KNOWN PROBLEM" 143clear_xfail *-*-* 144setup_xfail *-*-* 145mi_gdb_test "-var-update foo" \ 146 "\\^done,changelist=\{FIXME\}" \ 147 "update foo should be out of scope: KNOWN PROBLEM" 148clear_xfail *-*-* 149mi_gdb_test "-var-update cb" \ 150 "\\^done,changelist=\\\[\\\]" \ 151 "update cb" 152 153# Test: c_variable-3.10 154# Desc: names of editable variables 155#gdbtk_test c_variable-3.10 {names of editable variables} { 156# editable_variables 157#} {{foo cb foo2} {}} 158 159# Done with block tests 160mi_gdb_test "-var-delete foo" \ 161 "\\^done,ndeleted=\"1\"" \ 162 "delete var foo 2" 163 164mi_gdb_test "-var-delete foo2" \ 165 "\\^done,ndeleted=\"1\"" \ 166 "delete var foo2" 167 168mi_gdb_test "-var-delete cb" \ 169 "\\^done,ndeleted=\"1\"" \ 170 "delete var cb" 171 172mi_gdb_exit 173return 0 174