]>
Commit | Line | Data |
---|---|---|
08351840 PA |
1 | # Copyright 2014 Free Software Foundation, Inc. |
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 | # Test that "file" doesn't leave stale breakpoints planted in the | |
17 | # target. | |
18 | ||
19 | standard_testfile | |
20 | ||
21 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { | |
22 | return -1 | |
23 | } | |
24 | ||
25 | if ![runto_main] then { | |
26 | fail "Can't run to main" | |
27 | return 0 | |
28 | } | |
29 | ||
30 | # Run the test proper. ALWAYS_INSERT determines whether | |
31 | # always-inserted mode is on/off, and BREAK_COMMAND is the break | |
32 | # command being tested. | |
33 | # | |
34 | proc test_break { always_inserted break_command } { | |
35 | global gdb_prompt binfile hex | |
36 | ||
37 | with_test_prefix "always-inserted $always_inserted: $break_command" { | |
38 | clean_restart $binfile | |
39 | ||
40 | if ![runto_main] then { | |
41 | fail "Can't run to main" | |
42 | return | |
43 | } | |
44 | ||
45 | delete_breakpoints | |
46 | ||
47 | gdb_test_no_output "set breakpoint always-inserted $always_inserted" | |
48 | ||
49 | set test "$break_command foo" | |
50 | gdb_test_multiple "$break_command foo" $test { | |
51 | -re "No hardware breakpoint support in the target.*$gdb_prompt $" { | |
52 | unsupported $test | |
53 | return | |
54 | } | |
55 | -re "Hardware breakpoints used exceeds limit.*$gdb_prompt $" { | |
56 | unsupported $test | |
57 | return | |
58 | } | |
59 | -re "Cannot insert hardware breakpoint.*$gdb_prompt $" { | |
60 | unsupported $test | |
61 | return | |
62 | } | |
63 | -re ".*reakpoint .* at .*$gdb_prompt $" { | |
64 | pass $test | |
65 | } | |
66 | } | |
67 | ||
68 | # The breakpoint shouldn't be pending now. | |
69 | gdb_test "info break" "y.*$hex.*in foo at.*" \ | |
70 | "breakpoint is not pending" | |
71 | ||
72 | # Remove the file, while the breakpoint above is inserted in a | |
73 | # function in the main objfile. GDB used to have a bug where | |
74 | # it would mark the breakpoint as uninserted, but actually | |
75 | # would leave it inserted in the target. | |
76 | set test "file" | |
77 | gdb_test_multiple "file" $test { | |
78 | -re "Are you sure you want to change the file. .*y or n. $" { | |
79 | send_gdb "y\n" | |
80 | exp_continue | |
81 | } | |
82 | -re "Discard symbol table from `.*'? .y or n. $" { | |
83 | send_gdb "y\n" | |
84 | exp_continue | |
85 | } | |
86 | -re "No symbol file now\\.\r\n$gdb_prompt $" { | |
87 | pass $test | |
88 | } | |
89 | } | |
90 | ||
91 | gdb_test "info break" "y.*PENDING.*foo" \ | |
92 | "breakpoint is not pending" | |
93 | ||
94 | # Now delete the breakpoint from GDB's tables, to make sure | |
95 | # GDB doesn't reinsert it, masking the bug (with the bug, on | |
96 | # re-insert, GDB would fill the shadow buffer with a | |
97 | # breakpoint instruction). Avoid delete_breakpoints as that | |
98 | # doesn't record a pass/fail. | |
99 | gdb_test "delete" "" "delete all breakpoints" \ | |
100 | "Delete all breakpoints.*y or n.*$" "y" | |
101 | ||
102 | # Re-add symbols back. | |
103 | set test "file \$binfile" | |
104 | gdb_test_multiple "file $binfile" $test { | |
105 | -re "Are you sure you want to change the file. .*y or n. $" { | |
106 | send_gdb "y\n" | |
107 | exp_continue | |
108 | } | |
109 | -re "Reading symbols from.*done.*$gdb_prompt $" { | |
110 | pass $test | |
111 | } | |
112 | } | |
113 | ||
114 | # Run to another function now. With the bug, GDB would trip | |
115 | # on a spurious trap at foo. | |
116 | gdb_test "b bar" ".*reakpoint .* at .*" | |
117 | gdb_test "continue" "Breakpoint .*, bar .*" | |
118 | } | |
119 | } | |
120 | ||
121 | # While it doesn't trigger the original bug this is a regression test | |
122 | # for, test with breakpoint always-inserted off for extra coverage. | |
123 | foreach always_inserted { "off" "on" } { | |
124 | test_break $always_inserted "break" | |
125 | if {![skip_hw_breakpoint_tests]} { | |
126 | test_break $always_inserted "hbreak" | |
127 | } | |
128 | } |