1 # Copyright 2021-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 stepping over a breakpoint installed on an instruction that
17 # exits the thread, while another thread is repeatedly hitting a
18 # breakpoint, causing GDB to stop all threads.
22 set syscalls_src $srcdir/lib/my-syscalls.S
24 if { [build_executable "failed to prepare" $testfile \
25 [list $srcfile $syscalls_src] {debug pthreads}] == -1 } {
29 proc test {displaced-stepping target-non-stop} {
30 save_vars ::GDBFLAGS {
31 append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\""
32 clean_restart $::binfile
35 gdb_test_no_output "set displaced-stepping ${displaced-stepping}"
37 if { ![runto_main] } {
41 # The "stepper over exit" threads will step over an instruction
42 # that causes them to exit.
43 gdb_test "break my_exit_syscall if 0"
45 # The "breakpoint hitter" thread will repeatedly hit this
46 # breakpoint, causing GDB to stop all threads.
47 gdb_test "break break_here"
49 # To avoid flooding the log with thread created/exited messages.
50 gdb_test_no_output "set print thread-events off"
52 # Make sure the target reports the breakpoint stops.
53 gdb_test_no_output "set breakpoint condition-evaluation host"
55 for { set i 0 } { $i < 30 } { incr i } {
56 with_test_prefix "iter $i" {
57 if { [gdb_test "continue" "hit Breakpoint $::decimal, break_here .*"] != 0 } {
58 # Exit if there's a failure to avoid lengthy timeouts.
65 foreach_with_prefix displaced-stepping {off auto} {
66 foreach_with_prefix target-non-stop {off on} {
67 test ${displaced-stepping} ${target-non-stop}