1# Copyright 2012-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 16standard_testfile basics.c 17if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ 18 executable {debug nowarnings}] != "" } { 19 untested "failed to compile" 20 return -1 21} 22 23load_lib mi-support.exp 24 25if [mi_gdb_start] { 26 return 27} 28mi_gdb_reinitialize_dir $srcdir/$subdir 29mi_gdb_load ${binfile} 30 31mi_gdb_test "-break-insert -t ${srcfile}:[gdb_get_line_number "C = A + B"]" \ 32 "\\^done,bkpt=\{number=\"1\".*" \ 33 "insert breakpoint" 34mi_run_cmd 35mi_expect_stop "breakpoint-hit" "callee4" "" ".*" ".*" {"" "disp=\"del\""} \ 36 "continue to callee4" 37 38mi_gdb_test "set var C = 4" \ 39 ".*=memory-changed,thread-group=\"i${decimal}\".addr=\"${hex}\",len=\"${hex}\".*\\^done" \ 40 "set var C = 4" 41 42# Write memory through MI commands shouldn't trigger MI notification. 43mi_gdb_test "-var-create var_c * C" \ 44 "\\^done,name=\"var_c\",numchild=\"0\",value=\"4\",type=\"int\",thread-id=\"1\",has_more=\"0\"" \ 45 "create objvar for C" 46 47mi_gdb_test "-var-assign var_c 5" \ 48 "-var-assign var_c 5\r\n\\^done,value=\"5\"" \ 49 "change C thru. varobj" 50 51mi_gdb_test "-data-write-memory-bytes &C \"00\"" \ 52 {\^done} \ 53 "change C thru. -data-write-memory-bytes" 54 55# Modify code section also triggers MI notification. 56 57# Get the instruction content of function main and its address. 58set main_addr "" 59set main_insn "" 60set test "get address of main" 61send_gdb "x/x main\n" 62gdb_expect { 63 -re ".*(${hex}) <main>:.*(${hex}).*$mi_gdb_prompt$" { 64 set main_addr $expect_out(1,string) 65 set main_insn $expect_out(2,string) 66 pass $test 67 } 68 -re ".*$mi_gdb_prompt$" { 69 fail $test 70 return 71 } 72 timeout { 73 fail "$test (timeout)" 74 return 75 } 76} 77 78mi_gdb_test "set var *(unsigned int *) ${main_addr} = ${main_insn}" \ 79 ".*=memory-changed,thread-group=\"i${decimal}\".addr=\"${main_addr}\",len=\"0x4\",type=\"code\".*\\^done" 80mi_gdb_exit 81return 0 82