1 # Copyright (C) 2015 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 # This test verifies that several threads forking while another thread
17 # is constantly stepping over a breakpoint is properly handled.
21 set linenum [gdb_get_line_number "set break here"]
23 if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}] == -1} {
27 # The test proper. If COND_BP_TARGET is true, then test with
28 # conditional breakpoints evaluated on the target side, if possible.
29 # DETACH_ON_FORK is used as value for the "set detach-on-fork"
30 # setting. If "on", this exercises GDB explicitly continuing the fork
31 # child until exit. If "off", this exercises GDB detaching the fork
33 proc do_test { cond_bp_target detach_on_fork } {
35 global srcfile testfile binfile
36 global decimal gdb_prompt
38 global is_remote_target
40 set saved_gdbflags $GDBFLAGS
41 set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""]
42 set GDBFLAGS [concat $GDBFLAGS " -ex \"set sysroot /\""]
43 clean_restart $binfile
44 set GDBFLAGS $saved_gdbflags
46 if ![runto_main] then {
47 fail "Can't run to main"
51 gdb_test_no_output "set detach-on-fork $detach_on_fork"
53 gdb_test "break $linenum if zero == 1" \
55 "set breakpoint that evals false"
58 gdb_test_multiple $test $test {
67 set test "inferior 1 exited"
68 gdb_test_multiple "" $test {
69 -re "Inferior 1 \(\[^\r\n\]+\) exited normally" {
73 -re "Inferior $decimal \(\[^\r\n\]+\) exited normally" {
76 if {$fork_count <= 100} {
79 fail "$test (too many forks)"
85 # No use testing further.
89 gdb_test "info threads" "No threads\." \
92 gdb_test "info inferiors" \
93 "Num\[ \t\]+Description\[ \t\]+Executable\[ \t\]+\r\n\\* 1 \[^\r\n\]+" \
94 "only inferior 1 left"
97 # Wrapper for foreach that calls with_test_prefix on each iteration,
98 # including the iterator's current value in the prefix.
100 proc foreach_with_prefix {var list body} {
102 foreach myvar $list {
103 with_test_prefix "$var=$myvar" {
109 foreach_with_prefix cond_bp_target {1 0} {
110 foreach_with_prefix detach_on_fork {"off" "off"} {
111 do_test $cond_bp_target $detach_on_fork
113 # Disable "off" for now. The test does pass with
114 # detach-on-fork off (at the time of writing), but gdb seems
115 # to slow down quadratically as inferiors are created, and
116 # then the test takes annoyingly long to complete...