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