Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / watchpoint-hw-attach.exp
CommitLineData
88b9d363 1# Copyright 2018-2022 Free Software Foundation, Inc.
8363f9d5
RB
2
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.
7#
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.
12#
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/>.
15
16# watchpoint-hw-attach.exp -- Test if hardware watchpoints are used
17# when attaching to a target.
18
19if {[skip_hw_watchpoint_tests]} {
20 return 0
21}
22
23if {![can_spawn_for_attach]} {
24 return 0
25}
26
27standard_testfile
28
29if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
30 return -1
31}
32
33clean_restart $binfile
34
35if ![runto_main] {
36 untested "can't run to main"
37 return -1
38}
39
40# Run to the point where mypid in the test program has been
41# populated.
42gdb_breakpoint [gdb_get_line_number "pidacquired"]
43gdb_continue_to_breakpoint "pidacquired"
44
45# Get the PID of the test process.
46set testpid [get_integer_valueof "mypid" 0]
47
48gdb_test "detach" "Detaching from program: .*, process $testpid\r\n\\\[Inferior $decimal \\(process $testpid\\) detached\\\]"
49
50if {$testpid == ""} {
51 return -1
52}
53
54# A clean restart is needed to force the hardware watchpoint setup
55# logic to run post attach rather than post inferior launch.
56clean_restart $binfile
57
49af4b70 58gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*" "attach"
8363f9d5 59
8363f9d5
RB
60# Ensure the test program is in the top frame so the required
61# variables are in scope.
be1b6474
RB
62gdb_breakpoint $srcfile:[gdb_get_line_number "pidacquired"]
63gdb_continue_to_breakpoint "$srcfile:pidacquired"
64
65gdb_test_no_output "set should_continue = 1"
8363f9d5
RB
66
67gdb_test "watch watched_variable" \
68 "Hardware watchpoint $decimal: watched_variable"
69
70gdb_test "continue" \
71 "continue.*Continuing.*\.Hardware watchpoint $decimal: watched_variable.*Old value = 0.*New value = 4.*watched_variable\\);"
This page took 0.470993 seconds and 4 git commands to generate.