2011-05-30 Yao Qi <yao@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / sigaltstack.exp
1 # Copyright 2004, 2007, 2008, 2009, 2010, 2011 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
16
17 # The program sigaltstack.c creates a backtrace containing nested
18 # signal handlers on an alternative stack. This in turn leads to a
19 # non-contiguous (and possibly non-monotonic) backtrace - stack
20 # address jump at the normal-alt stack boundary.
21
22 # This test confirms that GDB can both backtrace through and finish
23 # such a stack.
24
25 if [target_info exists gdb,nosignals] {
26 verbose "Skipping signals.exp because of nosignals."
27 continue
28 }
29
30 if $tracelevel then {
31 strace $tracelevel
32 }
33
34
35 set testfile sigaltstack
36 set srcfile ${testfile}.c
37 set binfile ${objdir}/${subdir}/${testfile}
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39 untested "Couldn't compile ${srcfile}.c"
40 return -1
41 }
42
43 # get things started
44 gdb_exit
45 gdb_start
46 gdb_reinitialize_dir $srcdir/$subdir
47 gdb_load ${binfile}
48
49 # Pass all the alarms straight through (but verbosely)
50 gdb_test "handle SIGALRM print pass nostop"
51 gdb_test "handle SIGVTALRM print pass nostop"
52 gdb_test "handle SIGPROF print pass nostop"
53
54 # Advance to main
55 if { ![runto_main] } then {
56 gdb_suppress_tests;
57 }
58
59 # Stop in handle, when at the inner most level
60 gdb_test "break catcher if level == INNER"
61 gdb_test "continue" ".* catcher .*" "continue to catch"
62 # step off the assignment
63 gdb_test "next"
64
65 # Full backtrace?
66 gdb_test_sequence "bt" "backtrace" {
67 "\[\r\n\]+.0 \[^\r\n\]* catcher "
68 "\[\r\n\]+.1 .signal handler called."
69 "\[\r\n\]+.2 \[^\r\n\]* thrower .next_level=INNER"
70 "\[\r\n\]+.3 \[^\r\n\]* catcher "
71 "\[\r\n\]+.4 .signal handler called."
72 "\[\r\n\]+.5 \[^\r\n\]* thrower .next_level=OUTER"
73 "\[\r\n\]+.6 \[^\r\n\]* catcher "
74 "\[\r\n\]+.7 \[^\r\n\]* main "
75 }
76
77 proc finish_test { pattern msg } {
78 global gdb_prompt
79
80 gdb_test_multiple "finish" $msg {
81 -re "Cannot insert breakpoint 0.*${gdb_prompt} $" {
82 # Some platforms use a special read-only page for signal
83 # trampolines. We can't set a breakpoint there, and we
84 # don't gracefully fall back to single-stepping.
85 setup_kfail gdb/1736 "i?86-*-linux*"
86 setup_kfail gdb/1736 "*-*-openbsd*"
87 fail "$msg (could not set breakpoint)"
88 }
89 -re "$pattern.*${gdb_prompt} $" {
90 pass $msg
91 }
92 }
93 }
94
95 # Finish?
96 finish_test "signal handler called." "finish from catch LEAF"
97 finish_test "thrower .next_level=INNER, .*" "finish to throw INNER"
98 finish_test "catcher .*" "finish to catch INNER"
99 finish_test "signal handler called.*" "finish from catch INNER"
100 finish_test "thrower .next_level=OUTER, .*" "finish to OUTER"
101 finish_test "catcher .*" "finish to catch MAIN"
102 finish_test "main .*" "finish to MAIN"
This page took 0.032654 seconds and 4 git commands to generate.