| 1 | # This testcase is part of GDB, the GNU debugger. |
| 2 | |
| 3 | # Copyright 2010-2017 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 | |
| 23 | standard_testfile |
| 24 | |
| 25 | if { [prepare_for_testing "failed to prepare" $testfile $testfile.c {debug}] } { |
| 26 | return -1 |
| 27 | } |
| 28 | |
| 29 | # Disable hardware watchpoints if necessary. |
| 30 | if [target_info exists gdb,no_hardware_watchpoints] { |
| 31 | gdb_test_no_output "set can-use-hw-watchpoints 0" "" |
| 32 | } |
| 33 | |
| 34 | if { ![runto main] } then { |
| 35 | fail "run to main" |
| 36 | return |
| 37 | } |
| 38 | |
| 39 | # The breakpoint is probably at the instruction where the value being |
| 40 | # watched (myrec.x) gets updated. This is the instruction where we |
| 41 | # expect to receive a watchpoint notification when we do the "stepi" |
| 42 | # below. However, having the breakpoint at the same location as this |
| 43 | # intruction can possibly interfere with our testcase, as stepping |
| 44 | # over the breakpoint in order to get past it may incorrectly lead |
| 45 | # to the debugger missing the watchpoint hit. This would be a bug |
| 46 | # in GDB, but this is not the bug that we are trying to test here. |
| 47 | # So, we remove all breakpoints first. |
| 48 | |
| 49 | delete_breakpoints |
| 50 | |
| 51 | set nl "\[\r\n\]+" |
| 52 | |
| 53 | gdb_test "watch myrec.x" ".*atchpoint \[0-9\]+: myrec\.x" "set watchpoint" |
| 54 | |
| 55 | gdb_test "next" \ |
| 56 | ".*${nl}.*atchpoint \[0-9\]+: myrec\.x${nl}Old value = 0${nl}New value = 5${nl}.*" \ |
| 57 | "watchpoint variable triggers at next" |
| 58 | |
| 59 | gdb_test "continue" \ |
| 60 | ".*${nl}.*atchpoint \[0-9\]+: myrec\.x${nl}Old value = 5${nl}New value = 78${nl}.*" \ |
| 61 | "watchpoint variable triggers at continue" |
| 62 | |