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/>. */
18 require {!target_info exists gdb,nosignals}
20 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
21 executable { debug }] != "" } {
25 # Run test proper. COMMAND indicates whether to resume the inferior
26 # with "signal 0" or "continue".
28 proc test { command } {
29 global srcfile binfile tdlabel_re
31 with_test_prefix "$command" {
32 clean_restart ${binfile}
38 gdb_test "handle SIGUSR1 stop print pass"
40 gdb_test "continue" "Thread 2 .*received signal SIGUSR1.*" "stop with SIGUSR1"
42 set pattern "\\\* 2\[ \t\]+${tdlabel_re}.*"
44 gdb_test "info threads" $pattern "thread 2 intercepted signal"
46 gdb_test "break handler" "Breakpoint .* at .*$srcfile.*"
48 gdb_test "thread 1" "Switching to thread 1.*"
50 if { $command == "continue" } {
51 gdb_test "continue" "handler .*"
52 } elseif { $command == "signal 0" } {
54 set test "signal 0 queries"
55 gdb_test_multiple "signal 0" $test {
56 -re "stopped with.*stopped with.*Continue anyway.*y or n. $" {
57 fail "$test (multiple threads noted)"
60 -re "stopped with signal SIGUSR1.*\r\nContinuing .*still deliver .*Continue anyway.*y or n. $" {
64 -re "Continue anyway.*y or n. $" {
65 fail "$test (no threads noted)"
71 gdb_test "y" "handler .*" "signal is delivered"
75 gdb_test "info threads" $pattern "thread 2 got the signal"
79 foreach command {"continue" "signal 0"} {