1# Copyright (C) 2014-2023 Free Software Foundation, Inc. 2 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. 7# 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. 12# 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/>. */ 15 16standard_testfile 17 18if [target_info exists gdb,nosignals] { 19 verbose "Skipping ${testfile}.exp because of nosignals." 20 return -1 21} 22 23if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ 24 executable { debug }] != "" } { 25 return -1 26} 27 28# Run test proper. COMMAND indicates whether to resume the inferior 29# with "signal 0" or "continue". 30 31proc test { command } { 32 global srcfile binfile 33 34 with_test_prefix "$command" { 35 clean_restart ${binfile} 36 37 if {![runto_main]} { 38 return 0 39 } 40 41 gdb_test "handle SIGUSR1 stop print pass" 42 43 gdb_test "continue" "Thread 2 .*received signal SIGUSR1.*" "stop with SIGUSR1" 44 45 set pattern "\\\* 2\[ \t\]+Thread.*" 46 47 gdb_test "info threads" $pattern "thread 2 intercepted signal" 48 49 gdb_test "break handler" "Breakpoint .* at .*$srcfile.*" 50 51 gdb_test "thread 1" "Switching to thread 1.*" 52 53 if { $command == "continue" } { 54 gdb_test "continue" "handler .*" 55 } elseif { $command == "signal 0" } { 56 set queried 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)" 61 set queried 1 62 } 63 -re "stopped with signal SIGUSR1.*\r\nContinuing .*still deliver .*Continue anyway.*y or n. $" { 64 pass $test 65 set queried 1 66 } 67 -re "Continue anyway.*y or n. $" { 68 fail "$test (no threads noted)" 69 set queried 1 70 } 71 } 72 73 if {$queried} { 74 gdb_test "y" "handler .*" "signal is delivered" 75 } 76 } 77 78 gdb_test "info threads" $pattern "thread 2 got the signal" 79 } 80} 81 82foreach command {"continue" "signal 0"} { 83 test $command 84} 85