1 # Copyright (C) 2014-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/>. */
18 if [target_info exists gdb,nosignals] {
19 verbose "Skipping ${testfile}.exp because of nosignals."
23 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
24 executable { debug }] != "" } {
28 # Run test proper. COMMAND indicates whether to resume the inferior
29 # with "signal 0" or "continue".
31 proc test { command } {
32 global srcfile binfile
34 with_test_prefix "$command" {
35 clean_restart ${binfile}
37 if ![runto_main] then {
41 gdb_test "handle SIGUSR1 stop print pass"
43 gdb_test "continue" "Thread 2 .*received signal SIGUSR1.*" "stop with SIGUSR1"
45 set pattern "\\\* 2\[ \t\]+Thread.*"
47 gdb_test "info threads" $pattern "thread 2 intercepted signal"
49 gdb_test "break handler" "Breakpoint .* at .*$srcfile.*"
51 gdb_test "thread 1" "Switching to thread 1.*"
53 if { $command == "continue" } {
54 gdb_test "continue" "handler .*"
55 } elseif { $command == "signal 0" } {
57 set test "signal 0 queries"
58 gdb_test_multiple "signal 0" $test {
59 -re "stopped with.*stopped with.*Continue anyway.*y or n. $" {
60 fail "$test (multiple threads noted)"
63 -re "stopped with signal SIGUSR1.*\r\nContinuing .*still deliver .*Continue anyway.*y or n. $" {
67 -re "Continue anyway.*y or n. $" {
68 fail "$test (no threads noted)"
74 gdb_test "y" "handler .*" "signal is delivered"
78 gdb_test "info threads" $pattern "thread 2 got the signal"
82 foreach command {"continue" "signal 0"} {