1# Copyright (C) 2014-2020 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 behaves correctly when a "next" steps over a call, and 17# another thread hits a breakpoint that doesn't cause a user visible 18# stop (and so needs to be stepped over). GDB used to trip on an 19# invalid assertion - PR17408. 20 21standard_testfile 22 23if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] == -1} { 24 return -1 25} 26 27# Test all "set scheduler-locking" variants. 28foreach schedlock {"off" "step" "on" } { 29 with_test_prefix "schedlock=$schedlock" { 30 clean_restart $binfile 31 32 if ![runto_main] { 33 continue 34 } 35 36 gdb_breakpoint [gdb_get_line_number "set wait-thread breakpoint here"] 37 gdb_continue_to_breakpoint "run to wait-thread breakpoint" 38 gdb_test "info threads" "\\\* 1 .* 2 .*" "info threads shows all threads" 39 40 delete_breakpoints 41 42 gdb_breakpoint [gdb_get_line_number "set breakpoint child here"] 43 # Give it a condition that always fails. 44 gdb_test "condition \$bpnum global_zero == 1" ".*" 45 46 gdb_test_no_output "set scheduler-locking $schedlock" 47 48 # While stepping over the sleep call, the other thread hits a 49 # breakpoint that doesn't cause a user visible stop (and so 50 # needs to be stepped over). The next should complete as if 51 # that breakpoint never triggered. 52 gdb_test "next" "EXIT_SUCCESS.*" "next over function call" 53 } 54} 55