1 # Copyright (C) 2011-2014 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 # Test that GDB steps over all breakpoints of threads not the stepping
17 # thread, before actually proceeding with the stepped thread.
20 set executable ${testfile}
22 if [target_info exists gdb,nosignals] {
23 verbose "Skipping ${testfile}.exp because of nosignals."
27 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
28 executable [list debug "incdir=${objdir}"]] != "" } {
32 # Prepare environment for test. PREFIX is used as prefix in test
35 proc setup { prefix } {
38 with_test_prefix $prefix {
39 clean_restart $executable
45 gdb_breakpoint [gdb_get_line_number "set wait-threads breakpoint here"]
46 gdb_continue_to_breakpoint "run to breakpoint"
47 gdb_test "info threads" "3 .* 2 .*\\\* 1.*" "info threads shows all threads"
49 gdb_test_no_output "set scheduler-locking on"
51 gdb_breakpoint [gdb_get_line_number "set breakpoint thread 3 here"]
52 gdb_breakpoint [gdb_get_line_number "set breakpoint thread 2 here"]
54 gdb_test "thread 3" "Switching.*"
55 gdb_continue_to_breakpoint "run to breakpoint in thread 3"
56 gdb_test "p *myp = 0" " = 0" "unbreak loop in thread 3"
58 gdb_test "thread 2" "Switching.*"
59 gdb_continue_to_breakpoint "run to breakpoint in thread 2"
60 gdb_test "p *myp = 0" " = 0" "unbreak loop in thread 2"
62 # Switch back to thread 1 and disable scheduler locking.
63 gdb_test "thread 1" "Switching.*"
64 gdb_test_no_output "set scheduler-locking off"
66 # Now all 3 threads are stopped for a breakpoint that needs to
67 # be stepped over before thread 1 is resumed.
72 gdb_test "step" "in wait_threads .*"
75 gdb_test "set debug infrun 1" ".*"
76 gdb_test "next" "pthread_join.*"
79 gdb_breakpoint [gdb_get_line_number "EXIT_SUCCESS"]
80 gdb_test "continue" "EXIT_SUCCESS.*"