Commit | Line | Data |
---|---|---|
0b302171 | 1 | # Copyright 2004, 2007-2012 Free Software Foundation, Inc. |
44f4de1a 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 |
44f4de1a | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
44f4de1a 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 | # |
44f4de1a | 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/>. |
44f4de1a AC |
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 | ||
44f4de1a AC |
30 | |
31 | set testfile sigaltstack | |
32 | set srcfile ${testfile}.c | |
33 | set binfile ${objdir}/${subdir}/${testfile} | |
34 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
ef783a7d | 35 | untested "Couldn't compile ${srcfile}.c" |
44f4de1a AC |
36 | return -1 |
37 | } | |
38 | ||
39 | # get things started | |
40 | gdb_exit | |
41 | gdb_start | |
42 | gdb_reinitialize_dir $srcdir/$subdir | |
43 | gdb_load ${binfile} | |
44 | ||
45 | # Pass all the alarms straight through (but verbosely) | |
46 | gdb_test "handle SIGALRM print pass nostop" | |
47 | gdb_test "handle SIGVTALRM print pass nostop" | |
48 | gdb_test "handle SIGPROF print pass nostop" | |
49 | ||
50 | # Advance to main | |
51 | if { ![runto_main] } then { | |
52 | gdb_suppress_tests; | |
53 | } | |
54 | ||
55 | # Stop in handle, when at the inner most level | |
56 | gdb_test "break catcher if level == INNER" | |
57 | gdb_test "continue" ".* catcher .*" "continue to catch" | |
58 | # step off the assignment | |
59 | gdb_test "next" | |
60 | ||
61 | # Full backtrace? | |
5fa290c1 | 62 | gdb_test_sequence "bt" "backtrace" { |
44f4de1a AC |
63 | "\[\r\n\]+.0 \[^\r\n\]* catcher " |
64 | "\[\r\n\]+.1 .signal handler called." | |
65 | "\[\r\n\]+.2 \[^\r\n\]* thrower .next_level=INNER" | |
66 | "\[\r\n\]+.3 \[^\r\n\]* catcher " | |
67 | "\[\r\n\]+.4 .signal handler called." | |
68 | "\[\r\n\]+.5 \[^\r\n\]* thrower .next_level=OUTER" | |
69 | "\[\r\n\]+.6 \[^\r\n\]* catcher " | |
5fa290c1 | 70 | "\[\r\n\]+.7 \[^\r\n\]* main " |
44f4de1a AC |
71 | } |
72 | ||
d2f6abb0 | 73 | proc finish_test { pattern msg } { |
04f6ecf2 DJ |
74 | global gdb_prompt |
75 | ||
d2f6abb0 | 76 | gdb_test_multiple "finish" $msg { |
04f6ecf2 | 77 | -re "Cannot insert breakpoint 0.*${gdb_prompt} $" { |
d2f6abb0 DJ |
78 | # Some platforms use a special read-only page for signal |
79 | # trampolines. We can't set a breakpoint there, and we | |
80 | # don't gracefully fall back to single-stepping. | |
bbc8b958 TT |
81 | setup_kfail gdb/1736 "i?86-*-linux*" |
82 | setup_kfail gdb/1736 "*-*-openbsd*" | |
d2f6abb0 DJ |
83 | fail "$msg (could not set breakpoint)" |
84 | } | |
6a89fc9c | 85 | -re "$pattern.*${gdb_prompt} $" { |
d2f6abb0 DJ |
86 | pass $msg |
87 | } | |
88 | } | |
89 | } | |
90 | ||
44f4de1a | 91 | # Finish? |
d2f6abb0 DJ |
92 | finish_test "signal handler called." "finish from catch LEAF" |
93 | finish_test "thrower .next_level=INNER, .*" "finish to throw INNER" | |
94 | finish_test "catcher .*" "finish to catch INNER" | |
95 | finish_test "signal handler called.*" "finish from catch INNER" | |
96 | finish_test "thrower .next_level=OUTER, .*" "finish to OUTER" | |
97 | finish_test "catcher .*" "finish to catch MAIN" | |
98 | finish_test "main .*" "finish to MAIN" |