1# Copyright 2010-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 17set executable ${testfile} 18 19if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { 20 untested "failed to compile" 21 return -1 22} 23 24clean_restart $executable 25 26if ![runto_main] { 27 return -1 28} 29 30# `noprint' would not test the full logic of GDB. 31gdb_test "handle SIGUSR1 nostop print pass" \ 32 "\r\nSIGUSR1\[ \t\]+No\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" 33 34gdb_test_no_output "set scheduler-locking off" 35 36gdb_breakpoint [gdb_get_line_number "step-1"] 37gdb_test_no_output {set $step1=$bpnum} 38gdb_continue_to_breakpoint "step-1" ".* step-1 .*" 39gdb_test_no_output {disable $step1} 40 41# 1 as we are now stopped at the `step-1' label. 42set step_at 1 43for {set i 0} {$i < 100} {incr i} { 44 set test "step $i" 45 # Presume this step failed - as in the case of a timeout. 46 set failed 1 47 gdb_test_multiple "step" $test { 48 -re " received signal SIGUSR1, User defined signal 1.\r\n" { 49 exp_continue -continue_timer 50 } 51 -re "step-(\[012\]).*\r\n$gdb_prompt $" { 52 set now $expect_out(1,string) 53 if {$step_at == 2 && $now == 1} { 54 set failed 0 55 } elseif {$step_at == 1 && $now == 2} { 56 set failed 0 57 # Continue over the re-signalling back to the handle entry. 58 gdb_test_no_output -nopass {enable $step1} 59 gdb_test -nopass "continue" " step-1 .*" 60 set now 1 61 gdb_test_no_output -nopass {disable $step1} 62 } else { 63 fail $test 64 } 65 set step_at $now 66 } 67 } 68 if $failed { 69 return 70 } 71} 72# We can never reliably say the racy problematic case has been tested. 73pass "step" 74