siginfo-threads.exp revision 1.3
1# Copyright 2010-2015 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" 43gdb_test_multiple "p getpid ()" $test { 44 -re " = (\[0-9\]+)\r\n$gdb_prompt $" { 45 set pid $expect_out(1,string) 46 pass $test 47 } 48} 49 50for {set sigcount 0} {$sigcount < 4} {incr sigcount} { 51 set test "catch signal $sigcount" 52 set sigusr "" 53 gdb_test_multiple "continue" $test { 54 -re "Program received signal SIGUSR(\[12\]), User defined signal \[12\]\\.\r\n.*\r\n$gdb_prompt $" { 55 set sigusr $expect_out(1,string) 56 pass $test 57 } 58 } 59 if {$sigusr == ""} { 60 return -1 61 } 62 63 set test "signal $sigcount si_signo" 64 if {$sigusr == 1} { 65 set signo 10 66 } else { 67 set signo 12 68 } 69 gdb_test_multiple {p $_siginfo.si_signo} $test { 70 -re " = $signo\r\n$gdb_prompt $" { 71 pass $test 72 } 73 -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { 74 unsupported $test 75 } 76 } 77 78 set test "signal $sigcount si_code is SI_TKILL" 79 gdb_test_multiple {p $_siginfo.si_code} $test { 80 -re " = -6\r\n$gdb_prompt $" { 81 pass $test 82 } 83 -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { 84 unsupported $test 85 } 86 } 87 88 set test "signal $sigcount si_pid" 89 gdb_test_multiple {p $_siginfo._sifields._kill.si_pid} $test { 90 -re " = $pid\r\n$gdb_prompt $" { 91 pass $test 92 } 93 -re "Attempt to extract a component of a value that is not a structure\\.\r\n$gdb_prompt $" { 94 unsupported $test 95 } 96 } 97} 98 99gdb_continue_to_breakpoint break-at-exit ".*break-at-exit.*" 100