gdb:
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / siginfo.exp
CommitLineData
4c38e0a4 1# Copyright 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
78cef34b
AC
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
78cef34b 6# (at your option) any later version.
e22f8b7c 7#
78cef34b
AC
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.
e22f8b7c 12#
78cef34b 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
78cef34b
AC
15
16
17# The program siginfo.c creates a backtrace containing a signal
18# handler registered using sigaction's sa_sigaction / SA_SIGINFO.
19# Some OS's (e.g., GNU/Linux) use different signal trampolines for
20# sa_sigaction and sa_handler.
21
22# This test first confirms that GDB can backtrace through the
23# alternative sa_sigaction signal handler, and second that GDB can
24# nexti/stepi out of such a handler.
25
26if [target_info exists gdb,nosignals] {
27 verbose "Skipping signals.exp because of nosignals."
28 continue
29}
30
31if $tracelevel then {
32 strace $tracelevel
33}
34
78cef34b
AC
35
36set testfile siginfo
37set srcfile ${testfile}.c
38set binfile ${objdir}/${subdir}/${testfile}
39if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
ef783a7d 40 untested "Couldn't compile ${srcfile}.c"
78cef34b
AC
41 return -1
42}
43
44# get things started
45gdb_exit
46gdb_start
47gdb_reinitialize_dir $srcdir/$subdir
48gdb_load ${binfile}
49
50gdb_test "display/i \$pc"
51
52# Advance to main
53if { ![runto_main] } then {
54 gdb_suppress_tests;
55}
56
57# Pass all the alarms straight through (but verbosely)
58# gdb_test "handle SIGALRM print pass nostop"
59# gdb_test "handle SIGVTALRM print pass nostop"
60# gdb_test "handle SIGPROF print pass nostop"
61
62# Run to the signal handler, validate the backtrace.
63gdb_test "break handler"
64gdb_test "continue" ".* handler .*" "continue to stepi handler"
65send_gdb "bt\n"
66gdb_expect_list "backtrace for nexti" ".*$gdb_prompt $" {
67 "\[\r\n\]+.0 \[^\r\n\]* handler "
68 "\[\r\n\]+.1 .signal handler called."
69 "\[\r\n\]+.2 \[^\r\n\]* main .*"
70}
71
72# Check that GDB can step the inferior back to main
73set test "step out of handler"
74gdb_test_multiple "step" "${test}" {
8608915f 75 -re "Could not insert single-step breakpoint.*$gdb_prompt $" {
bbc8b958 76 setup_kfail gdb/1736 sparc*-*-openbsd*
8608915f
MK
77 fail "$test (could not insert single-step breakpoint)"
78 }
78cef34b
AC
79 -re "done = 1;.*${gdb_prompt} $" {
80 send_gdb "$i\n"
81 exp_continue
82 }
83 -re "\} .. handler .*${gdb_prompt} $" {
84 send_gdb "step\n"
85 exp_continue
86 }
61bcae62
AC
87 -re "Program exited normally.*${gdb_prompt} $" {
88 kfail gdb/1613 "$test (program exited)"
89 }
90 -re "(while ..done|return 0).*${gdb_prompt} $" {
91 # After stepping out of a function /r signal-handler, GDB will
92 # advance the inferior until it is at the first instruction of
93 # a code-line. While typically things return to the middle of
94 # the "while..." (and hence GDB advances the inferior to the
95 # "return..." line) it is also possible for the return to land
96 # on the first instruction of "while...". Accept both cases.
78cef34b
AC
97 pass "$test"
98 }
99}
This page took 0.620855 seconds and 4 git commands to generate.