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