]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.mi/mi-memory-changed.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-memory-changed.exp
1 # Copyright 2012-2024 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 standard_testfile basics.c
17 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
18 executable {debug nowarnings}] != "" } {
19 untested "failed to compile"
20 return -1
21 }
22
23 load_lib mi-support.exp
24
25 if {[mi_clean_restart $binfile]} {
26 return
27 }
28
29 mi_gdb_test "-break-insert -t ${srcfile}:[gdb_get_line_number "C = A + B"]" \
30 "\\^done,bkpt=\{number=\"1\".*" \
31 "insert breakpoint"
32 mi_run_cmd
33 mi_expect_stop "breakpoint-hit" "callee4" "" ".*" ".*" {"" "disp=\"del\""} \
34 "continue to callee4"
35
36 mi_gdb_test "set var C = 4" \
37 ".*=memory-changed,thread-group=\"i${decimal}\".addr=\"${hex}\",len=\"${hex}\".*\\^done" \
38 "set var C = 4"
39
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\"" \
43 "create objvar for C"
44
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"
48
49 mi_gdb_test "-data-write-memory-bytes &C \"00\"" \
50 {\^done} \
51 "change C thru. -data-write-memory-bytes"
52
53 # Modify code section also triggers MI notification.
54
55 # Get the instruction content of function main and its address.
56 set main_addr ""
57 set main_insn ""
58 set test "get address of main"
59 send_gdb "x/x main\n"
60 gdb_expect {
61 -re ".*(${hex}) <main>:.*(${hex}).*$mi_gdb_prompt$" {
62 set main_addr $expect_out(1,string)
63 set main_insn $expect_out(2,string)
64 pass $test
65 }
66 -re ".*$mi_gdb_prompt$" {
67 fail $test
68 return
69 }
70 timeout {
71 fail "$test (timeout)"
72 return
73 }
74 }
75
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"
79 mi_gdb_exit