]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/gdb11531.exp
[gdb/build] Cleanup gdb/features/feature_to_c.sh
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / gdb11531.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 2010-2024 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 # Test GDB bug report 11531.
19 # This is a problem related to CANNOT_STEP_HW_WATCHPOINTS macro.
20 # It affects Solaris native targets.
21
22 # The allow_hw_watchpoint_tests checks if watchpoints are supported by the
23 # processor. On PowerPC, the check runs a small test program under gdb
24 # to determine if the Power processor supports HW watchpoints. The check
25 # must be done before starting the test so as to not disrupt the execution
26 # of the actual test.
27
28 set allow_hw_watchpoint_tests_p [allow_hw_watchpoint_tests]
29
30 standard_testfile
31
32 if { [prepare_for_testing "failed to prepare" $testfile $testfile.c {debug}] } {
33 return -1
34 }
35
36 # Disable hardware watchpoints if necessary.
37 if {!$allow_hw_watchpoint_tests_p} {
38 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
39 }
40
41 if {![runto_main]} {
42 return
43 }
44
45 # The breakpoint is probably at the instruction where the value being
46 # watched (myrec.x) gets updated. This is the instruction where we
47 # expect to receive a watchpoint notification when we do the "stepi"
48 # below. However, having the breakpoint at the same location as this
49 # intruction can possibly interfere with our testcase, as stepping
50 # over the breakpoint in order to get past it may incorrectly lead
51 # to the debugger missing the watchpoint hit. This would be a bug
52 # in GDB, but this is not the bug that we are trying to test here.
53 # So, we remove all breakpoints first.
54
55 delete_breakpoints
56
57 set nl "\[\r\n\]+"
58
59 gdb_test "watch myrec.x" ".*atchpoint \[0-9\]+: myrec\.x" "set watchpoint"
60
61 gdb_test "next" \
62 ".*${nl}.*atchpoint \[0-9\]+: myrec\.x${nl}Old value = 0${nl}New value = 5${nl}.*" \
63 "watchpoint variable triggers at next"
64
65 gdb_test "continue" \
66 ".*${nl}.*atchpoint \[0-9\]+: myrec\.x${nl}Old value = 5${nl}New value = 78${nl}.*" \
67 "watchpoint variable triggers at continue"
68