1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Test support for stepping over longjmp.
#
if $tracelevel then {
strace $tracelevel
}
set prms_id 0
set bug_id 0
set testfile "longjmp"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
untested longjmp.exp
return -1
}
if [get_compiler_info ${binfile}] {
return -1
}
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
if ![runto_main] then {
fail "Can't run to main"
return 0
}
set bp_miss_step_1 [gdb_get_line_number "miss_step_1"]
set bp_miss_step_2 [gdb_get_line_number "miss_step_2"]
set bp_start_test_1 [gdb_get_line_number "patt1"]
set bp_start_test_2 [gdb_get_line_number "patt2"]
set bp_start_test_3 [gdb_get_line_number "patt3"]
#
# Pattern 1 - simple longjmp.
#
delete_breakpoints
gdb_test "break $bp_start_test_1" \
"Breakpoint.*at.* file .*$srcfile, line.*$bp_start_test_1.*" \
"breakpoint at pattern 1 start"
gdb_test "continue" "patt1.*" "continue to breakpoint at pattern 1 start"
# set safe-net break
gdb_test "break $bp_miss_step_1" \
"Breakpoint.*at.* file .*$srcfile, line.*$bp_miss_step_1.*" \
"breakpoint at miss_step_1"
gdb_test "next" "longjmps\\+\\+;.*" "next over setjmp (1)"
gdb_test "next" "longjmp \\(env, 1\\);.*" "next to longjmp (1)"
set msg "next over longjmp(1)"
gdb_test_multiple "next" $msg {
-re ".*patt1.*$gdb_prompt $" {
pass $msg
gdb_test "next" "resumes\\+\\+.*" "next into else block (1)"
gdb_test "next" "miss_step_1.*" "next into safety net (1)"
}
-re "miss_step_1.*$gdb_prompt $" {
fail $msg
}
}
#
# Pattern 2 - longjmp from an inner function.
#
delete_breakpoints
gdb_test "break $bp_start_test_2" \
"Breakpoint.*at.* file .*$srcfile, line.*$bp_start_test_2.*" \
"breakpoint at pattern 2 start"
gdb_test "continue" "patt2.*" "continue to breakpoint at pattern 2 start"
# set safe-net break
gdb_test "break $bp_miss_step_2" \
"Breakpoint.*at.* file .*$srcfile, line.*$bp_miss_step_2.*" \
"breakpoint at miss_step_2"
gdb_test "next" "call_longjmp.*" "next over setjmp (2)"
set msg "next over call_longjmp (2)"
gdb_test_multiple "next" $msg {
-re ".*patt2.*$gdb_prompt $" {
pass $msg
gdb_test "next" "resumes\\+\\+.*" "next into else block (2)"
gdb_test "next" "miss_step_2.*" "next into safety net (2)"
}
-re "miss_step_2.*$gdb_prompt $" {
fail $msg
}
}
#
# Pattern 3 - setjmp/longjmp inside stepped-over function.
#
delete_breakpoints
gdb_test "break $bp_start_test_3" \
"Breakpoint.*at.* file .*$srcfile, line.*$bp_start_test_3.*" \
"breakpoint at pattern 3 start"
gdb_test "continue" "patt3.*" "continue to breakpoint at pattern 3 start"
gdb_test "next" "longjmp caught.*" "next over patt3"
|