1 # Copyright
2014-2019 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
58 # It
'll execute a large amount of code with software watchpoint
59 # enabled, which means GDB will single stepping all the way
60 # through til the inferior exits. Increase the timeout by a
62 with_timeout_factor 4 {
68 # Check that regular watchpoints against expressions involving
69 # bitfields trigger properly.
70 proc test_regular_watch {} {
71 with_test_prefix "regular watch against bitfields" {
76 watch "q.d + q.f + q.g"
77 expect_watchpoint "q.d + q.f + q.g" 0 4
78 expect_watchpoint "q.d + q.f + q.g" 4 10
79 expect_watchpoint "q.d + q.f + q.g" 10 3
80 expect_watchpoint "q.d + q.f + q.g" 3 2
81 expect_watchpoint "q.d + q.f + q.g" 2 1
82 expect_watchpoint "q.d + q.f + q.g" 1 0
84 # It'll
execute a large amount of code with software watchpoint
85 # enabled
, which means GDB will single stepping all the way
86 # through til the inferior exits. Increase the timeout by a
88 with_timeout_factor
4 {
94 # Disable hardware watchpoints
if the target does not support them.
95 if [target_info
exists gdb
,no_hardware_watchpoints
] {
96 gdb_test_no_output
"set can-use-hw-watchpoints 0"