siginfo-threads.exp revision 1.8
1# Copyright 2010-2019 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}" \ 20 ${binfile} \ 21 executable \ 22 [list debug additional_flags=-lrt]] != "" } { 23 return -1 24} 25 26clean_restart $testfile 27 28if ![runto_main] { 29 return -1 30} 31 32# `nostop noprint pass' could in some cases report false PASS due to 33# the (preempt 'handle') code path in linux-nat.c. 34 35gdb_test "handle SIGUSR1 stop print pass" \ 36 "Signal\[ \t\]+Stop\[ \t\]+Print\[ \t\]+Pass to program\[ \t\]+Description\r\nSIGUSR1\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" 37gdb_test "handle SIGUSR2 stop print pass" \ 38 "Signal\[ \t\]+Stop\[ \t\]+Print\[ \t\]+Pass to program\[ \t\]+Description\r\nSIGUSR2\[ \t\]+Yes\[ \t\]+Yes\[ \t\]+Yes\[ \t\].*" 39 40gdb_breakpoint [gdb_get_line_number "break-at-exit"] 41 42set test "get pid" 43set pid "" 44gdb_test_multiple "p (int) getpid ()" $test { 45 -re " = (\[0-9\]+)\r\n$gdb_prompt $" { 46 set pid $expect_out(1,string) 47 pass $test 48 } 49} 50if {$pid == ""} { 51 untested "failed to get pid" 52 return 53} 54 55for {set sigcount 0} {$sigcount < 4} {incr sigcount} { 56 set test "catch signal $sigcount" 57 set sigusr "" 58 gdb_test_multiple "continue" $test { 59 -re "Thread .* received signal SIGUSR(\[12\]), User defined signal \[12\]\\.\r\n.*\r\n$gdb_prompt $" { 60 set sigusr $expect_out(1,string) 61 pass $test 62 } 63 } 64 if {$sigusr == ""} { 65 return -1 66 } 67 68 set test "signal $sigcount si_signo" 69 if {$sigusr == 1} { 70 set signo 10 71 } else { 72 set signo 12 73 } 74 gdb_test_multiple {p $_siginfo.si_signo} $test { 75 -re " = $signo\r\n$gdb_prompt $" { 76 pass $test 77 } 78 -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { 79 unsupported $test 80 } 81 } 82 83 set test "signal $sigcount si_code is SI_TKILL" 84 gdb_test_multiple {p $_siginfo.si_code} $test { 85 -re " = -6\r\n$gdb_prompt $" { 86 pass $test 87 } 88 -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { 89 unsupported $test 90 } 91 } 92 93 set test "signal $sigcount si_pid" 94 gdb_test_multiple {p $_siginfo._sifields._kill.si_pid} $test { 95 -re " = $pid\r\n$gdb_prompt $" { 96 pass $test 97 } 98 -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { 99 unsupported $test 100 } 101 } 102} 103 104gdb_continue_to_breakpoint break-at-exit ".*break-at-exit.*" 105