]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/lib/gdbserver-support.exp
RISC-V: [gprofng] Allow building gprofng without asm/hwprobe.h
[thirdparty/binutils-gdb.git] / gdb / testsuite / lib / gdbserver-support.exp
1 # Copyright 2000-2025 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 # This file is based on config/gdbserver.exp, which was written by
17 # Michael Snyder (msnyder@redhat.com).
18
19 #
20 # To be addressed or set in your baseboard config file:
21 #
22 # set_board_info gdb_protocol "remote"
23 # Unles you have a gdbserver that uses a different protocol...
24 # After GDB starts you should check global $gdbserver_protocol instead as
25 # the testfile may force a specific different target protocol itself.
26 #
27 # set_board_info gdb_server_prog
28 # This will be the path to the gdbserver program you want to test.
29 # Defaults to "gdbserver".
30 #
31 # set_board_info sockethost
32 # The name of the host computer whose socket is being used.
33 # Defaults to "localhost". Note: old gdbserver requires
34 # that you define this, but libremote/gdbserver does not.
35 #
36 # set_board_info gdb,socketport
37 # Port id to use for socket connection. If not set explicitly,
38 # it will start at "2345" and increment for each use.
39 # After GDB starts you should check global $gdbserver_gdbport for the
40 # real port used. It is not useful if $gdbserver_reconnect_p was not set.
41 #
42
43 #
44 # gdb_target_cmd_ext
45 # Send gdb the "target" command. Returns 0 on success, 1 on failure, 2 on
46 # unsupported.
47 # If specified, then ADDITIONAL_TEXT must match the text that comes after
48 # the connection message in order for the procedure to succeed.
49 #
50 proc gdb_target_cmd_ext { targetname serialport {additional_text ""} } {
51 global gdb_prompt gdb_target_remote_cmd_msg
52
53 set serialport_re [string_to_regexp $serialport]
54 for {set i 1} {$i <= 3} {incr i} {
55 send_gdb "target $targetname $serialport\n"
56 gdb_expect 60 {
57 -re "A program is being debugged already.*ill it.*y or n. $" {
58 send_gdb "y\n"
59 exp_continue
60 }
61 -re "unknown host.*$gdb_prompt" {
62 verbose "Couldn't look up $serialport"
63 }
64 -re "Couldn't establish connection to remote.*$gdb_prompt $" {
65 verbose "Connection failed"
66 }
67 -re "Cannot assign requested address.*$gdb_prompt $" {
68 verbose "Could not assign requested address"
69 }
70 -re "Non-stop mode requested, but remote does not support non-stop.*$gdb_prompt $" {
71 verbose "remote does not support non-stop"
72 return 2
73 }
74 -re "Remote MIPS debugging.*$additional_text.*$gdb_prompt" {
75 verbose "Set target to $targetname"
76 set gdb_target_remote_cmd_msg $expect_out(buffer)
77 return 0
78 }
79 -re "Remote debugging using .*$serialport_re.*$additional_text.*$gdb_prompt $" {
80 verbose "Set target to $targetname"
81 set gdb_target_remote_cmd_msg $expect_out(buffer)
82 return 0
83 }
84 -re "Remote debugging using stdio.*$additional_text.*$gdb_prompt $" {
85 verbose "Set target to $targetname"
86 set gdb_target_remote_cmd_msg $expect_out(buffer)
87 return 0
88 }
89 -re "Remote target $targetname connected to.*$additional_text.*$gdb_prompt $" {
90 verbose "Set target to $targetname"
91 set gdb_target_remote_cmd_msg $expect_out(buffer)
92 return 0
93 }
94 -re "Connected to.*$additional_text.*$gdb_prompt $" {
95 verbose "Set target to $targetname"
96 set gdb_target_remote_cmd_msg $expect_out(buffer)
97 return 0
98 }
99 -re "Ending remote.*$gdb_prompt $" { }
100 -re "Connection refused.*$gdb_prompt $" {
101 verbose "Connection refused by remote target. Pausing, and trying again."
102 sleep 30
103 continue
104 }
105 -re "Timeout reading from remote system.*$gdb_prompt $" {
106 verbose "Got timeout error from gdb."
107 }
108 -notransfer -re "Remote debugging using .*\r\n> $" {
109 # We got an unexpected prompt while creating the target.
110 # Leave it there for the test to diagnose.
111 return 1
112 }
113 -re ": Network is unreachable.\r\n.*$gdb_prompt $" {
114 return 2
115 }
116 timeout {
117 send_gdb "\ 3"
118 break
119 }
120 }
121 }
122 return 1
123 }
124
125 # Like gdb_target_cmd_ext, but returns 0 on success, 1 on failure.
126
127 proc gdb_target_cmd { args } {
128 set res [eval gdb_target_cmd_ext $args]
129 return [expr $res == 0 ? 0 : 1]
130 }
131
132 # Return a usable port number.
133
134 proc get_portnum {} {
135 if { [target_info exists gdb,socketport] } {
136 # Hard-coded in target board.
137 return [target_info gdb,socketport]
138 }
139
140 # Not hard-coded in target board. Return increasing port numbers,
141 # starting at $initial_portnum, to avoid conflicts with hung ports.
142 set initial_portnum 2345
143
144 if { ![info exists ::GDB_PARALLEL] } {
145 # Sequential case.
146
147 # Currently available port number.
148 gdb_persistent_global portnum
149
150 # Initialize, if necessary.
151 if { ![info exists portnum] } {
152 set portnum $initial_portnum
153 }
154
155 # Return currently available port number, and update it.
156 set res $portnum
157 incr portnum
158 return $res
159 }
160
161 # Parallel case.
162 with_lock portnum.lock {
163 # Keep portnum file alongside the lock that guards it.
164 set portnum_file [lock_dir]/portnum
165
166 if { [file exists $portnum_file] } {
167 set fd [open $portnum_file r]
168 set portnum [read $fd]
169 close $fd
170
171 set portnum [string trim $portnum]
172 } else {
173 # Initialize.
174 set portnum $initial_portnum
175 }
176
177 set next_portnum [expr $portnum + 1]
178
179 set fd [open $portnum_file w]
180 puts $fd $next_portnum
181 close $fd
182 }
183
184 return $portnum
185 }
186
187 # Locate the gdbserver binary. Returns "" if gdbserver could not be found.
188
189 proc find_gdbserver { } {
190 global GDB
191 global GDBSERVER
192
193 if [info exists GDBSERVER] {
194 return ${GDBSERVER}
195 }
196
197 if [target_info exists gdb_server_prog] {
198 return [target_info gdb_server_prog]
199 }
200
201 set toplevel [file join [file dirname $GDB] .. gdbserver]
202 foreach gdbserver [list "${GDB}server" $toplevel] {
203 if { [file isdirectory $gdbserver] } {
204 append gdbserver "/gdbserver"
205 }
206
207 if { [file executable $gdbserver] } {
208 return $gdbserver
209 }
210 }
211
212 return ""
213 }
214
215 # Return non-zero if we should run gdbserver-specific tests.
216
217 proc allow_gdbserver_tests { } {
218 if { [find_gdbserver] == "" } {
219 return 0
220 }
221
222 # If GDB is lack of XML support, and targets, like arm, have
223 # multiple target descriptions, GDB doesn't know which target
224 # description GDBserver uses, and may fail to parse 'g' packet
225 # after connection.
226 if { ![allow_xml_test]
227 && ([istarget "arm*-*-linux*"]
228 || [istarget "aarch64*-*-linux*"]
229 || [istarget "mips*-*-linux*"]
230 || [istarget "powerpc*-*-linux*"]
231 || [istarget "s390*-*-linux*"]
232 || [istarget "x86_64-*-linux*"]
233 || [istarget "i\[34567\]86-*-linux*"]) } {
234 return 0
235 }
236
237 return 1
238 }
239
240 # Download the currently loaded program to the target if necessary.
241 # Return the target system filename.
242 # NOTE: This was named "gdbserver_download", but that collides with the
243 # dejagnu "download" API function when using load_generic_config "gdbserver".
244
245 proc gdbserver_download_current_prog { } {
246 global gdbserver_host_exec
247 global gdbserver_host_mtime
248 global gdbserver_server_exec
249 global last_loaded_file
250
251 if { ![info exists last_loaded_file] } {
252 return ""
253 }
254
255 set host_exec $last_loaded_file
256
257 # If we already downloaded a file to the target, see if we can reuse it.
258 set reuse 0
259 if { [info exists gdbserver_server_exec] } {
260 set reuse 1
261
262 # If the file has changed, we can not.
263 if { $host_exec != $gdbserver_host_exec } {
264 set reuse 0
265 }
266
267 # If the mtime has changed, we can not.
268 if { [file mtime $host_exec] != $gdbserver_host_mtime } {
269 set reuse 0
270 }
271 }
272
273 if { $reuse == 0 } {
274 set gdbserver_host_exec $host_exec
275 set gdbserver_host_mtime [file mtime $host_exec]
276 set gdbserver_server_exec [gdb_remote_download target $host_exec]
277 }
278
279 return $gdbserver_server_exec
280 }
281
282 # Default routine to compute the argument to "target remote".
283
284 proc gdbserver_default_get_remote_address { host port } {
285 # Historically HOST included the trailing ":".
286 # To avoid breaking any board files out there we leave things alone.
287 return "$host$port"
288 }
289
290 # Default routine to compute the "comm" argument for gdbserver.
291
292 proc gdbserver_default_get_comm_port { port } {
293 return "$port"
294 }
295
296 # Start a gdbserver process with initial OPTIONS and trailing ARGUMENTS.
297 # The port will be filled in between them automatically.
298 #
299 # Returns the target protocol and socket to connect to.
300
301 proc gdbserver_start { options arguments } {
302 global GDB_TEST_SOCKETHOST
303
304 # Port id -- either specified in baseboard file, or managed here.
305 set portnum [get_portnum]
306
307 # Extract the local and remote host ids from the target board struct.
308 if { [info exists GDB_TEST_SOCKETHOST] } {
309 # The user is not supposed to provide a port number, just a
310 # hostname/address, therefore we add the trailing ":" here.
311 set debughost "${GDB_TEST_SOCKETHOST}:"
312 # Escape open and close square brackets.
313 set debughost_tmp [string map { [ \\[ ] \\] } $debughost]
314 # We need a "gdbserver" version of the debughost, which will
315 # have the possible connection prefix stripped. This is
316 # because gdbserver currently doesn't recognize the prefixes.
317 regsub -all "^\(tcp:|udp:|tcp4:|udp4:|tcp6:|udp6:\)" $debughost_tmp "" debughost_gdbserver
318 } elseif [target_info exists sockethost] {
319 set debughost [target_info sockethost]
320 set debughost_gdbserver $debughost
321 } else {
322 set debughost "localhost:"
323 set debughost_gdbserver $debughost
324 }
325
326 # Some boards use a different value for the port that is passed to
327 # gdbserver and the port that is passed to the "target remote" command.
328 # One example is the stdio gdbserver support.
329 if [target_info exists gdb,get_remote_address] {
330 set get_remote_address [target_info gdb,get_remote_address]
331 } else {
332 set get_remote_address gdbserver_default_get_remote_address
333 }
334 if [target_info exists gdbserver,get_comm_port] {
335 set get_comm_port [target_info gdbserver,get_comm_port]
336 } else {
337 set get_comm_port gdbserver_default_get_comm_port
338 }
339
340 # Extract the protocol
341 if [target_info exists gdb_protocol] {
342 set protocol [target_info gdb_protocol]
343 } else {
344 set protocol "remote"
345 }
346
347 set gdbserver [find_gdbserver]
348
349 # Loop till we find a free port.
350 while 1 {
351 # Fire off the debug agent.
352 set gdbserver_command "$gdbserver"
353
354 # If gdbserver_reconnect will be called $gdbserver_reconnect_p must be
355 # set to true already during gdbserver_start.
356 global gdbserver_reconnect_p
357 global srcdir
358 global subdir
359 if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
360 # GDB client could accidentally connect to a stale server.
361 append gdbserver_command " --once"
362 }
363
364 # Enable debug if set.
365 if [gdbserver_debug_enabled] {
366 global gdbserverdebug
367 set enabled 0
368 foreach entry [split $gdbserverdebug ,] {
369 switch -- $entry {
370 "debug-all" {
371 append gdbserver_command " --debug=all"
372 set enabled 1
373 }
374 "all" {
375 # Different from the debug-all option, all argument sets
376 # the replay log file. See gdb_debug_init.
377 append gdbserver_command " --debug=all"
378 set enabled 1
379 }
380 "debug-threads" {
381 append gdbserver_command " --debug=threads"
382 set enabled 1
383 }
384 "debug-remote" {
385 append gdbserver_command " --debug=remote"
386 set enabled 1
387 }
388 "debug-event-loop" {
389 append gdbserver_command " --debug=event-loop"
390 set enabled 1
391 }
392 }
393 }
394 # Ensure debugfile is only added if something has been enabled
395 if { $enabled } {
396 set debugfile [standard_output_file gdbserver.debug]
397 append gdbserver_command " --debug-file=$debugfile"
398 }
399 }
400
401 if { $options != "" } {
402 append gdbserver_command " $options"
403 }
404 if { $debughost_gdbserver != "" } {
405 append gdbserver_command " $debughost_gdbserver"
406 }
407 if { $portnum != "" } {
408 if { $debughost_gdbserver == "" } {
409 append gdbserver_command " "
410 }
411 append gdbserver_command "[$get_comm_port $portnum]"
412 }
413 if { $arguments != "" } {
414 append gdbserver_command " $arguments"
415 }
416
417 gdbserver_write_cmd_file $gdbserver_command
418
419 global server_spawn_id
420 set server_spawn_id [remote_spawn target $gdbserver_command]
421
422 # GDBserver doesn't do inferior I/O through GDB. But we can
423 # talk to the program using GDBserver's tty instead.
424 global inferior_spawn_id
425 set inferior_spawn_id $server_spawn_id
426
427 # Wait for the server to open its TCP socket, so that GDB can connect.
428 expect {
429 -i $server_spawn_id
430 -timeout 120
431 -notransfer
432 -re "Listening on" { }
433 -re "Can't (bind address|listen on socket): Address already in use\\.\r\n" {
434 verbose -log "Port $portnum is already in use."
435 set other_portnum [get_portnum]
436 if { $other_portnum != $portnum } {
437 # Bump the port number to avoid the conflict.
438 wait -i $expect_out(spawn_id)
439 set portnum $other_portnum
440 continue
441 }
442 }
443 -re ".*: cannot resolve name: .*\r\n" {
444 error "gdbserver cannot resolve name."
445 }
446 -re "Can't open socket: Address family not supported by protocol." {
447 return {}
448 }
449 timeout {
450 error "Timeout waiting for gdbserver response."
451 }
452 }
453 break
454 }
455
456 return [list $protocol [$get_remote_address $debughost $portnum]]
457 }
458
459 # Start a gdbserver process running SERVER_EXEC, and connect GDB
460 # to it. CHILD_ARGS are passed to the inferior.
461 #
462 # Returns the target protocol and socket to connect to.
463
464 proc gdbserver_spawn { child_args } {
465 set target_exec [gdbserver_download_current_prog]
466
467 # Fire off the debug agent. This flavour of gdbserver takes as
468 # arguments the port information, the name of the executable file to
469 # be debugged, and any arguments.
470 set arguments "$target_exec"
471 if { $child_args != "" } {
472 append arguments " $child_args"
473 }
474 return [gdbserver_start "" $arguments]
475 }
476
477 # Close the GDBserver connection.
478
479 proc close_gdbserver {} {
480 global server_spawn_id
481
482 # We can't just call close, because if gdbserver is local then that means
483 # that it will get a SIGHUP. Doing it this way could also allow us to
484 # get at the inferior's input or output if necessary, and means that we
485 # don't need to redirect output.
486
487 if {![info exists server_spawn_id]} {
488 return
489 }
490
491 verbose "Quitting GDBserver"
492
493 catch "close -i $server_spawn_id"
494
495 # If gdbserver misbehaves, and ignores the close, waiting for it
496 # without the -nowait flag will cause testing to hang. Passing
497 # -nowait makes expect tell Tcl to wait for the process in the
498 # background.
499 catch "wait -nowait -i $server_spawn_id"
500 clean_up_spawn_id target $server_spawn_id
501 unset server_spawn_id
502 }
503
504 # Hook into GDB exit, and close GDBserver. We must load this
505 # explicitly here, and rename the procedures we want to override.
506 load_lib mi-support.exp
507
508 if { [info procs gdbserver_orig_gdb_exit] == "" } {
509 rename gdb_exit gdbserver_orig_gdb_exit
510 rename mi_gdb_exit gdbserver_orig_mi_gdb_exit
511 }
512
513 # Cleanup gdbserver $server_spawn_id
514
515 proc gdbserver_exit { is_mi } {
516 global gdb_spawn_id server_spawn_id
517 global gdb_prompt
518
519 if {[info exists gdb_spawn_id] && [info exists server_spawn_id]} {
520 # GDB may be terminated in an expected way or an unexpected way,
521 # but DejaGNU doesn't know that, so gdb_spawn_id isn't unset.
522 # Catch the exceptions.
523 catch {
524 if { $is_mi } {
525 set monitor_exit "-interpreter-exec console \"monitor exit\""
526 } else {
527 set monitor_exit "monitor exit"
528 }
529 send_gdb "$monitor_exit\n";
530 # We use expect rather than gdb_expect because
531 # we want to suppress printing exception messages, otherwise,
532 # remote_expect, invoked by gdb_expect, prints the exceptions.
533 set have_prompt 0
534 expect {
535 -i "$gdb_spawn_id" -re "$gdb_prompt $" {
536 set have_prompt 1
537 if { [info exists server_spawn_id] } {
538 exp_continue
539 }
540 }
541 -i "$server_spawn_id" eof {
542 wait -i $expect_out(spawn_id)
543 unset server_spawn_id
544 if { ! $have_prompt } {
545 exp_continue
546 }
547 }
548 timeout {
549 warning "Timed out waiting for EOF in server after $monitor_exit"
550 }
551 }
552 }
553 }
554 close_gdbserver
555 }
556
557 # Local version of gdb_exit that also cleans up gdbserver $server_spawn_id.
558
559 proc gdbserver_gdb_exit { is_mi } {
560 global gdb_spawn_id server_spawn_id
561 global gdb_prompt
562 global gdbserver_reconnect_p
563
564 # Leave GDBserver running if we're exiting GDB in order to
565 # reconnect to the same instance of GDBserver again.
566 if {[info exists gdbserver_reconnect_p] && $gdbserver_reconnect_p} {
567 if { $is_mi } {
568 gdbserver_orig_mi_gdb_exit
569 } else {
570 gdbserver_orig_gdb_exit
571 }
572 return
573 }
574
575 gdbserver_exit $is_mi
576
577 if { $is_mi } {
578 gdbserver_orig_mi_gdb_exit
579 } else {
580 gdbserver_orig_gdb_exit
581 }
582 }
583
584 proc gdb_exit {} {
585 gdbserver_gdb_exit 0
586 }
587
588 proc mi_gdb_exit {} {
589 gdbserver_gdb_exit 1
590 }
591
592 # Start a gdbserver process running HOST_EXEC and pass CHILD_ARGS
593 # to it. Return 0 on success, or non-zero on failure: 2 if gdbserver
594 # failed to start or 1 if we couldn't connect to it.
595
596 proc gdbserver_run { child_args } {
597 global gdbserver_protocol
598 global gdbserver_gdbport
599
600 # Kill anything running before we try to start gdbserver, in case
601 # we are sharing a serial connection.
602 global gdb_prompt
603 send_gdb "kill\n" optional
604 gdb_expect 120 {
605 -re "Kill the program being debugged. .y or n. $" {
606 send_gdb "y\n"
607 verbose "\t\tKilling previous program being debugged"
608 exp_continue
609 }
610 -re "$gdb_prompt $" {
611 # OK.
612 }
613 }
614
615 if { [catch { gdbserver_spawn $child_args } res] == 1 } {
616 perror $res
617 return 2
618 }
619 set gdbserver_protocol [lindex $res 0]
620 set gdbserver_gdbport [lindex $res 1]
621
622 return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
623 }
624
625 # Reconnect to the previous gdbserver session.
626
627 proc gdbserver_reconnect { } {
628 global gdbserver_protocol
629 global gdbserver_gdbport
630
631 global gdbserver_reconnect_p
632 if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
633 error "gdbserver_reconnect_p is not set before gdbserver_reconnect"
634 return 0
635 }
636
637 return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
638 }
639
640 # Start gdbserver in extended mode with OPTIONS and connect to it. Note
641 # this frobs $gdbserver_protocol, so should be used only from a board
642 # that usually connects in target remote mode.
643 proc gdbserver_start_extended { {options ""} } {
644 global gdbserver_protocol
645 global gdbserver_gdbport
646 global use_gdb_stub
647
648 set gdbserver_options "--multi"
649
650 if { $options != "" } {
651 append gdbserver_options " $options"
652 }
653
654 if { [catch { gdbserver_start $gdbserver_options "" } res] == 1 } {
655 perror $res
656 return 2
657 }
658 set gdbserver_protocol [lindex $res 0]
659 if { [string first "extended-" $gdbserver_protocol] != 0} {
660 set gdbserver_protocol "extended-$gdbserver_protocol"
661 }
662 set gdbserver_gdbport [lindex $res 1]
663
664 # Even if the board file is testing with target remote, our caller
665 # wants to test against gdbserver in extended-remote mode. Make sure to
666 # disable stub-like techniques.
667 set use_gdb_stub 0
668
669 return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
670 }
671
672 # Start and connect to a gdbserver in extended/multi mode. Unlike
673 # gdbserver_start_extended, this does not frob $gdbserver_protocol.
674
675 proc gdbserver_start_multi { } {
676 global gdbserver_protocol
677 global gdbserver_gdbport
678
679 if { [catch { gdbserver_start "--multi" "" } res] == 1 } {
680 perror $res
681 return 2
682 }
683 set gdbserver_protocol [lindex $res 0]
684 set gdbserver_gdbport [lindex $res 1]
685
686 return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
687 }
688
689 # Start a gdbserver process in multi/extended mode, and have GDB
690 # connect to it (MI version). Return 0 on success, or non-zero on
691 # failure.
692
693 proc mi_gdbserver_start_multi { } {
694 global gdbserver_protocol
695 global gdbserver_gdbport
696
697 if { [catch { gdbserver_start "--multi" "" } res] == 1 } {
698 perror $res
699 return 2
700 }
701 set gdbserver_protocol [lindex $res 0]
702 set gdbserver_gdbport [lindex $res 1]
703
704 return [mi_gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
705 }
706
707 # Check if debugging is enabled for gdbserver.
708
709 proc gdbserver_debug_enabled { } {
710 global gdbserverdebug
711
712 # If not already read, get the debug setting from environment or board setting.
713 if ![info exists gdbserverdebug] {
714 global env
715 if [info exists env(GDBSERVER_DEBUG)] {
716 set gdbserverdebug $env(GDBSERVER_DEBUG)
717 } elseif [target_info exists gdbserver,debug] {
718 set gdbserverdebug [target_info gdbserver,debug]
719 } else {
720 return 0
721 }
722 }
723
724 # Ensure it is not empty.
725 return [expr { $gdbserverdebug != "" }]
726 }
727
728 # Write the command line used to invocate gdbserver to the cmd file.
729
730 proc gdbserver_write_cmd_file { cmdline } {
731 set logfile [standard_output_file_with_gdb_instance gdbserver.cmd]
732 set cmd_file [open $logfile w]
733 puts $cmd_file $cmdline
734 catch "close $cmd_file"
735 }
736
737 # Override gdb_debug_init so that we can set replay logging in GDB if required.
738 # Backup the original function so we can call it afterwards
739
740 rename gdb_debug_init _gdb_debug_init
741
742 proc gdb_debug_init { } {
743 global gdbserverdebug
744 global gdb_prompt
745
746 if [gdbserver_debug_enabled] {
747 foreach entry [split $gdbserverdebug ,] {
748 if { $entry == "replay" || $entry == "all"} {
749 set replayfile [standard_output_file_with_gdb_instance gdbserver.replay]
750 send_gdb "set remotelogfile $replayfile\n" optional
751 gdb_expect 10 {
752 -re "$gdb_prompt $" {}
753 }
754 }
755 }
756 }
757
758 # Now call the standard debug init function
759 _gdb_debug_init
760 }