Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: gdb/testsuite/lib/trace-support.exp

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/testsuite/lib/set_unbuffered_mode.c ('k') | gdb/thread.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 1998, 2007-2012 Free Software Foundation, Inc. 1 # Copyright (C) 1998-2013 Free Software Foundation, Inc.
2 2
3 # This program is free software; you can redistribute it and/or modify 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 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 5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version. 6 # (at your option) any later version.
7 # 7 #
8 # This program is distributed in the hope that it will be useful, 8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 # with a clean slate with respect to tracepoints, so this utility proc 62 # with a clean slate with respect to tracepoints, so this utility proc
63 # lets us do this without duplicating this code everywhere. 63 # lets us do this without duplicating this code everywhere.
64 # 64 #
65 65
66 proc gdb_delete_tracepoints {} { 66 proc gdb_delete_tracepoints {} {
67 global gdb_prompt 67 global gdb_prompt
68 68
69 send_gdb "delete tracepoints\n" 69 send_gdb "delete tracepoints\n"
70 gdb_expect 30 { 70 gdb_expect 30 {
71 -re "Delete all tracepoints.*y or n.*$" { 71 -re "Delete all tracepoints.*y or n.*$" {
72 » send_gdb "y\n"; 72 » send_gdb "y\n"
73 exp_continue 73 exp_continue
74 } 74 }
75 -re ".*$gdb_prompt $" { # This happens if there were no tracepoints } 75 -re ".*$gdb_prompt $" { # This happens if there were no tracepoints }
76 timeout { 76 timeout {
77 perror "Delete all tracepoints in delete_tracepoints (timeout)" 77 perror "Delete all tracepoints in delete_tracepoints (timeout)"
78 return 78 return
79 } 79 }
80 } 80 }
81 send_gdb "info tracepoints\n" 81 send_gdb "info tracepoints\n"
82 gdb_expect 30 { 82 gdb_expect 30 {
83 -re "No tracepoints.*$gdb_prompt $" {} 83 -re "No tracepoints.*$gdb_prompt $" {}
84 -re "$gdb_prompt $" { perror "tracepoints not deleted" ; return } 84 -re "$gdb_prompt $" { perror "tracepoints not deleted" ; return }
85 timeout { perror "info tracepoints (timeout)" ; return } 85 timeout { perror "info tracepoints (timeout)" ; return }
86 } 86 }
87 } 87 }
88 88
89 #
90 # Procedure: gdb_trace_setactions
91 # Define actions for a tracepoint. 89 # Define actions for a tracepoint.
92 # Arguments: 90 # Arguments:
91 # actions_command -- the command used to create the actions.
92 # either "actions" or "commands".
93 # testname -- identifying string for pass/fail output 93 # testname -- identifying string for pass/fail output
94 #» tracepoint -- to which tracepoint do these actions apply? (optional) 94 #» tracepoint -- to which tracepoint(s) do these actions apply? (optional)
95 # args -- list of actions to be defined. 95 # args -- list of actions to be defined.
96 # Returns: 96 # Returns:
97 # zero -- success 97 # zero -- success
98 # non-zero -- failure 98 # non-zero -- failure
99 99
100 proc gdb_trace_setactions { testname tracepoint args } { 100 proc gdb_trace_setactions_command { actions_command testname tracepoint args } {
101 global gdb_prompt; 101 global gdb_prompt
102 102
103 set state 0; 103 set state 0
104 set passfail "pass"; 104 set passfail "pass"
105 send_gdb "actions $tracepoint\n"; 105 send_gdb "$actions_command $tracepoint\n"
106 set expected_result ""; 106 set expected_result ""
107 gdb_expect 5 { 107 gdb_expect 5 {
108 -re "No tracepoint number .*$gdb_prompt $" { 108 -re "No tracepoint number .*$gdb_prompt $" {
109 fail $testname 109 fail $testname
110 » return 1; 110 » return 1
111 } 111 }
112 -re "Enter actions for tracepoint $tracepoint.*>" { 112 -re "Enter actions for tracepoint $tracepoint.*>" {
113 if { [llength $args] > 0 } { 113 if { [llength $args] > 0 } {
114 » » set lastcommand "[lindex $args $state]"; 114 » » set lastcommand "[lindex $args $state]"
115 » » send_gdb "[lindex $args $state]\n"; 115 » » send_gdb "[lindex $args $state]\n"
116 » » incr state; 116 » » incr state
117 » » set expected_result [lindex $args $state]; 117 » » set expected_result [lindex $args $state]
118 » » incr state; 118 » » incr state
119 } else { 119 } else {
120 » » send_gdb "end\n"; 120 » » send_gdb "end\n"
121 } 121 }
122 » exp_continue; 122 » exp_continue
123 } 123 }
124 -re "\(.*\)\[\r\n\]+\[ \t]*>$" { 124 -re "\(.*\)\[\r\n\]+\[ \t]*>$" {
125 if { $expected_result != "" } { 125 if { $expected_result != "" } {
126 » » regsub "^\[^\r\n\]+\[\r\n\]+" "$expect_out(1,string)" "" out; 126 » » regsub "^\[^\r\n\]+\[\r\n\]+" "$expect_out(1,string)" "" out
127 if ![regexp $expected_result $out] { 127 if ![regexp $expected_result $out] {
128 » » set passfail "fail"; 128 » » set passfail "fail"
129 } 129 }
130 » » set expected_result ""; 130 » » set expected_result ""
131 } 131 }
132 if { $state < [llength $args] } { 132 if { $state < [llength $args] } {
133 » » send_gdb "[lindex $args $state]\n"; 133 » » send_gdb "[lindex $args $state]\n"
134 » » incr state; 134 » » incr state
135 » » set expected_result [lindex $args $state]; 135 » » set expected_result [lindex $args $state]
136 » » incr state; 136 » » incr state
137 } else { 137 } else {
138 » » send_gdb "end\n"; 138 » » send_gdb "end\n"
139 » » set expected_result ""; 139 » » set expected_result ""
140 } 140 }
141 » exp_continue; 141 » exp_continue
142 } 142 }
143 -re "\(.*\)$gdb_prompt $" { 143 -re "\(.*\)$gdb_prompt $" {
144 if { $expected_result != "" } { 144 if { $expected_result != "" } {
145 if ![regexp $expected_result $expect_out(1,string)] { 145 if ![regexp $expected_result $expect_out(1,string)] {
146 » » set passfail "fail"; 146 » » set passfail "fail"
147 } 147 }
148 » » set expected_result ""; 148 » » set expected_result ""
149 } 149 }
150 if { [llength $args] < $state } { 150 if { [llength $args] < $state } {
151 » » set passfail "fail"; 151 » » set passfail "fail"
152 } 152 }
153 } 153 }
154 default { 154 default {
155 » set passfail "fail"; 155 » set passfail "fail"
156 } 156 }
157 } 157 }
158 if { $testname != "" } { 158 if { $testname != "" } {
159 » $passfail $testname; 159 » $passfail $testname
160 } 160 }
161 if { $passfail == "pass" } then { 161 if { $passfail == "pass" } then {
162 » return 0; 162 » return 0
163 } else { 163 } else {
164 » return 1; 164 » return 1
165 } 165 }
166 } 166 }
167 167
168 # Define actions for a tracepoint, using the "actions" command. See
169 # gdb_trace_setactions_command.
170 #
171 proc gdb_trace_setactions { testname tracepoint args } {
172 eval gdb_trace_setactions_command "actions" {$testname} {$tracepoint} $args
173 }
174
175 # Define actions for a tracepoint, using the "commands" command. See
176 # gdb_trace_setactions_command.
177 #
178 proc gdb_trace_setcommands { testname tracepoint args } {
179 eval gdb_trace_setactions_command "commands" {$testname} {$tracepoint} $args
180 }
181
168 # 182 #
169 # Procedure: gdb_tfind_test 183 # Procedure: gdb_tfind_test
170 # Find a specified trace frame. 184 # Find a specified trace frame.
171 # Arguments: 185 # Arguments:
172 # testname -- identifying string for pass/fail output 186 # testname -- identifying string for pass/fail output
173 # tfind_arg -- frame (line, PC, etc.) identifier 187 # tfind_arg -- frame (line, PC, etc.) identifier
174 # exp_res -- Expected result of frame test 188 # exp_res -- Expected result of frame test
175 # args -- Test expression 189 # args -- Test expression
176 # Returns: 190 # Returns:
177 # zero -- success 191 # zero -- success
178 # non-zero -- failure 192 # non-zero -- failure
179 # 193 #
180 194
181 proc gdb_tfind_test { testname tfind_arg exp_res args } { 195 proc gdb_tfind_test { testname tfind_arg exp_res args } {
182 global gdb_prompt; 196 global gdb_prompt
183 197
184 if { "$args" != "" } { 198 if { "$args" != "" } {
185 » set expr "$exp_res"; 199 » set expr "$exp_res"
186 » set exp_res "$args"; 200 » set exp_res "$args"
187 } else { 201 } else {
188 » set expr "(int) \$trace_frame"; 202 » set expr "(int) \$trace_frame"
189 } 203 }
190 set passfail "fail"; 204 set passfail "fail"
191 205
192 gdb_test "tfind $tfind_arg" "" "" 206 gdb_test "tfind $tfind_arg" "" ""
193 send_gdb "printf \"x \%d x\\n\", $expr\n"; 207 send_gdb "printf \"x \%d x\\n\", $expr\n"
194 gdb_expect 10 { 208 gdb_expect 10 {
195 -re "x (-*\[0-9\]+) x" { 209 -re "x (-*\[0-9\]+) x" {
196 if { $expect_out(1,string) == $exp_res } { 210 if { $expect_out(1,string) == $exp_res } {
197 » » set passfail "pass"; 211 » » set passfail "pass"
198 } 212 }
199 » exp_continue; 213 » exp_continue
200 } 214 }
201 -re "$gdb_prompt $" { } 215 -re "$gdb_prompt $" { }
202 } 216 }
203 $passfail "$testname"; 217 $passfail "$testname"
204 if { $passfail == "pass" } then { 218 if { $passfail == "pass" } then {
205 » return 0; 219 » return 0
206 } else { 220 } else {
207 » return 1; 221 » return 1
208 } 222 }
209 } 223 }
210 224
211 # 225 #
212 # Procedure: gdb_readexpr 226 # Procedure: gdb_readexpr
213 # Arguments: 227 # Arguments:
214 # gdb_expr -- the expression whose value is desired 228 # gdb_expr -- the expression whose value is desired
215 # Returns: 229 # Returns:
216 # the value of gdb_expr, as evaluated by gdb. 230 # the value of gdb_expr, as evaluated by gdb.
217 # [FIXME: returns -1 on error, which is sometimes a legit value] 231 # [FIXME: returns -1 on error, which is sometimes a legit value]
218 # 232 #
219 233
220 proc gdb_readexpr { gdb_expr } { 234 proc gdb_readexpr { gdb_expr } {
221 global gdb_prompt; 235 global gdb_prompt
222 236
223 set result -1; 237 set result -1
224 send_gdb "print $gdb_expr\n" 238 send_gdb "print $gdb_expr\n"
225 gdb_expect 5 { 239 gdb_expect 5 {
226 -re "\[$\].*= (\[0-9\]+).*$gdb_prompt $" { 240 -re "\[$\].*= (\[0-9\]+).*$gdb_prompt $" {
227 » set result $expect_out(1,string); 241 » set result $expect_out(1,string)
228 } 242 }
229 -re "$gdb_prompt $" { } 243 -re "$gdb_prompt $" { }
230 default { } 244 default { }
231 } 245 }
232 return $result; 246 return $result
233 } 247 }
234 248
235 # 249 #
236 # Procedure: gdb_gettpnum 250 # Procedure: gdb_gettpnum
237 # Arguments: 251 # Arguments:
238 # tracepoint (optional): if supplied, set a tracepoint here. 252 # tracepoint (optional): if supplied, set a tracepoint here.
239 # Returns: 253 # Returns:
240 # the tracepoint ID of the most recently set tracepoint. 254 # the tracepoint ID of the most recently set tracepoint.
241 # 255 #
242 256
243 proc gdb_gettpnum { tracepoint } { 257 proc gdb_gettpnum { tracepoint } {
244 global gdb_prompt; 258 global gdb_prompt
245 259
246 if { $tracepoint != "" } { 260 if { $tracepoint != "" } {
247 gdb_test "trace $tracepoint" "" "" 261 gdb_test "trace $tracepoint" "" ""
248 } 262 }
249 return [gdb_readexpr "\$tpnum"]; 263 return [gdb_readexpr "\$tpnum"]
250 } 264 }
251 265
252 266
253 # 267 #
254 # Procedure: gdb_find_function_baseline 268 # Procedure: gdb_find_function_baseline
255 # Arguments: 269 # Arguments:
256 # func_name -- name of source function 270 # func_name -- name of source function
257 # Returns: 271 # Returns:
258 # Sourcefile line of function definition (open curly brace), 272 # Sourcefile line of function definition (open curly brace),
259 # or -1 on failure. Caller must check return value. 273 # or -1 on failure. Caller must check return value.
260 # Note: 274 # Note:
261 # Works only for open curly brace at beginning of source line! 275 # Works only for open curly brace at beginning of source line!
262 # 276 #
263 277
264 proc gdb_find_function_baseline { func_name } { 278 proc gdb_find_function_baseline { func_name } {
265 global gdb_prompt; 279 global gdb_prompt
266 280
267 set baseline -1; 281 set baseline -1
268 282
269 send_gdb "list $func_name\n" 283 send_gdb "list $func_name\n"
270 # gdb_expect { 284 # gdb_expect {
271 # -re "\[\r\n\]\[\{\].*$gdb_prompt $" { 285 # -re "\[\r\n\]\[\{\].*$gdb_prompt $" {
272 # set baseline 1 286 # set baseline 1
273 # } 287 # }
274 # } 288 # }
275 } 289 }
276 290
277 # 291 #
278 # Procedure: gdb_find_function_baseline 292 # Procedure: gdb_find_function_baseline
279 # Arguments: 293 # Arguments:
280 # filename: name of source file of desired function. 294 # filename: name of source file of desired function.
281 # Returns: 295 # Returns:
282 # Sourcefile line of function definition (open curly brace), 296 # Sourcefile line of function definition (open curly brace),
283 # or -1 on failure. Caller must check return value. 297 # or -1 on failure. Caller must check return value.
284 # Note: 298 # Note:
285 # Works only for open curly brace at beginning of source line! 299 # Works only for open curly brace at beginning of source line!
286 # 300 #
287 301
288 proc gdb_find_recursion_test_baseline { filename } { 302 proc gdb_find_recursion_test_baseline { filename } {
289 global gdb_prompt; 303 global gdb_prompt
290 304
291 set baseline -1; 305 set baseline -1
292 306
293 gdb_test "list $filename:1" "" "" 307 gdb_test "list $filename:1" "" ""
294 send_gdb "search gdb_recursion_test line 0\n" 308 send_gdb "search gdb_recursion_test line 0\n"
295 gdb_expect { 309 gdb_expect {
296 -re "(\[0-9\]+)\[\t \]+\{.*line 0.*$gdb_prompt $" { 310 -re "(\[0-9\]+)\[\t \]+\{.*line 0.*$gdb_prompt $" {
297 » set baseline $expect_out(1,string); 311 » set baseline $expect_out(1,string)
298 } 312 }
299 -re "$gdb_prompt $" { } 313 -re "$gdb_prompt $" { }
300 default { } 314 default { }
301 } 315 }
302 return $baseline; 316 return $baseline
303 } 317 }
304 318
305 # Return the location of the IPA library. 319 # Return the location of the IPA library.
306 320
307 proc get_in_proc_agent {} { 321 proc get_in_proc_agent {} {
308 global objdir 322 global objdir
309 323
310 if [target_info exists in_proc_agent] { 324 if [target_info exists in_proc_agent] {
311 return [target_info in_proc_agent] 325 return [target_info in_proc_agent]
312 } else { 326 } else {
313 return $objdir/../gdbserver/libinproctrace.so 327 return $objdir/../gdbserver/libinproctrace.so
314 } 328 }
315 } 329 }
OLDNEW
« no previous file with comments | « gdb/testsuite/lib/set_unbuffered_mode.c ('k') | gdb/thread.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698