Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 2012-2015 Free Software Foundation, Inc. |
8d126d8a LM |
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 'set breakpoint condition-evaluation' settings | |
17 | ||
d708bcd1 PA |
18 | standard_testfile |
19 | ||
20 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { | |
8d126d8a LM |
21 | return -1 |
22 | } | |
23 | ||
d708bcd1 PA |
24 | if ![runto_main] then { |
25 | fail "Can't run to main" | |
26 | return 0 | |
27 | } | |
8d126d8a LM |
28 | |
29 | set test_host "set breakpoint condition-evaluation host" | |
30 | set test_auto "set breakpoint condition-evaluation auto" | |
31 | set test_target "set breakpoint condition-evaluation target" | |
32 | ||
33 | gdb_test_no_output $test_host | |
34 | gdb_test_no_output $test_auto | |
35 | ||
36 | # If target-side condition evaluation is not supported, this warning will be | |
37 | # displayed. | |
4082afcc | 38 | set warning "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead." |
8d126d8a LM |
39 | |
40 | gdb_test_multiple $test_target $test_target { | |
4082afcc | 41 | -re "$warning\r\n$gdb_prompt $" { |
8d126d8a LM |
42 | unsupported $test_target |
43 | return -1 | |
44 | } | |
45 | ||
46 | -re "^$test_target\r\n$gdb_prompt $" { | |
47 | pass $test_target | |
48 | } | |
49 | } | |
d708bcd1 | 50 | |
4082afcc PA |
51 | # We now know that the target supports target-side conditional |
52 | # evaluation. Now make sure we can force-disable the | |
53 | # ConditionalBreakpoints RSP feature. | |
54 | if [gdb_is_target_remote] { | |
55 | gdb_test_no_output "set remote conditional-breakpoints-packet off" | |
56 | ||
57 | gdb_test $test_target "$warning" \ | |
58 | "set breakpoint condition-evaluation target, with support disabled" | |
59 | ||
60 | # Confirm we can re-enable it. | |
61 | gdb_test_no_output "set remote conditional-breakpoints-packet on" | |
62 | gdb_test_no_output $test_target "restore $test_target" | |
63 | } | |
64 | ||
d708bcd1 PA |
65 | # Test setting a condition in a breakpoint. BREAK_COMMAND is the |
66 | # break/hwatch command to test. | |
67 | # | |
68 | proc test_break { break_command } { | |
69 | global gdb_prompt | |
70 | ||
71 | with_test_prefix "$break_command" { | |
72 | delete_breakpoints | |
73 | ||
74 | gdb_test "$break_command foo" "reakpoint.* at .*" | |
75 | ||
76 | # A condition that evals true. | |
77 | gdb_test "condition \$bpnum cond_global==0" ".*" | |
78 | ||
79 | set can_do_cmd 0 | |
80 | ||
81 | set test "continue" | |
82 | gdb_test_multiple $test $test { | |
83 | -re "You may have requested too many.*$gdb_prompt $" { | |
84 | pass $test | |
85 | } | |
86 | -re "Breakpoint .*, foo .*$gdb_prompt $" { | |
87 | pass $test | |
88 | set can_do_cmd 1 | |
89 | } | |
90 | } | |
91 | ||
92 | if { !$can_do_cmd } { | |
93 | unsupported "no target support" | |
94 | return | |
95 | } | |
96 | ||
97 | delete_breakpoints | |
98 | ||
99 | gdb_test "$break_command foo" ".*reakpoint .* at .*" | |
100 | ||
101 | # A condition that evals false. | |
102 | gdb_test "condition \$bpnum cond_global==1" ".*" | |
103 | ||
104 | gdb_test "b bar" "Breakpoint .* at .*" | |
105 | ||
106 | gdb_test "continue" "Breakpoint .*, bar .*" | |
107 | } | |
108 | } | |
109 | ||
110 | # Test setting conditions in watchpoints. WATCH_COMMAND is the watch | |
111 | # command to test. | |
112 | # | |
113 | proc test_watch { watch_command } { | |
114 | global gdb_prompt | |
115 | ||
116 | with_test_prefix "$watch_command" { | |
117 | if [target_info exists gdb,no_hardware_watchpoints] { | |
118 | unsupported "no target support" | |
119 | return | |
120 | } | |
121 | ||
122 | delete_breakpoints | |
123 | ||
124 | gdb_test "$watch_command global" ".*atchpoint .*: global.*" | |
125 | ||
126 | # A condition that evals true. | |
127 | gdb_test "condition \$bpnum cond_global==0" ".*" | |
128 | ||
129 | set can_do_cmd 0 | |
130 | ||
131 | set test "continue" | |
132 | gdb_test_multiple $test $test { | |
133 | -re "You may have requested too many.*$gdb_prompt $" { | |
134 | pass $test | |
135 | } | |
136 | -re "atchpoint .*: global.*$gdb_prompt $" { | |
137 | pass $test | |
138 | set can_do_cmd 1 | |
139 | } | |
140 | } | |
141 | ||
142 | if { !$can_do_cmd } { | |
143 | unsupported "no target support" | |
144 | return | |
145 | } | |
146 | ||
147 | delete_breakpoints | |
148 | ||
149 | gdb_test "$watch_command global" ".*atchpoint .*: global.*" | |
150 | ||
151 | # A condition that evals false. | |
152 | gdb_test "condition \$bpnum cond_global==1" ".*" | |
153 | ||
154 | gdb_test "b bar" "Breakpoint .* at .*" | |
155 | ||
156 | gdb_test "continue" "Breakpoint .*, bar .*" | |
157 | } | |
158 | } | |
159 | ||
160 | foreach break_command { "break" "hbreak" } { | |
161 | test_break $break_command | |
162 | } | |
163 | ||
164 | foreach watch_command { "watch" "rwatch" "awatch" } { | |
165 | test_watch $watch_command | |
166 | } |