]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2016-2023 Free Software Foundation, Inc. |
63000888 PA |
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 | # Make sure that if an inferior exits or is detached/killed, its | |
17 | # watchpoints don't end up with stale locations, preventing resumption | |
18 | # of other inferiors. | |
19 | ||
20 | standard_testfile | |
21 | ||
22 | if {[build_executable "failed to build" $testfile $srcfile {debug}]} { | |
23 | return -1 | |
24 | } | |
25 | ||
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 | |
28 | # normal exit). | |
29 | proc do_test {dispose} { | |
78805ff8 | 30 | global binfile bkptno_numopt_re |
63000888 PA |
31 | |
32 | clean_restart $binfile | |
33 | ||
34 | gdb_test_no_output "set follow-fork child" | |
35 | gdb_test_no_output "set detach-on-fork off" | |
36 | ||
37 | if ![runto "child_function"] { | |
63000888 PA |
38 | return |
39 | } | |
40 | ||
41 | gdb_test "watch globalvar" "atchpoint \[0-9\]+: globalvar" \ | |
42 | "set watchpoint on inferior 2" | |
43 | ||
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" | |
53 | } else { | |
54 | perror "unhandled dispose: $dispose" | |
55 | } | |
56 | ||
57 | gdb_test "inferior 1" "witching to inferior 1 .*" \ | |
58 | "switch back to inferior 1" | |
59 | ||
60 | if {$dispose == "kill"} { | |
61 | gdb_test "print expect_signaled = 1" " = 1" | |
62 | } | |
63 | ||
64 | gdb_breakpoint "marker" | |
65 | ||
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: | |
69 | # | |
70 | # (gdb) continue | |
71 | # Continuing. | |
72 | # Warning: | |
73 | # Could not insert hardware watchpoint 2. | |
74 | # Could not insert hardware breakpoints: | |
75 | # You may have requested too many hardware breakpoints/watchpoints. | |
76 | # | |
77 | # Command aborted. | |
78 | # (gdb) | |
79 | # | |
78805ff8 | 80 | gdb_test "continue" "Breakpoint $bkptno_numopt_re, marker .*" \ |
63000888 PA |
81 | "continue in inferior 1" |
82 | } | |
83 | ||
84 | foreach_with_prefix dispose {"kill" "detach" "exit"} { | |
85 | do_test $dispose | |
86 | } |