Commit | Line | Data |
---|---|---|
e2882c85 | 1 | # Copyright 2004-2018 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 | ||
26 | if [target_info exists gdb,nosignals] { | |
595fc67f | 27 | verbose "Skipping siginfo.exp because of nosignals." |
78cef34b AC |
28 | continue |
29 | } | |
30 | ||
78cef34b | 31 | |
0ab77f5f TT |
32 | standard_testfile |
33 | ||
5b362f04 | 34 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { |
78cef34b AC |
35 | return -1 |
36 | } | |
37 | ||
78cef34b AC |
38 | gdb_test "display/i \$pc" |
39 | ||
40 | # Advance to main | |
41 | if { ![runto_main] } then { | |
4ec70201 | 42 | gdb_suppress_tests |
78cef34b AC |
43 | } |
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 | # Run to the signal handler, validate the backtrace. | |
51 | gdb_test "break handler" | |
52 | gdb_test "continue" ".* handler .*" "continue to stepi handler" | |
5fa290c1 | 53 | gdb_test_sequence "bt" "backtrace for nexti" { |
78cef34b AC |
54 | "\[\r\n\]+.0 \[^\r\n\]* handler " |
55 | "\[\r\n\]+.1 .signal handler called." | |
5fa290c1 | 56 | "\[\r\n\]+.2 \[^\r\n\]* main " |
78cef34b AC |
57 | } |
58 | ||
59 | # Check that GDB can step the inferior back to main | |
60 | set test "step out of handler" | |
61 | gdb_test_multiple "step" "${test}" { | |
8608915f | 62 | -re "Could not insert single-step breakpoint.*$gdb_prompt $" { |
a5b6e449 | 63 | setup_kfail gdb/8841 sparc*-*-openbsd* |
8608915f MK |
64 | fail "$test (could not insert single-step breakpoint)" |
65 | } | |
03346981 SL |
66 | -re "Cannot insert breakpoint.*Cannot access memory.*$gdb_prompt $" { |
67 | setup_kfail gdb/8841 "nios2*-*-linux*" | |
68 | fail "$test (could not insert single-step breakpoint)" | |
69 | } | |
78cef34b AC |
70 | -re "done = 1;.*${gdb_prompt} $" { |
71 | send_gdb "$i\n" | |
72 | exp_continue | |
73 | } | |
74 | -re "\} .. handler .*${gdb_prompt} $" { | |
75 | send_gdb "step\n" | |
76 | exp_continue | |
77 | } | |
fda326dd | 78 | -re "$inferior_exited_re normally.*${gdb_prompt} $" { |
61bcae62 AC |
79 | kfail gdb/1613 "$test (program exited)" |
80 | } | |
81 | -re "(while ..done|return 0).*${gdb_prompt} $" { | |
82 | # After stepping out of a function /r signal-handler, GDB will | |
83 | # advance the inferior until it is at the first instruction of | |
84 | # a code-line. While typically things return to the middle of | |
85 | # the "while..." (and hence GDB advances the inferior to the | |
86 | # "return..." line) it is also possible for the return to land | |
87 | # on the first instruction of "while...". Accept both cases. | |
78cef34b AC |
88 | pass "$test" |
89 | } | |
90 | } |