Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.base / watchpoint-hw-attach.exp
blob5bff78f92426379b114603f749996d98a134250e
1 # Copyright 2018-2023 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 # watchpoint-hw-attach.exp -- Test if hardware watchpoints are used
17 # when attaching to a target.
19 if {[skip_hw_watchpoint_tests]} {
20     return 0
23 if {![can_spawn_for_attach]} {
24     return 0
27 standard_testfile
29 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
30     return -1
33 if ![runto_main] {
34     return -1
37 # Run to the point where mypid in the test program has been
38 # populated.
39 gdb_breakpoint [gdb_get_line_number "pidacquired"]
40 gdb_continue_to_breakpoint "pidacquired"
42 # Get the PID of the test process.
43 set testpid [get_integer_valueof "mypid" 0]
45 gdb_test "detach" "Detaching from program: .*, process $testpid\r\n\\\[Inferior $decimal \\(process $testpid\\) detached\\\]"
47 if {$testpid == ""} {
48     return -1
51 # A clean restart is needed to force the hardware watchpoint setup
52 # logic to run post attach rather than post inferior launch.
53 clean_restart $binfile
55 gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*" "attach"
57 # Ensure the test program is in the top frame so the required
58 # variables are in scope.
59 gdb_breakpoint $srcfile:[gdb_get_line_number "pidacquired"]
60 gdb_continue_to_breakpoint "$srcfile:pidacquired"
62 gdb_test_no_output "set should_continue = 1"
64 gdb_test "watch watched_variable" \
65          "Hardware watchpoint $decimal: watched_variable"
67 gdb_test "continue" \
68          "continue.*Continuing.*\.Hardware watchpoint $decimal: watched_variable.*Old value = 0.*New value = 4.*watched_variable\\);"