1 # Copyright (C) 2011-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 that GDB steps over all breakpoints of threads not the stepping
17 # thread, before actually proceeding with the stepped thread.
20 set executable ${testfile}
22 if [target_info exists gdb,nosignals] {
23 verbose "Skipping ${testfile}.exp because of nosignals."
27 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
28 executable [list debug "incdir=${objdir}"]] != "" } {
32 # Prepare environment for test.
38 with_test_prefix "setup" {
39 clean_restart $executable
45 gdb_test_no_output "set displaced-stepping $displaced"
47 gdb_breakpoint [gdb_get_line_number "set wait-threads breakpoint here"]
48 gdb_continue_to_breakpoint "run to breakpoint"
49 gdb_test "info threads" "\\\* 1 .* 2 .* 3 .*" "info threads shows all threads"
51 gdb_test_no_output "set scheduler-locking on"
53 gdb_breakpoint [gdb_get_line_number "set breakpoint thread 3 here"]
54 gdb_breakpoint [gdb_get_line_number "set breakpoint thread 2 here"]
56 gdb_test "thread 3" "Switching.*"
57 gdb_continue_to_breakpoint "run to breakpoint in thread 3"
58 gdb_test "p *myp = 0" " = 0" "unbreak loop in thread 3"
60 gdb_test "thread 2" "Switching.*"
61 gdb_continue_to_breakpoint "run to breakpoint in thread 2"
62 gdb_test "p *myp = 0" " = 0" "unbreak loop in thread 2"
64 # Disable scheduler locking.
65 gdb_test_no_output "set scheduler-locking off"
67 # Now all 3 threads are stopped for a breakpoint that needs to
68 # be stepped over before thread 1 is resumed.
72 foreach displaced { "off" "on" } {
73 with_test_prefix "displaced=$displaced" {
74 with_test_prefix "step" {
76 gdb_test "thread 1" "Switching.*"
77 gdb_test "step" "in wait_threads .*"
80 with_test_prefix "next" {
82 gdb_test "thread 1" "Switching.*"
83 gdb_test "next" "pthread_join.*"
86 with_test_prefix "continue" {
88 gdb_breakpoint [gdb_get_line_number "EXIT_SUCCESS"]
89 gdb_test "thread 1" "Switching.*"
90 gdb_test "continue" "EXIT_SUCCESS.*"
93 # Try continuing with a queued signal in each of the threads
94 # (one at a time). Should stop at the signal handler, instead
95 # of re-trapping the breakpoint the threads were already
97 foreach thread {1 2 3} {
98 with_test_prefix "signal thr$thread" {
101 # Queue a signal in THREAD.
102 gdb_test "thread $thread" "Switching.*"
103 gdb_test_no_output "queue-signal SIGUSR1"
105 # Switch back to thread 1, and continue.
106 gdb_test "thread 1" "Switching.*" "switch back to thread 1"
107 gdb_breakpoint "sigusr1_handler" "set break at sigusr1_handler"
109 set msg "continue to sigusr1_handler"
110 gdb_test_multiple "continue" $msg {
111 -re "Breakpoint .* sigusr1_handler .*$gdb_prompt $" {
114 -re "Breakpoint .*$gdb_prompt $" {
115 if {![can_single_step_to_signal_handler]
116 && $thread != 1 && $displaced == "off"} {
117 setup_kfail "gdb/18214" "*-*-*"