Remove required field in agent's symbols
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / forking-threads-plus-breakpoint.exp
CommitLineData
863d01bd
PA
1# Copyright (C) 2015 Free Software Foundation, Inc.
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# This test verifies that several threads forking while another thread
17# is constantly stepping over a breakpoint is properly handled.
18
19standard_testfile
20
21set linenum [gdb_get_line_number "set break here"]
22
23if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}] == -1} {
24 return -1
25}
26
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
32# child.
33proc do_test { cond_bp_target detach_on_fork } {
34 global GDBFLAGS
35 global srcfile testfile binfile
36 global decimal gdb_prompt
37 global linenum
38 global is_remote_target
39
40 set saved_gdbflags $GDBFLAGS
41 set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""]
42 clean_restart $binfile
43 set GDBFLAGS $saved_gdbflags
44
45 if ![runto_main] then {
46 fail "Can't run to main"
47 return 0
48 }
49
50 gdb_test_no_output "set detach-on-fork $detach_on_fork"
51
52 gdb_test "break $linenum if zero == 1" \
53 "Breakpoint .*" \
54 "set breakpoint that evals false"
55
56 set test "continue &"
57 gdb_test_multiple $test $test {
58 -re "$gdb_prompt " {
59 pass $test
60 }
61 }
62
63 set fork_count 0
64 set ok 0
65
66 set test "inferior 1 exited"
67 gdb_test_multiple "" $test {
68 -re "Inferior 1 \(\[^\r\n\]+\) exited normally" {
69 set ok 1
70 pass $test
71 }
72 -re "Inferior $decimal \(\[^\r\n\]+\) exited normally" {
73 incr fork_count
74 if {$fork_count <= 100} {
75 exp_continue
76 } else {
77 fail "$test (too many forks)"
78 }
79 }
80 }
81
82 if {!$ok} {
83 # No use testing further.
84 return
85 }
86
87 gdb_test "info threads" "No threads\." \
88 "no threads left"
89
90 gdb_test "info inferiors" \
91 "Num\[ \t\]+Description\[ \t\]+Executable\[ \t\]+\r\n\\* 1 \[^\r\n\]+" \
92 "only inferior 1 left"
93}
94
95# Wrapper for foreach that calls with_test_prefix on each iteration,
96# including the iterator's current value in the prefix.
97
98proc foreach_with_prefix {var list body} {
99 upvar 1 $var myvar
100 foreach myvar $list {
101 with_test_prefix "$var=$myvar" {
102 uplevel 1 $body
103 }
104 }
105}
106
107foreach_with_prefix cond_bp_target {1 0} {
108 foreach_with_prefix detach_on_fork {"on" "off"} {
109 do_test $cond_bp_target $detach_on_fork
110
111 # Disable "off" for now. The test does pass with
112 # detach-on-fork off (at the time of writing), but gdb seems
113 # to slow down quadratically as inferiors are created, and
114 # then the test takes annoyingly long to complete...
115 break
116 }
117}
This page took 0.027884 seconds and 4 git commands to generate.