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