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