1 # Copyright 2012-2021 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/>.
17 set executable ${testfile}
19 # Multiple inferiors are needed, therefore both native and extended gdbserver
20 # modes are supported. Only non-extended gdbserver is not supported.
22 untested "using gdb stub"
26 # Do not use simple hardware watchpoints ("watch") as its false hit may be
27 # unnoticed by GDB if it reads it still has the same value.
28 if [skip_hw_watchpoint_access_tests] {
29 untested "${testfile} (no hardware access watchpoints)"
33 if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
34 untested "failed to compile"
38 clean_restart $executable
40 # Simulate non-stop which also uses breakpoint always-inserted.
41 gdb_test_no_output "set breakpoint always-inserted on"
42 # displaced-stepping is also needed as other GDB sometimes still removes the
43 # breakpoints, even with always-inserted on.
44 # Without the support this test just is not as thorough as it could be.
45 if [support_displaced_stepping] {
46 gdb_test_no_output "set displaced-stepping on"
49 # Debugging of this testcase:
50 #gdb_test_no_output "maintenance set show-debug-regs on"
51 #gdb_test_no_output "set debug infrun 1"
53 gdb_breakpoint main {temporary}
54 gdb_test "run" "Temporary breakpoint.* main .*" "start to main inferior 1"
56 gdb_test "add-inferior" "Added inferior 2 on connection .*" "add inferior 2"
57 gdb_test "inferior 2" "witching to inferior 2 .*" "switch to inferior 2, first time"
60 gdb_breakpoint main {temporary}
61 gdb_test "run" "Temporary breakpoint.* main .*" "start to main inferior 2"
64 "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c" \
65 "awatch c on inferior 2"
67 gdb_breakpoint "marker_exit"
69 gdb_test "inferior 1" "witching to inferior 1 .*" "switch back to inferior 1"
71 if [skip_hw_watchpoint_multi_tests] {
72 # On single hardware watchpoint at least test the watchpoint in inferior
76 "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b" \
77 "awatch b on inferior 1"
79 gdb_test "inferior 2" "witching to inferior 2 .*" "switch to inferior 2 again"
81 # FAIL would be a hit on watchpoint for `b' - that one is for the other
84 "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c\r\n\r\nOld value = 0\r\nNew value = 3\r\n.*" \
85 "catch c on inferior 2"
87 gdb_test "continue" "Breakpoint \[0-9\]+, marker_exit .*" "catch marker_exit in inferior 2"
89 gdb_test "inferior 1" "witching to inferior 1 .*" "switch back to inferior 1 again"
91 gdb_test "continue" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b\r\n\r\nOld value = 0\r\nNew value = 2\r\n.*" "catch b on inferior 1"
94 gdb_test "continue" "Breakpoint \[0-9\]+, marker_exit .*" "catch marker_exit in inferior 1"