Commit | Line | Data |
---|---|---|
ecd75fc8 | 1 | # Copyright 2012-2014 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. | |
3a69ffb2 | 38 | set warning "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead.\r\n" |
8d126d8a LM |
39 | |
40 | gdb_test_multiple $test_target $test_target { | |
41 | -re "$warning$gdb_prompt $" { | |
42 | unsupported $test_target | |
43 | return -1 | |
44 | } | |
45 | ||
46 | -re "^$test_target\r\n$gdb_prompt $" { | |
47 | pass $test_target | |
48 | } | |
49 | } | |
d708bcd1 PA |
50 | |
51 | # Test setting a condition in a breakpoint. BREAK_COMMAND is the | |
52 | # break/hwatch command to test. | |
53 | # | |
54 | proc test_break { break_command } { | |
55 | global gdb_prompt | |
56 | ||
57 | with_test_prefix "$break_command" { | |
58 | delete_breakpoints | |
59 | ||
60 | gdb_test "$break_command foo" "reakpoint.* at .*" | |
61 | ||
62 | # A condition that evals true. | |
63 | gdb_test "condition \$bpnum cond_global==0" ".*" | |
64 | ||
65 | set can_do_cmd 0 | |
66 | ||
67 | set test "continue" | |
68 | gdb_test_multiple $test $test { | |
69 | -re "You may have requested too many.*$gdb_prompt $" { | |
70 | pass $test | |
71 | } | |
72 | -re "Breakpoint .*, foo .*$gdb_prompt $" { | |
73 | pass $test | |
74 | set can_do_cmd 1 | |
75 | } | |
76 | } | |
77 | ||
78 | if { !$can_do_cmd } { | |
79 | unsupported "no target support" | |
80 | return | |
81 | } | |
82 | ||
83 | delete_breakpoints | |
84 | ||
85 | gdb_test "$break_command foo" ".*reakpoint .* at .*" | |
86 | ||
87 | # A condition that evals false. | |
88 | gdb_test "condition \$bpnum cond_global==1" ".*" | |
89 | ||
90 | gdb_test "b bar" "Breakpoint .* at .*" | |
91 | ||
92 | gdb_test "continue" "Breakpoint .*, bar .*" | |
93 | } | |
94 | } | |
95 | ||
96 | # Test setting conditions in watchpoints. WATCH_COMMAND is the watch | |
97 | # command to test. | |
98 | # | |
99 | proc test_watch { watch_command } { | |
100 | global gdb_prompt | |
101 | ||
102 | with_test_prefix "$watch_command" { | |
103 | if [target_info exists gdb,no_hardware_watchpoints] { | |
104 | unsupported "no target support" | |
105 | return | |
106 | } | |
107 | ||
108 | delete_breakpoints | |
109 | ||
110 | gdb_test "$watch_command global" ".*atchpoint .*: global.*" | |
111 | ||
112 | # A condition that evals true. | |
113 | gdb_test "condition \$bpnum cond_global==0" ".*" | |
114 | ||
115 | set can_do_cmd 0 | |
116 | ||
117 | set test "continue" | |
118 | gdb_test_multiple $test $test { | |
119 | -re "You may have requested too many.*$gdb_prompt $" { | |
120 | pass $test | |
121 | } | |
122 | -re "atchpoint .*: global.*$gdb_prompt $" { | |
123 | pass $test | |
124 | set can_do_cmd 1 | |
125 | } | |
126 | } | |
127 | ||
128 | if { !$can_do_cmd } { | |
129 | unsupported "no target support" | |
130 | return | |
131 | } | |
132 | ||
133 | delete_breakpoints | |
134 | ||
135 | gdb_test "$watch_command global" ".*atchpoint .*: global.*" | |
136 | ||
137 | # A condition that evals false. | |
138 | gdb_test "condition \$bpnum cond_global==1" ".*" | |
139 | ||
140 | gdb_test "b bar" "Breakpoint .* at .*" | |
141 | ||
142 | gdb_test "continue" "Breakpoint .*, bar .*" | |
143 | } | |
144 | } | |
145 | ||
146 | foreach break_command { "break" "hbreak" } { | |
147 | test_break $break_command | |
148 | } | |
149 | ||
150 | foreach watch_command { "watch" "rwatch" "awatch" } { | |
151 | test_watch $watch_command | |
152 | } |