1 # Copyright (C) 2014-2024 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 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.
23 if {[build_executable "failed to prepare" $testfile $srcfile \
24 {debug pthreads}] == -1} {
28 # Test all "set scheduler-locking" variants.
29 foreach schedlock {"off" "step" "on" } {
30 with_test_prefix "schedlock=$schedlock" {
31 clean_restart $binfile
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"
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" ".*"
47 gdb_test_no_output "set scheduler-locking $schedlock"
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"