1 # Copyright 2012-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 standard_testfile basics.c
17 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
18 executable {debug nowarnings}] != "" } {
19 untested "failed to compile"
23 load_lib mi-support.exp
25 if {[mi_clean_restart $binfile]} {
29 mi_gdb_test "-break-insert -t ${srcfile}:[gdb_get_line_number "C = A + B"]" \
30 "\\^done,bkpt=\{number=\"1\".*" \
33 mi_expect_stop "breakpoint-hit" "callee4" "" ".*" ".*" {"" "disp=\"del\""} \
36 mi_gdb_test "set var C = 4" \
37 ".*=memory-changed,thread-group=\"i${decimal}\".addr=\"${hex}\",len=\"${hex}\".*\\^done" \
40 # Write memory through MI commands shouldn't trigger MI notification.
41 mi_gdb_test "-var-create var_c * C" \
42 "\\^done,name=\"var_c\",numchild=\"0\",value=\"4\",type=\"int\",thread-id=\"1\",has_more=\"0\"" \
45 mi_gdb_test "-var-assign var_c 5" \
46 "-var-assign var_c 5\r\n\\^done,value=\"5\"" \
47 "change C thru. varobj"
49 mi_gdb_test "-data-write-memory-bytes &C \"00\"" \
51 "change C thru. -data-write-memory-bytes"
53 # Modify code section also triggers MI notification.
55 # Get the instruction content of function main and its address.
58 set test "get address of main"
61 -re ".*(${hex}) <main>:.*(${hex}).*$mi_gdb_prompt$" {
62 set main_addr $expect_out(1,string)
63 set main_insn $expect_out(2,string)
66 -re ".*$mi_gdb_prompt$" {
71 fail "$test (timeout)"
76 regsub ^0x0* $main_addr "" main_addr
77 mi_gdb_test "set var *(unsigned int *) 0x${main_addr} = ${main_insn}" \
78 ".*=memory-changed,thread-group=\"i${decimal}\".addr=\"0x0*${main_addr}\",len=\"0x4\",type=\"code\".*\\^done"