Various spelling fixes.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / longjmp.exp
CommitLineData
7b6bb8da 1# Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
9dd789d0
PA
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# Test support for stepping over longjmp.
18#
19
20if $tracelevel then {
21 strace $tracelevel
22}
23
9dd789d0
PA
24
25set testfile "longjmp"
26set srcfile ${testfile}.c
27set binfile ${objdir}/${subdir}/${testfile}
28
29if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
30 untested longjmp.exp
31 return -1
32}
33
34if [get_compiler_info ${binfile}] {
35 return -1
36}
37
38gdb_exit
39gdb_start
40gdb_reinitialize_dir $srcdir/$subdir
41gdb_load ${binfile}
42
43if ![runto_main] then {
44 fail "Can't run to main"
45 return 0
46}
47
48set bp_miss_step_1 [gdb_get_line_number "miss_step_1"]
49set bp_miss_step_2 [gdb_get_line_number "miss_step_2"]
50
51set bp_start_test_1 [gdb_get_line_number "patt1"]
52set bp_start_test_2 [gdb_get_line_number "patt2"]
53set bp_start_test_3 [gdb_get_line_number "patt3"]
54
55#
56# Pattern 1 - simple longjmp.
57#
58
59delete_breakpoints
60
61gdb_test "break $bp_start_test_1" \
62 "Breakpoint.*at.* file .*$srcfile, line.*$bp_start_test_1.*" \
63 "breakpoint at pattern 1 start"
64gdb_test "continue" "patt1.*" "continue to breakpoint at pattern 1 start"
65
66# set safe-net break
67gdb_test "break $bp_miss_step_1" \
68 "Breakpoint.*at.* file .*$srcfile, line.*$bp_miss_step_1.*" \
69 "breakpoint at miss_step_1"
70
71gdb_test "next" "longjmps\\+\\+;.*" "next over setjmp (1)"
72gdb_test "next" "longjmp \\(env, 1\\);.*" "next to longjmp (1)"
73
74set msg "next over longjmp(1)"
75gdb_test_multiple "next" $msg {
103a8671 76 -re ".*patt1.*$gdb_prompt $" {
9dd789d0
PA
77 pass $msg
78 gdb_test "next" "resumes\\+\\+.*" "next into else block (1)"
79 gdb_test "next" "miss_step_1.*" "next into safety net (1)"
80 }
103a8671 81 -re "miss_step_1.*$gdb_prompt $" {
9dd789d0
PA
82 fail $msg
83 }
84}
85
86#
87# Pattern 2 - longjmp from an inner function.
88#
89
90delete_breakpoints
91
92gdb_test "break $bp_start_test_2" \
93 "Breakpoint.*at.* file .*$srcfile, line.*$bp_start_test_2.*" \
94 "breakpoint at pattern 2 start"
95gdb_test "continue" "patt2.*" "continue to breakpoint at pattern 2 start"
96
97# set safe-net break
98gdb_test "break $bp_miss_step_2" \
99 "Breakpoint.*at.* file .*$srcfile, line.*$bp_miss_step_2.*" \
100 "breakpoint at miss_step_2"
101
102gdb_test "next" "call_longjmp.*" "next over setjmp (2)"
103
104set msg "next over call_longjmp (2)"
105gdb_test_multiple "next" $msg {
103a8671 106 -re ".*patt2.*$gdb_prompt $" {
9dd789d0
PA
107 pass $msg
108
109 gdb_test "next" "resumes\\+\\+.*" "next into else block (2)"
110 gdb_test "next" "miss_step_2.*" "next into safety net (2)"
111 }
103a8671 112 -re "miss_step_2.*$gdb_prompt $" {
9dd789d0
PA
113 fail $msg
114 }
115}
116
117#
118# Pattern 3 - setjmp/longjmp inside stepped-over function.
119#
120
121delete_breakpoints
122
123gdb_test "break $bp_start_test_3" \
124 "Breakpoint.*at.* file .*$srcfile, line.*$bp_start_test_3.*" \
125 "breakpoint at pattern 3 start"
126gdb_test "continue" "patt3.*" "continue to breakpoint at pattern 3 start"
127
128gdb_test "next" "longjmp caught.*" "next over patt3"
This page took 0.349874 seconds and 4 git commands to generate.