gdb/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.multi / watchpoint-multi.exp
1 # Copyright 2012 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 set testfile "watchpoint-multi"
17
18 # Multiple inferiors are needed, therefore both native and extended gdbserver
19 # modes are supported. Only non-extended gdbserver is not supported.
20 if [target_info exists use_gdb_stub] {
21 untested ${testfile}.exp
22 return
23 }
24
25 # Do not use simple hardware watchpoints ("watch") as its false hit may be
26 # unnoticed by GDB if it reads it still has the same value.
27 if [skip_hw_watchpoint_access_tests] {
28 untested "${testfile} (no hardware access watchpoints)"
29 return
30 }
31
32 set executable ${testfile}
33 set srcfile ${testfile}.c
34 set binfile ${objdir}/${subdir}/${executable}
35
36 if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37 untested ${testfile}.exp
38 return -1
39 }
40
41 clean_restart $executable
42
43 # Simulate non-stop+target-async which also uses breakpoint always-inserted.
44 gdb_test_no_output "set breakpoint always-inserted on"
45 # displaced-stepping is also needed as other GDB sometimes still removes the
46 # breakpoints, even with always-inserted on.
47 # Without the support this test just is not as thorough as it could be.
48 if [support_displaced_stepping] {
49 gdb_test_no_output "set displaced-stepping on"
50 }
51
52 # Debugging of this testcase:
53 #gdb_test_no_output "maintenance set show-debug-regs on"
54 #gdb_test_no_output "set debug infrun 1"
55
56 gdb_breakpoint main {temporary}
57 gdb_test "run" "Temporary breakpoint.* main .*" "start to main inferior 1"
58
59 gdb_test "add-inferior" "Added inferior 2"
60 gdb_test "inferior 2" "witching to inferior 2 .*"
61 gdb_load $binfile
62
63 gdb_breakpoint main {temporary}
64 gdb_test "run" "Temporary breakpoint.* main .*" "start to main inferior 2"
65
66 gdb_test "awatch c" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c"
67
68 gdb_breakpoint "marker_exit"
69
70 gdb_test "inferior 1" "witching to inferior 1 .*"
71
72 if [skip_hw_watchpoint_multi_tests] {
73 # On single hardware watchpoint at least test the watchpoint in inferior
74 # 2 is not hit.
75 } else {
76 gdb_test "awatch b" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b"
77
78 gdb_test "inferior 2" "witching to inferior 2 .*"
79
80 # FAIL would be a hit on watchpoint for `b' - that one is for the other
81 # inferior.
82 gdb_test "continue" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c\r\n\r\nOld value = 0\r\nNew value = 3\r\n.*" "catch c"
83
84 gdb_test "continue" "Breakpoint \[0-9\]+, marker_exit .*" "catch marker_exit in inferior 2"
85
86 gdb_test "inferior 1" "witching to inferior 1 .*"
87
88 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"
89 }
90
91 gdb_test "continue" "Breakpoint \[0-9\]+, marker_exit .*" "catch marker_exit in inferior 1"
This page took 0.051711 seconds and 5 git commands to generate.