xref: /netbsd-src/external/gpl3/gdb/dist/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp (revision 32d1c65c71fbdb65a012e8392a62a757dd6853e9)
1# Copyright 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# Test a binary that uses MOPS (Memory Operations) instructions.
17# This test is similar to gdb.base/memops-watchpoint.exp, but specifically
18# tests MOPS instructions rather than whatever instructions are used in the
19# system libc's implementation of memset/memcpy/memmove.
20
21require allow_hw_watchpoint_tests allow_aarch64_mops_tests
22
23standard_testfile
24
25if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
26	  [list debug additional_flags=-march=armv9.3-a]] } {
27    return -1
28}
29
30set linespec ${srcfile}:[gdb_get_line_number "Break here"]
31if ![runto ${linespec}] {
32    return -1
33}
34
35gdb_test "watch -location a\[28\]" \
36    "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \
37    "set watch on a"
38gdb_test "watch -location b\[28\]" \
39    "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
40    "set watchpoint on b"
41gdb_test "watch -location c\[28\]" \
42    "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \
43    "set watchpoint on c"
44
45gdb_test "continue" \
46    [multi_line \
47	 "Continuing\\." \
48	 "" \
49	 "Hardware watchpoint ${decimal}: -location a\\\[28\\\]" \
50	 "" \
51	 "Old value = 104 'h'" \
52	 "New value = 0 '\\\\000'" \
53	 "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
54	 "${decimal}\\s+__asm__ volatile \\(\"setp.*\\\\n\\\\t\""] \
55    "continue until set watchpoint hits"
56
57gdb_test "continue" \
58    [multi_line \
59	 "Continuing\\." \
60	 "" \
61	 "Hardware watchpoint ${decimal}: -location b\\\[28\\\]" \
62	 "" \
63	 "Old value = 101 'e'" \
64	 "New value = 114 'r'" \
65	 "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
66	 "${decimal}\\s+__asm__ volatile \\(\"cpyp.*\\\\n\\\\t\""] \
67    "continue until cpy watchpoint hits"
68
69gdb_test "continue" \
70    [multi_line \
71	 "Continuing\\." \
72	 "" \
73	 "Hardware watchpoint ${decimal}: -location c\\\[28\\\]" \
74	 "" \
75	 "Old value = 100 'd'" \
76	 "New value = 114 'r'" \
77	 "$hex in main \\(\\) at .*aarch64-mops-watchpoint.c:$decimal" \
78	 "${decimal}\\s+__asm__ volatile \\(\"cpyfp.*\\\\n\\\\t\""] \
79    "continue until cpyf watchpoint hits"
80