]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2018-2024 Free Software Foundation, Inc. |
6295b6da SM |
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 | # Test that we can follow forks properly when the executable is | |
17 | # position-independent. | |
18 | ||
19 | standard_testfile | |
20 | ||
6ef69a3f | 21 | set opts [list debug pie] |
6295b6da | 22 | |
98bf5c02 | 23 | if [build_executable "failed to prepare" $testfile $srcfile $opts] { |
6295b6da SM |
24 | return |
25 | } | |
26 | ||
27 | proc setup_test {detach_on_fork {follow_fork_mode "parent"}} { | |
28 | global binfile | |
29 | ||
30 | clean_restart ${binfile} | |
31 | ||
32 | if ![runto_main] { | |
6295b6da SM |
33 | return |
34 | } | |
35 | ||
36 | gdb_test_no_output "set detach-on-fork ${detach_on_fork}" | |
37 | gdb_test_no_output "set follow-fork-mode ${follow_fork_mode}" | |
38 | ||
39 | gdb_breakpoint "break_here" | |
40 | } | |
41 | ||
42 | proc_with_prefix test_detach_on_fork_follow_parent {} { | |
43 | setup_test "on" "parent" | |
44 | ||
45 | gdb_test "continue" "\r\nBreakpoint 2, break_here.*" | |
46 | } | |
47 | ||
48 | proc_with_prefix test_detach_on_fork_follow_child {} { | |
49 | setup_test "on" "child" | |
50 | ||
51 | gdb_test "continue" "\r\nThread 2.1 .* hit Breakpoint 2, break_here.*" | |
52 | } | |
53 | ||
54 | proc_with_prefix test_no_detach_on_fork {} { | |
55 | setup_test "off" | |
56 | ||
78805ff8 | 57 | gdb_test "continue" "\r\nThread 1.1 .* hit Breakpoint 2.1, break_here.*" \ |
f4581a88 | 58 | "continue from thread 1.1" |
6295b6da | 59 | gdb_test "thread 2.1" |
78805ff8 | 60 | gdb_test "continue" "\r\nThread 2.1 .* hit Breakpoint 2.2, break_here.*" \ |
f4581a88 | 61 | "continue from thread 2.1" |
6295b6da SM |
62 | } |
63 | ||
64 | test_detach_on_fork_follow_parent | |
65 | test_detach_on_fork_follow_child | |
66 | test_no_detach_on_fork |