GDB: trad-frame: Store length of value_bytes in trad_frame_saved_reg
[binutils-gdb.git] / gdb / testsuite / gdb.base / watchpoint-hw-attach.exp
blobff3585a98a45e88f43a0b5d0dc123ecaefd7a2f7
1 # Copyright 2018-2024 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 require allow_hw_watchpoint_tests
21 require can_spawn_for_attach
23 standard_testfile
25 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
26 return -1
29 if ![runto_main] {
30 return -1
33 # Run to the point where mypid in the test program has been
34 # populated.
35 gdb_breakpoint [gdb_get_line_number "pidacquired"]
36 gdb_continue_to_breakpoint "pidacquired"
38 # Get the PID of the test process.
39 set testpid [get_integer_valueof "mypid" 0]
41 gdb_test "detach" "Detaching from program: .*, process $testpid\r\n\\\[Inferior $decimal \\(process $testpid\\) detached\\\]"
43 if {$testpid == ""} {
44 return -1
47 # A clean restart is needed to force the hardware watchpoint setup
48 # logic to run post attach rather than post inferior launch.
49 clean_restart $binfile
51 gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*" "attach"
53 # Ensure the test program is in the top frame so the required
54 # variables are in scope.
55 gdb_breakpoint $srcfile:[gdb_get_line_number "pidacquired"]
56 gdb_continue_to_breakpoint "$srcfile:pidacquired"
58 gdb_test_no_output "set should_continue = 1"
60 gdb_test "watch watched_variable" \
61 "Hardware watchpoint $decimal: watched_variable"
63 gdb_test "continue" \
64 "continue.*Continuing.*\.Hardware watchpoint $decimal: watched_variable.*Old value = 0.*New value = 4.*watched_variable\\);"