1 # Copyright 2021-2022 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
21 set syscalls_src $srcdir/lib/my-syscalls.S
23 if { [build_executable "failed to prepare" $testfile \
24 [list $srcfile $syscalls_src] {debug pthreads}] == -1 } {
28 # Each argument is a different testing axis, most of them obvious.
29 # NS_STOP_ALL is only used if testing "set non-stop on", and indicates
30 # whether to have GDB explicitly stop all threads before continuing to
32 proc test {displaced-stepping non-stop target-non-stop schedlock ns_stop_all} {
33 if {${non-stop} == "off" && $ns_stop_all} {
34 error "invalid arguments"
37 save_vars ::GDBFLAGS {
38 append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\""
39 append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
40 clean_restart $::binfile
43 gdb_test_no_output "set displaced-stepping ${displaced-stepping}"
45 if { ![runto_main] } {
49 gdb_breakpoint "my_exit_syscall"
52 || (${non-stop} == "on" && $ns_stop_all)} {
54 "Thread 2 .*hit Breakpoint $::decimal.* my_exit_syscall .*" \
55 "continue until syscall"
57 if {${non-stop} == "on"} {
58 # The test only spawns one thread at a time, so this just
59 # stops the main thread.
60 gdb_test_multiple "interrupt -a" "" {
61 -re "$::gdb_prompt " {
62 gdb_test_multiple "" $gdb_test_name {
63 -re "Thread 1 \[^\r\n\]*stopped." {
71 gdb_test "thread 2" "Switching to thread 2 .*"
73 gdb_test_no_output "set scheduler-locking ${schedlock}"
76 "No unwaited-for children left." \
77 "continue stops when thread exits"
79 gdb_test_no_output "set scheduler-locking ${schedlock}"
81 for { set i 0 } { $i < 100 } { incr i } {
82 with_test_prefix "iter $i" {
84 set thread "<unknown>"
85 gdb_test_multiple "continue" "" {
86 -re -wrap "Thread ($::decimal) .*hit Breakpoint $::decimal.* my_exit_syscall .*" {
87 set thread $expect_out(1,string)
92 # Exit if there's a failure to avoid lengthy
98 gdb_test "thread $thread" "Switching to thread .*" \
99 "switch to event thread"
106 foreach_with_prefix displaced-stepping {off auto} {
107 foreach_with_prefix non-stop {off on} {
108 foreach_with_prefix target-non-stop {off on} {
109 if {${non-stop} == "on" && ${target-non-stop} == "off"} {
110 # Invalid combination.
114 foreach_with_prefix schedlock {off on} {
115 if {${non-stop} == "on"} {
116 foreach_with_prefix ns_stop_all {0 1} {
117 test ${displaced-stepping} ${non-stop} ${target-non-stop} \
118 ${schedlock} ${ns_stop_all}
121 test ${displaced-stepping} ${non-stop} ${target-non-stop} ${schedlock} 0