1# Copyright 2004 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 2 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, write to the Free Software 15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 17 18# The program siginfo.c creates a backtrace containing a signal 19# handler registered using sigaction's sa_sigaction / SA_SIGINFO. 20# Some OS's (e.g., GNU/Linux) use different signal trampolines for 21# sa_sigaction and sa_handler. 22 23# This test first confirms that GDB can backtrace through the 24# alternative sa_sigaction signal handler, and second that GDB can 25# nexti/stepi out of such a handler. 26 27if [target_info exists gdb,nosignals] { 28 verbose "Skipping signals.exp because of nosignals." 29 continue 30} 31 32if $tracelevel then { 33 strace $tracelevel 34} 35 36set prms_id 0 37set bug_id 0 38 39set testfile siginfo 40set srcfile ${testfile}.c 41set binfile ${objdir}/${subdir}/${testfile} 42if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { 43 untested "Couldn't compile ${module}.c" 44 return -1 45} 46 47# get things started 48gdb_exit 49gdb_start 50gdb_reinitialize_dir $srcdir/$subdir 51gdb_load ${binfile} 52 53gdb_test "display/i \$pc" 54 55# Advance to main 56if { ![runto_main] } then { 57 gdb_suppress_tests; 58} 59 60# Pass all the alarms straight through (but verbosely) 61# gdb_test "handle SIGALRM print pass nostop" 62# gdb_test "handle SIGVTALRM print pass nostop" 63# gdb_test "handle SIGPROF print pass nostop" 64 65# Run to the signal handler, validate the backtrace. 66gdb_test "break handler" 67gdb_test "continue" ".* handler .*" "continue to stepi handler" 68send_gdb "bt\n" 69gdb_expect_list "backtrace for nexti" ".*$gdb_prompt $" { 70 "\[\r\n\]+.0 \[^\r\n\]* handler " 71 "\[\r\n\]+.1 .signal handler called." 72 "\[\r\n\]+.2 \[^\r\n\]* main .*" 73} 74 75# Check that GDB can step the inferior back to main 76set test "step out of handler" 77gdb_test_multiple "step" "${test}" { 78 -re "done = 1;.*${gdb_prompt} $" { 79 send_gdb "$i\n" 80 exp_continue 81 } 82 -re "\} .. handler .*${gdb_prompt} $" { 83 send_gdb "step\n" 84 exp_continue 85 } 86 -re "Program exited normally.*${gdb_prompt} $" { 87 kfail gdb/1613 "$test (program exited)" 88 } 89 -re "(while ..done|return 0).*${gdb_prompt} $" { 90 # After stepping out of a function /r signal-handler, GDB will 91 # advance the inferior until it is at the first instruction of 92 # a code-line. While typically things return to the middle of 93 # the "while..." (and hence GDB advances the inferior to the 94 # "return..." line) it is also possible for the return to land 95 # on the first instruction of "while...". Accept both cases. 96 pass "$test" 97 } 98} 99