Commit | Line | Data |
---|---|---|
f67c0c91 SDJ |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
11bc5fe4 | 3 | # Copyright 2007-2020 Free Software Foundation, Inc. |
f67c0c91 SDJ |
4 | |
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation; either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
18 | # Test that the event messages printed when using 'set print | |
19 | # inferior-events [on,off]', 'set follow-fork-mode [child,parent]' and | |
20 | # 'set detach-on-fork [on,off]' are the correct ones. | |
21 | ||
22 | # This test relies on "run", so it cannot run on target remote stubs. | |
23 | if { [use_gdb_stub] } { | |
24 | untested "not supported on target remote stubs" | |
25 | return | |
26 | } | |
27 | ||
81f47ac2 AH |
28 | # Test relies on checking follow-fork output. Do not run if gdb debug is |
29 | # enabled as it will be redirected to the log. | |
30 | if [gdb_debug_enabled] { | |
31 | untested "debug is enabled" | |
32 | return 0 | |
33 | } | |
34 | ||
f67c0c91 SDJ |
35 | standard_testfile |
36 | ||
37 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } { | |
38 | return -1 | |
39 | } | |
40 | ||
41 | # This is the expected output for each of the test combinations | |
42 | # below. The order here is important: | |
43 | # | |
44 | # inferior-events: on; follow-fork: child; detach-on-fork: on | |
45 | # inferior-events: on; follow-fork: child; detach-on-fork: off | |
46 | # inferior-events: on; follow-fork: parent; detach-on-fork: on | |
47 | # inferior-events: on; follow-fork: parent; detach-on-fork: off | |
48 | # inferior-events: off; follow-fork: child; detach-on-fork: on | |
49 | # inferior-events: off; follow-fork: child; detach-on-fork: off | |
50 | # inferior-events: off; follow-fork: parent; detach-on-fork: on | |
51 | # inferior-events: off; follow-fork: parent; detach-on-fork: off | |
52 | ||
53 | set reading_re "(Reading.*from remote target\\.\\.\\.\r\n)*" | |
54 | set exited_normally_re "${reading_re}\\\[Inferior $decimal \\(.*\\) exited normally\\\]" | |
55 | # gdbserver produces a slightly different message when attaching after | |
56 | # a fork, so we have to tweak the regexp to accomodate that. | |
57 | set attach_child_re "${reading_re}\\\[Attaching after .* fork to child .*\\\]\r\n" | |
58 | set detach_child_re "${reading_re}\\\[Detaching after fork from child .*\\\]\r\n" | |
59 | set detach_parent_re "${reading_re}\\\[Detaching after fork from parent .*\\\]\r\n" | |
60 | set new_inf_re "${reading_re}\\\[New inferior $decimal \\(.*\\)\\\]\r\n" | |
61 | set inf_detached_re "${reading_re}\\\[Inferior $decimal \\(.*\\) detached\\\]\r\n" | |
62 | ||
63 | set expected_output [list \ | |
64 | "${attach_child_re}${new_inf_re}${detach_parent_re}${inf_detached_re}" \ | |
65 | "${attach_child_re}${new_inf_re}" \ | |
66 | "${detach_child_re}" \ | |
67 | "${new_inf_re}" \ | |
68 | "" \ | |
69 | "" \ | |
70 | "" \ | |
71 | "" \ | |
72 | ] | |
73 | ||
74 | set i 0 | |
75 | ||
76 | foreach_with_prefix print_inferior_events { "on" "off" } { | |
77 | foreach_with_prefix follow_fork_mode { "child" "parent" } { | |
78 | foreach_with_prefix detach_on_fork { "on" "off" } { | |
79 | clean_restart $binfile | |
80 | gdb_test_no_output "set print inferior-events $print_inferior_events" | |
81 | gdb_test_no_output "set follow-fork-mode $follow_fork_mode" | |
82 | gdb_test_no_output "set detach-on-fork $detach_on_fork" | |
83 | ||
84 | set output [lindex $expected_output $i] | |
85 | # Always add the "Starting program..." string so that we | |
86 | # match exactly the lines we want. | |
87 | set output "Starting program: $binfile\\s*\r\n${output}${exited_normally_re}" | |
88 | set i [expr $i + 1] | |
89 | gdb_test "run" $output | |
90 | } | |
91 | } | |
92 | } |