1 # Copyright 2008-2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Test support for stepping over longjmp.
25 set testfile "longjmp"
26 set srcfile ${testfile}.c
27 set binfile ${objdir}/${subdir}/${testfile}
29 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
34 if [get_compiler_info ${binfile}] {
40 gdb_reinitialize_dir $srcdir/$subdir
43 if ![runto_main] then {
44 fail "Can't run to main"
48 set bp_miss_step_1 [gdb_get_line_number "miss_step_1"]
49 set bp_miss_step_2 [gdb_get_line_number "miss_step_2"]
51 set bp_start_test_1 [gdb_get_line_number "patt1"]
52 set bp_start_test_2 [gdb_get_line_number "patt2"]
53 set bp_start_test_3 [gdb_get_line_number "patt3"]
56 # Pattern 1 - simple longjmp.
61 gdb_test "break $bp_start_test_1" \
62 "Breakpoint.*at.* file .*$srcfile, line.*$bp_start_test_1.*" \
63 "breakpoint at pattern 1 start"
64 gdb_test "continue" "patt1.*" "continue to breakpoint at pattern 1 start"
67 gdb_test "break $bp_miss_step_1" \
68 "Breakpoint.*at.* file .*$srcfile, line.*$bp_miss_step_1.*" \
69 "breakpoint at miss_step_1"
71 gdb_test "next" "longjmps\\+\\+;.*" "next over setjmp (1)"
72 gdb_test "next" "longjmp \\(env, 1\\);.*" "next to longjmp (1)"
74 set msg "next over longjmp(1)"
75 gdb_test_multiple "next" $msg {
76 -re ".*patt1.*$gdb_prompt $" {
78 gdb_test "next" "resumes\\+\\+.*" "next into else block (1)"
79 gdb_test "next" "miss_step_1.*" "next into safety net (1)"
81 -re "miss_step_1.*$gdb_prompt $" {
87 # Pattern 2 - longjmp from an inner function.
92 gdb_test "break $bp_start_test_2" \
93 "Breakpoint.*at.* file .*$srcfile, line.*$bp_start_test_2.*" \
94 "breakpoint at pattern 2 start"
95 gdb_test "continue" "patt2.*" "continue to breakpoint at pattern 2 start"
98 gdb_test "break $bp_miss_step_2" \
99 "Breakpoint.*at.* file .*$srcfile, line.*$bp_miss_step_2.*" \
100 "breakpoint at miss_step_2"
102 gdb_test "next" "call_longjmp.*" "next over setjmp (2)"
104 set msg "next over call_longjmp (2)"
105 gdb_test_multiple "next" $msg {
106 -re ".*patt2.*$gdb_prompt $" {
109 gdb_test "next" "resumes\\+\\+.*" "next into else block (2)"
110 gdb_test "next" "miss_step_2.*" "next into safety net (2)"
112 -re "miss_step_2.*$gdb_prompt $" {
118 # Pattern 3 - setjmp/longjmp inside stepped-over function.
123 gdb_test "break $bp_start_test_3" \
124 "Breakpoint.*at.* file .*$srcfile, line.*$bp_start_test_3.*" \
125 "breakpoint at pattern 3 start"
126 gdb_test "continue" "patt3.*" "continue to breakpoint at pattern 3 start"
128 gdb_test "next" "longjmp caught.*" "next over patt3"