1 # Copyright
2016-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 # Make sure that
if an inferior exits or is detached
/killed
, its
17 # watchpoints don
't end up with stale locations, preventing resumption
22 if {[build_executable "failed to build" $testfile $srcfile {debug}]} {
26 # The test proper. DISPOSE indicates how to dispose of the fork
27 # child. Can be either "kill", "detach", or "exit" (to continue it to
29 proc do_test {dispose} {
30 global binfile bkptno_numopt_re
32 clean_restart $binfile
34 gdb_test_no_output "set follow-fork child"
35 gdb_test_no_output "set detach-on-fork off"
37 if ![runto "child_function"] {
41 gdb_test "watch globalvar" "atchpoint \[0-9\]+: globalvar" \
42 "set watchpoint on inferior 2"
44 # Dispose of the inferior. This should get rid of this inferior's
45 # watchpoint locations.
46 if {$dispose
== "kill"} {
47 gdb_test
"kill" "" "kill inferior 2" \
48 "Kill the program being debugged.*y or n. $" "y"
49 } elseif
{$dispose
== "detach"} {
50 gdb_test
"detach" ".*" "detach inferior 2"
51 } elseif
{$dispose
== "exit"} {
52 gdb_test
"continue" ".*exited normally.*" "run to exit inferior 2"
54 perror
"unhandled dispose: $dispose"
57 gdb_test
"inferior 1" "witching to inferior 1 .*" \
58 "switch back to inferior 1"
60 if {$dispose
== "kill"} {
61 gdb_test
"print expect_signaled = 1" " = 1"
64 gdb_breakpoint
"marker"
66 # Now
continue inferior
1. Before GDB was fixed
, watchpoints
for
67 # inferior
2 managed to be left behind. When GDB realized that
68 # they hadn
't been inserted, the continue command was aborted:
73 # Could not insert hardware watchpoint 2.
74 # Could not insert hardware breakpoints:
75 # You may have requested too many hardware breakpoints/watchpoints.
80 gdb_test "continue" "Breakpoint $bkptno_numopt_re, marker .*" \
81 "continue in inferior 1"
84 foreach_with_prefix dispose {"kill" "detach" "exit"} {