1 # Copyright 2014 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/>.
16 # This file is part of the gdb testsuite
20 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
24 # Set a watchpoint watching EXPR.
28 set expr_re [string_to_regexp $expr]
29 gdb_test "watch $expr" \
30 "\(Hardware \)?\[Ww\]atchpoint $decimal: $expr_re"
33 # Continue inferior execution, expecting the watchpoint EXPR to be triggered
34 # having old value OLD and new value NEW.
35 proc expect_watchpoint { expr old new } {
36 with_test_prefix "$expr: $old->$new" {
37 set expr_re [string_to_regexp $expr]
38 gdb_test "print $expr" "\\$\\d+ = $old\\s" "print expression before"
39 gdb_test "continue" "$expr_re\\s.*Old value = $old\\s+New value = $new\\s.*"
40 gdb_test "print $expr" "\\$\\d+ = $new\\s" "print expression after"
44 # Check that -location watchpoints against bitfields trigger properly.
45 proc test_watch_location {} {
46 with_test_prefix "-location watch against bitfields" {
53 expect_watchpoint "q.a" 0 1
54 expect_watchpoint "q.e" 0 5
55 expect_watchpoint "q.a" 1 0
56 expect_watchpoint "q.e" 5 4
61 # Check that regular watchpoints against expressions involving
62 # bitfields trigger properly.
63 proc test_regular_watch {} {
64 with_test_prefix "regular watch against bitfields" {
69 watch "q.d + q.f + q.g"
70 expect_watchpoint "q.d + q.f + q.g" 0 4
71 expect_watchpoint "q.d + q.f + q.g" 4 10
72 expect_watchpoint "q.d + q.f + q.g" 10 3
73 expect_watchpoint "q.d + q.f + q.g" 3 2
74 expect_watchpoint "q.d + q.f + q.g" 2 1
75 expect_watchpoint "q.d + q.f + q.g" 1 0