1# Copyright 2012-2020 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 16standard_testfile 17set executable ${testfile} 18 19# Multiple inferiors are needed, therefore both native and extended gdbserver 20# modes are supported. Only non-extended gdbserver is not supported. 21if [use_gdb_stub] { 22 untested "using gdb stub" 23 return 24} 25 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. 28if [skip_hw_watchpoint_access_tests] { 29 untested "${testfile} (no hardware access watchpoints)" 30 return 31} 32 33if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { 34 untested "failed to compile" 35 return -1 36} 37 38clean_restart $executable 39 40# Simulate non-stop which also uses breakpoint always-inserted. 41gdb_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. 45if [support_displaced_stepping] { 46 gdb_test_no_output "set displaced-stepping on" 47} 48 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" 52 53gdb_breakpoint main {temporary} 54gdb_test "run" "Temporary breakpoint.* main .*" "start to main inferior 1" 55 56gdb_test "add-inferior" "Added inferior 2 on connection .*" "add inferior 2" 57gdb_test "inferior 2" "witching to inferior 2 .*" "switch to inferior 2, first time" 58gdb_load $binfile 59 60gdb_breakpoint main {temporary} 61gdb_test "run" "Temporary breakpoint.* main .*" "start to main inferior 2" 62 63gdb_test "awatch c" \ 64 "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c" \ 65 "awatch c on inferior 2" 66 67gdb_breakpoint "marker_exit" 68 69gdb_test "inferior 1" "witching to inferior 1 .*" "switch back to inferior 1" 70 71if [skip_hw_watchpoint_multi_tests] { 72 # On single hardware watchpoint at least test the watchpoint in inferior 73 # 2 is not hit. 74} else { 75 gdb_test "awatch b" \ 76 "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b" \ 77 "awatch b on inferior 1" 78 79 gdb_test "inferior 2" "witching to inferior 2 .*" "switch to inferior 2 again" 80 81 # FAIL would be a hit on watchpoint for `b' - that one is for the other 82 # inferior. 83 gdb_test "continue" \ 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" 86 87 gdb_test "continue" "Breakpoint \[0-9\]+, marker_exit .*" "catch marker_exit in inferior 2" 88 89 gdb_test "inferior 1" "witching to inferior 1 .*" "switch back to inferior 1 again" 90 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" 92} 93 94gdb_test "continue" "Breakpoint \[0-9\]+, marker_exit .*" "catch marker_exit in inferior 1" 95