Commit | Line | Data |
---|---|---|
30852783 UW |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
0b302171 | 3 | # Copyright 2011-2012 Free Software Foundation, Inc. |
30852783 UW |
4 | |
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation; either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
18 | set testfile "signest" | |
19 | set srcfile ${testfile}.c | |
20 | ||
21 | if [target_info exists gdb,nosignals] { | |
22 | verbose "Skipping ${testfile}.exp because of nosignals." | |
23 | return -1 | |
24 | } | |
25 | ||
26 | if [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug}] { | |
27 | untested ${testfile}.exp | |
28 | return -1 | |
29 | } | |
30 | ||
31 | if ![runto_main] then { | |
32 | untested ${testfile}.exp | |
33 | return -1 | |
34 | } | |
35 | ||
36 | # If we can examine what's at memory address 0, it is possible that we | |
37 | # could also execute it. This could probably make us run away, | |
38 | # executing random code, which could have all sorts of ill effects, | |
39 | # especially on targets without an MMU. Don't run the tests in that | |
40 | # case. | |
41 | ||
42 | gdb_test_multiple "x 0" "memory at address 0" { | |
43 | -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { } | |
44 | -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { } | |
45 | -re ".*$gdb_prompt $" { | |
46 | untested "Memory at address 0 is possibly executable" | |
47 | return -1 | |
48 | } | |
49 | } | |
50 | ||
51 | # Run until we hit the SIGSEGV (or SIGBUS on some platforms). | |
52 | gdb_test "continue" \ | |
53 | ".*Program received signal (SIGBUS|SIGSEGV).*bowler.*" \ | |
54 | "continue to fault" | |
55 | ||
56 | # Insert conditional breakpoint at faulting instruction | |
57 | gdb_test "break if 0" ".*" "set conditional breakpoint" | |
58 | ||
59 | # Set SIGSEGV/SIGBUS to pass+nostop | |
60 | gdb_test "handle SIGSEGV nostop print pass" ".*" "pass SIGSEGV" | |
61 | gdb_test "handle SIGBUS nostop print pass" ".*" "pass SIGBUS" | |
62 | ||
63 | # Step off the faulting instruction into the handler, triggering nested faults | |
64 | gdb_test "continue" \ | |
65 | ".*Program received signal (SIGBUS|SIGSEGV).*Program received signal (SIGBUS|SIGSEGV).*exited normally.*" \ | |
66 | "run through nested faults" | |
67 |