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

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

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 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/gdb.exp ('k') | gdb/testsuite/lib/go.exp » ('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 2000, 2002-2012 Free Software Foundation, Inc. 1 # Copyright 2000, 2002-2012 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
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 verbose "Connection failed" 62 verbose "Connection failed"
63 } 63 }
64 -re "Remote MIPS debugging.*$gdb_prompt" { 64 -re "Remote MIPS debugging.*$gdb_prompt" {
65 verbose "Set target to $targetname" 65 verbose "Set target to $targetname"
66 return 0 66 return 0
67 } 67 }
68 -re "Remote debugging using .*$serialport_re.*$gdb_prompt $" { 68 -re "Remote debugging using .*$serialport_re.*$gdb_prompt $" {
69 verbose "Set target to $targetname" 69 verbose "Set target to $targetname"
70 return 0 70 return 0
71 } 71 }
72 -re "Remote debugging using stdio.*$gdb_prompt $" {
73 verbose "Set target to $targetname"
74 return 0
75 }
72 -re "Remote target $targetname connected to.*$gdb_prompt $" { 76 -re "Remote target $targetname connected to.*$gdb_prompt $" {
73 verbose "Set target to $targetname" 77 verbose "Set target to $targetname"
74 return 0 78 return 0
75 } 79 }
76 -re "Connected to.*$gdb_prompt $" { 80 -re "Connected to.*$gdb_prompt $" {
77 verbose "Set target to $targetname" 81 verbose "Set target to $targetname"
78 return 0 82 return 0
79 } 83 }
80 -re "Ending remote.*$gdb_prompt $" { } 84 -re "Ending remote.*$gdb_prompt $" { }
81 -re "Connection refused.*$gdb_prompt $" { 85 -re "Connection refused.*$gdb_prompt $" {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if [is_remote target] { 179 if [is_remote target] {
176 set gdbserver_server_exec [gdb_download $host_exec] 180 set gdbserver_server_exec [gdb_download $host_exec]
177 } else { 181 } else {
178 set gdbserver_server_exec $host_exec 182 set gdbserver_server_exec $host_exec
179 } 183 }
180 } 184 }
181 185
182 return $gdbserver_server_exec 186 return $gdbserver_server_exec
183 } 187 }
184 188
189 # Default routine to compute the argument to "target remote".
190
191 proc gdbserver_default_get_remote_address { host port } {
192 return "$host$port"
193 }
194
185 # Start a gdbserver process with initial OPTIONS and trailing ARGUMENTS. 195 # Start a gdbserver process with initial OPTIONS and trailing ARGUMENTS.
186 # The port will be filled in between them automatically. 196 # The port will be filled in between them automatically.
187 # 197 #
188 # Returns the target protocol and socket to connect to. 198 # Returns the target protocol and socket to connect to.
189 199
190 proc gdbserver_start { options arguments } { 200 proc gdbserver_start { options arguments } {
191 global portnum 201 global portnum
192 202
193 # Port id -- either specified in baseboard file, or managed here. 203 # Port id -- either specified in baseboard file, or managed here.
194 if [target_info exists gdb,socketport] { 204 if [target_info exists gdb,socketport] {
195 set portnum [target_info gdb,socketport] 205 set portnum [target_info gdb,socketport]
196 } else { 206 } else {
197 # Bump the port number to avoid conflicts with hung ports. 207 # Bump the port number to avoid conflicts with hung ports.
198 incr portnum 208 incr portnum
199 } 209 }
200 210
201 # Extract the local and remote host ids from the target board struct. 211 # Extract the local and remote host ids from the target board struct.
202 if [target_info exists sockethost] { 212 if [target_info exists sockethost] {
203 set debughost [target_info sockethost] 213 set debughost [target_info sockethost]
204 } else { 214 } else {
205 set debughost "localhost:" 215 set debughost "localhost:"
206 } 216 }
207 217
218 # Some boards use a different value for the port that is passed to
219 # gdbserver and the port that is passed to the "target remote" command.
220 # One example is the stdio gdbserver support.
221 if [target_info exists gdb,get_remote_address] {
222 set get_remote_address [target_info gdb,get_remote_address]
223 } else {
224 set get_remote_address gdbserver_default_get_remote_address
225 }
226
208 # Extract the protocol 227 # Extract the protocol
209 if [target_info exists gdb_protocol] { 228 if [target_info exists gdb_protocol] {
210 set protocol [target_info gdb_protocol] 229 set protocol [target_info gdb_protocol]
211 } else { 230 } else {
212 set protocol "remote" 231 set protocol "remote"
213 } 232 }
214 233
215 set gdbserver [find_gdbserver] 234 set gdbserver [find_gdbserver]
216 235
217 # Loop till we find a free port. 236 # Loop till we find a free port.
218 while 1 { 237 while 1 {
219 # Export the host:port pair.
220 set gdbport $debughost$portnum
221
222 # Fire off the debug agent. 238 # Fire off the debug agent.
223 set gdbserver_command "$gdbserver" 239 set gdbserver_command "$gdbserver"
224 240
225 # If gdbserver_reconnect will be called $gdbserver_reconnect_p must be 241 # If gdbserver_reconnect will be called $gdbserver_reconnect_p must be
226 # set to true already during gdbserver_start. 242 # set to true already during gdbserver_start.
227 global gdbserver_reconnect_p 243 global gdbserver_reconnect_p
228 if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} { 244 if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
229 # GDB client could accidentally connect to a stale server. 245 # GDB client could accidentally connect to a stale server.
230 # append gdbserver_command " --debug --once" 246 # append gdbserver_command " --debug --once"
231 append gdbserver_command " --once" 247 append gdbserver_command " --once"
232 } 248 }
233 249
234 if { $options != "" } { 250 if { $options != "" } {
235 append gdbserver_command " $options" 251 append gdbserver_command " $options"
236 } 252 }
237 253 » if { $portnum != "" } {
238 » append gdbserver_command " :$portnum" 254 » append gdbserver_command " :$portnum"
239 255 » }
240 if { $arguments != "" } { 256 if { $arguments != "" } {
241 append gdbserver_command " $arguments" 257 append gdbserver_command " $arguments"
242 } 258 }
243 259
244 set server_spawn_id [remote_spawn target $gdbserver_command] 260 set server_spawn_id [remote_spawn target $gdbserver_command]
245 261
246 # Wait for the server to open its TCP socket, so that GDB can connect. 262 # Wait for the server to open its TCP socket, so that GDB can connect.
247 expect { 263 expect {
248 -i $server_spawn_id 264 -i $server_spawn_id
249 -notransfer 265 -notransfer
(...skipping 17 matching lines...) Expand all
267 # don't need to redirect output. 283 # don't need to redirect output.
268 expect_background { 284 expect_background {
269 -i $server_spawn_id 285 -i $server_spawn_id
270 full_buffer { } 286 full_buffer { }
271 eof { 287 eof {
272 # The spawn ID is already closed now (but not yet waited for). 288 # The spawn ID is already closed now (but not yet waited for).
273 wait -i $expect_out(spawn_id) 289 wait -i $expect_out(spawn_id)
274 } 290 }
275 } 291 }
276 292
277 return [list $protocol $gdbport] 293 return [list $protocol [$get_remote_address $debughost $portnum]]
278 } 294 }
279 295
280 # Start a gdbserver process running SERVER_EXEC, and connect GDB 296 # Start a gdbserver process running SERVER_EXEC, and connect GDB
281 # to it. CHILD_ARGS are passed to the inferior. 297 # to it. CHILD_ARGS are passed to the inferior.
282 # 298 #
283 # Returns the target protocol and socket to connect to. 299 # Returns the target protocol and socket to connect to.
284 300
285 proc gdbserver_spawn { child_args } { 301 proc gdbserver_spawn { child_args } {
286 set target_exec [gdbserver_download_current_prog] 302 set target_exec [gdbserver_download_current_prog]
287 303
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 348
333 global gdbserver_reconnect_p; 349 global gdbserver_reconnect_p;
334 if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} { 350 if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
335 error "gdbserver_reconnect_p is not set before gdbserver_reconnect" 351 error "gdbserver_reconnect_p is not set before gdbserver_reconnect"
336 return 0 352 return 0
337 } 353 }
338 354
339 return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] 355 return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
340 } 356 }
341 357
342 # Start and connect to a gdbserver in extended mode. 358 # Start and connect to a gdbserver in extended mode. Note this frobs
359 # $gdbserver_protocol, so should be used only from a board that
360 # usually connects in target remote mode.
343 proc gdbserver_start_extended { } { 361 proc gdbserver_start_extended { } {
344 global gdbserver_protocol 362 global gdbserver_protocol
345 global gdbserver_gdbport 363 global gdbserver_gdbport
346 global use_gdb_stub 364 global use_gdb_stub
347 365
348 set res [gdbserver_start "--multi" ""] 366 set res [gdbserver_start "--multi" ""]
349 set gdbserver_protocol "extended-[lindex $res 0]" 367 set gdbserver_protocol [lindex $res 0]
368 if { [string first "extended-" $gdbserver_protocol] != 0} {
369 » set gdbserver_protocol "extended-$gdbserver_protocol"
370 }
350 set gdbserver_gdbport [lindex $res 1] 371 set gdbserver_gdbport [lindex $res 1]
351 372
352 # Even if the board file is testing with target remote, our caller 373 # Even if the board file is testing with target remote, our caller
353 # wants to test against gdbserver in extended-remote mode. Make sure to 374 # wants to test against gdbserver in extended-remote mode. Make sure to
354 # disable stub-like techniques. 375 # disable stub-like techniques.
355 set use_gdb_stub 0 376 set use_gdb_stub 0
356 377
357 return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] 378 return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
358 } 379 }
380
381 # Start and connect to a gdbserver in extended/multi mode. Unlike
382 # gdbserver_start_extended, this does not frob $gdbserver_protocol.
383
384 proc gdbserver_start_multi { } {
385 global gdbserver_protocol
386 global gdbserver_gdbport
387
388 set res [gdbserver_start "--multi" ""]
389 set gdbserver_protocol [lindex $res 0]
390 set gdbserver_gdbport [lindex $res 1]
391
392 return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
393 }
394
395 # Start a gdbserver process in multi/extended mode, and have GDB
396 # connect to it (MI version). Return 0 on success, or non-zero on
397 # failure.
398
399 proc mi_gdbserver_start_multi { } {
400 global gdbserver_protocol
401 global gdbserver_gdbport
402
403 set res [gdbserver_start "--multi" ""]
404 set gdbserver_protocol [lindex $res 0]
405 set gdbserver_gdbport [lindex $res 1]
406
407 return [mi_gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
408 }
OLDNEW
« no previous file with comments | « gdb/testsuite/lib/gdb.exp ('k') | gdb/testsuite/lib/go.exp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698