Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2009-2020 Free Software Foundation, Inc. |
4c2786ba YQ |
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 | if {[skip_hw_watchpoint_tests]} { | |
17 | return 0 | |
18 | } | |
19 | ||
20 | load_lib mi-support.exp | |
21 | set MIFLAGS "-i=mi" | |
22 | ||
23 | standard_testfile .c | |
24 | ||
25 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
84c93cd5 | 26 | untested "failed to compile" |
4c2786ba YQ |
27 | return |
28 | } | |
29 | ||
0a251e08 YQ |
30 | proc test_memory_changed_observer { mi_command } { |
31 | with_test_prefix "${mi_command}" { | |
32 | global srcfile | |
4c2786ba | 33 | |
0a251e08 YQ |
34 | if [mi_gdb_start] { |
35 | return | |
36 | } | |
37 | mi_run_to_main | |
4c2786ba | 38 | |
0a251e08 YQ |
39 | set line_number [gdb_get_line_number "break here"] |
40 | mi_gdb_test "-break-insert ${srcfile}:${line_number}" \ | |
41 | {\^done,bkpt=.number="2",type="breakpoint".*\}} \ | |
42 | "set breakpoint" | |
4c2786ba | 43 | |
0a251e08 | 44 | mi_gdb_test "watch x" ".*" "set watchpoint" |
4c2786ba | 45 | |
0a251e08 YQ |
46 | mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \ |
47 | { "" "disp=\"keep\"" } "breakpoint hit" | |
4c2786ba | 48 | |
0a251e08 YQ |
49 | mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \ |
50 | { "" "wpt=\{number=\"3\",exp=\"x\"\},value=\{old=\"0\",new=\"42\"\}" } \ | |
51 | "watchpoint hit" | |
4c2786ba | 52 | |
0a251e08 YQ |
53 | mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \ |
54 | { "" "disp=\"keep\"" } "breakpoint hit 2" | |
4c2786ba | 55 | |
0a251e08 | 56 | mi_gdb_test "-${mi_command}" {\^done} "set x" |
4c2786ba | 57 | |
0a251e08 YQ |
58 | mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \ |
59 | { "" "wpt=\{number=\"3\",exp=\"x\"\},value=\{old=\"1\",new=\"42\"\}" } \ | |
60 | "watchpoint hit 2" | |
4c2786ba | 61 | |
0a251e08 YQ |
62 | mi_gdb_exit |
63 | } | |
64 | } | |
4c2786ba YQ |
65 | |
66 | test_memory_changed_observer "data-write-memory-bytes &x \"01\"" | |
67 | # We want to trigger a target memory write here, so the word size (4 or 8) | |
68 | # is not that important. | |
69 | test_memory_changed_observer "data-write-memory &x x 4 \"01\"" |