1# Copyright (C) 2011-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# Test that GDB steps over all breakpoints of threads not the stepping 17# thread, before actually proceeding with the stepped thread. 18 19standard_testfile 20set executable ${testfile} 21 22if [target_info exists gdb,nosignals] { 23 verbose "Skipping ${testfile}.exp because of nosignals." 24 return -1 25} 26 27if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ 28 executable [list debug "incdir=${objdir}"]] != "" } { 29 return -1 30} 31 32# Prepare environment for test. PREFIX is used as prefix in test 33# messages. 34 35proc setup { prefix } { 36 global executable 37 38 with_test_prefix $prefix { 39 clean_restart $executable 40 41 if ![runto_main] { 42 return -1 43 } 44 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" 48 49 gdb_test_no_output "set scheduler-locking on" 50 51 gdb_breakpoint [gdb_get_line_number "set breakpoint thread 3 here"] 52 gdb_breakpoint [gdb_get_line_number "set breakpoint thread 2 here"] 53 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" 57 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" 61 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" 65 66 # Now all 3 threads are stopped for a breakpoint that needs to 67 # be stepped over before thread 1 is resumed. 68 } 69} 70 71setup "step" 72gdb_test "step" "in wait_threads .*" 73 74setup "next" 75gdb_test "set debug infrun 1" ".*" 76gdb_test "next" "pthread_join.*" 77 78setup "continue" 79gdb_breakpoint [gdb_get_line_number "EXIT_SUCCESS"] 80gdb_test "continue" "EXIT_SUCCESS.*" 81