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
|
# Copyright 2014 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 that "file" doesn't leave stale breakpoints planted in the
# target.
standard_testfile
if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
return -1
}
if ![runto_main] then {
fail "Can't run to main"
return 0
}
# Run the test proper. ALWAYS_INSERT determines whether
# always-inserted mode is on/off, and BREAK_COMMAND is the break
# command being tested.
#
proc test_break { always_inserted break_command } {
global gdb_prompt binfile hex
with_test_prefix "always-inserted $always_inserted: $break_command" {
clean_restart $binfile
if ![runto_main] then {
fail "Can't run to main"
return
}
delete_breakpoints
gdb_test_no_output "set breakpoint always-inserted $always_inserted"
set test "$break_command foo"
gdb_test_multiple "$break_command foo" $test {
-re "No hardware breakpoint support in the target.*$gdb_prompt $" {
unsupported $test
return
}
-re "Hardware breakpoints used exceeds limit.*$gdb_prompt $" {
unsupported $test
return
}
-re "Cannot insert hardware breakpoint.*$gdb_prompt $" {
unsupported $test
return
}
-re ".*reakpoint .* at .*$gdb_prompt $" {
pass $test
}
}
# The breakpoint shouldn't be pending now.
gdb_test "info break" "y.*$hex.*in foo at.*" \
"breakpoint is not pending"
# Remove the file, while the breakpoint above is inserted in a
# function in the main objfile. GDB used to have a bug where
# it would mark the breakpoint as uninserted, but actually
# would leave it inserted in the target.
set test "file"
gdb_test_multiple "file" $test {
-re "Are you sure you want to change the file. .*y or n. $" {
send_gdb "y\n"
exp_continue
}
-re "Discard symbol table from `.*'? .y or n. $" {
send_gdb "y\n"
exp_continue
}
-re "No symbol file now\\.\r\n$gdb_prompt $" {
pass $test
}
}
gdb_test "info break" "y.*PENDING.*foo" \
"breakpoint is not pending"
# Now delete the breakpoint from GDB's tables, to make sure
# GDB doesn't reinsert it, masking the bug (with the bug, on
# re-insert, GDB would fill the shadow buffer with a
# breakpoint instruction). Avoid delete_breakpoints as that
# doesn't record a pass/fail.
gdb_test "delete" "" "delete all breakpoints" \
"Delete all breakpoints.*y or n.*$" "y"
# Re-add symbols back.
set test "file \$binfile"
gdb_test_multiple "file $binfile" $test {
-re "Are you sure you want to change the file. .*y or n. $" {
send_gdb "y\n"
exp_continue
}
-re "Reading symbols from.*done.*$gdb_prompt $" {
pass $test
}
}
# Run to another function now. With the bug, GDB would trip
# on a spurious trap at foo.
gdb_test "b bar" ".*reakpoint .* at .*"
gdb_test "continue" "Breakpoint .*, bar .*"
}
}
# While it doesn't trigger the original bug this is a regression test
# for, test with breakpoint always-inserted off for extra coverage.
foreach always_inserted { "off" "on" } {
test_break $always_inserted "break"
if {![skip_hw_breakpoint_tests]} {
test_break $always_inserted "hbreak"
}
}
|