* lib/gdb.exp (skip_hw_breakpoint_tests): New procedure.
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / mi-support.exp
CommitLineData
7b6bb8da 1# Copyright 1999, 2000, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
6aba47ca 2# Free Software Foundation, Inc.
fb40c209
AC
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
fb40c209 7# (at your option) any later version.
e22f8b7c 8#
fb40c209
AC
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
fb40c209 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
fb40c209 16
fb40c209
AC
17# This file was based on a file written by Fred Fish. (fnf@cygnus.com)
18
19# Test setup routines that work with the MI interpreter.
20
21# The variable mi_gdb_prompt is a regexp which matches the gdb mi prompt.
22# Set it if it is not already set.
23global mi_gdb_prompt
24if ![info exists mi_gdb_prompt] then {
25 set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
26}
27
ecd3fd0f
BR
28global mi_inferior_spawn_id
29global mi_inferior_tty_name
30
fb40c209
AC
31set MIFLAGS "-i=mi"
32
84a02e58 33set thread_selected_re "=thread-selected,id=\"\[0-9\]+\"\r\n"
c86cf029 34set library_loaded_re "=library-loaded\[^\n\]+\"\r\n"
66bb093b 35
fb40c209
AC
36#
37# mi_gdb_exit -- exit the GDB, killing the target program if necessary
38#
39proc mi_gdb_exit {} {
40 catch mi_uncatched_gdb_exit
41}
42
43proc mi_uncatched_gdb_exit {} {
44 global GDB
6b8ce727 45 global INTERNAL_GDBFLAGS GDBFLAGS
fb40c209
AC
46 global verbose
47 global gdb_spawn_id;
48 global gdb_prompt
49 global mi_gdb_prompt
50 global MIFLAGS
51
52 gdb_stop_suppressing_tests;
53
54 if { [info procs sid_exit] != "" } {
55 sid_exit
56 }
57
58 if ![info exists gdb_spawn_id] {
59 return;
60 }
61
6b8ce727 62 verbose "Quitting $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS"
fb40c209
AC
63
64 if { [is_remote host] && [board_info host exists fileid] } {
65 send_gdb "999-gdb-exit\n";
66 gdb_expect 10 {
67 -re "y or n" {
68 send_gdb "y\n";
69 exp_continue;
70 }
71 -re "Undefined command.*$gdb_prompt $" {
72 send_gdb "quit\n"
73 exp_continue;
74 }
75 -re "DOSEXIT code" { }
76 default { }
77 }
78 }
79
80 if ![is_remote host] {
81 remote_close host;
82 }
83 unset gdb_spawn_id
84}
85
86#
79732189 87# default_mi_gdb_start [INFERIOR_PTY] -- start gdb running, default procedure
ecd3fd0f
BR
88#
89# INFERIOR_PTY should be set to separate-inferior-tty to have the inferior work
90# with it's own PTY. If set to same-inferior-tty, the inferior shares GDB's PTY.
91# The default value is same-inferior-tty.
fb40c209
AC
92#
93# When running over NFS, particularly if running many simultaneous
94# tests on different hosts all using the same server, things can
95# get really slow. Give gdb at least 3 minutes to start up.
96#
79732189 97proc default_mi_gdb_start { args } {
fb40c209
AC
98 global verbose
99 global GDB
6b8ce727 100 global INTERNAL_GDBFLAGS GDBFLAGS
fb40c209
AC
101 global gdb_prompt
102 global mi_gdb_prompt
103 global timeout
104 global gdb_spawn_id;
105 global MIFLAGS
106
107 gdb_stop_suppressing_tests;
ecd3fd0f
BR
108 set inferior_pty no-tty
109
110 if { [llength $args] == 1} {
111 set inferior_pty [lindex $args 0]
112 }
113
114 set separate_inferior_pty [string match $inferior_pty separate-inferior-tty]
fb40c209 115
1759b3c3
AC
116 # Start SID.
117 if { [info procs sid_start] != "" } {
118 verbose "Spawning SID"
119 sid_start
120 }
121
6b8ce727 122 verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS"
fb40c209
AC
123
124 if [info exists gdb_spawn_id] {
125 return 0;
126 }
127
128 if ![is_remote host] {
129 if { [which $GDB] == 0 } then {
130 perror "$GDB does not exist."
131 exit 1
132 }
133 }
ecd3fd0f
BR
134
135 # Create the new PTY for the inferior process.
136 if { $separate_inferior_pty } {
137 spawn -pty
138 global mi_inferior_spawn_id
139 global mi_inferior_tty_name
140 set mi_inferior_spawn_id $spawn_id
141 set mi_inferior_tty_name $spawn_out(slave,name)
142 }
143
6b8ce727 144 set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS [host_info gdb_opts]"];
fb40c209
AC
145 if { $res < 0 || $res == "" } {
146 perror "Spawning $GDB failed."
147 return 1;
148 }
149 gdb_expect {
1f312e79
JJ
150 -re "~\"GNU.*\r\n~\".*$mi_gdb_prompt$" {
151 # We have a new format mi startup prompt. If we are
152 # running mi1, then this is an error as we should be
153 # using the old-style prompt.
154 if { $MIFLAGS == "-i=mi1" } {
155 perror "(mi startup) Got unexpected new mi prompt."
156 remote_close host;
157 return -1;
158 }
159 verbose "GDB initialized."
160 }
161 -re "\[^~\].*$mi_gdb_prompt$" {
162 # We have an old format mi startup prompt. If we are
163 # not running mi1, then this is an error as we should be
164 # using the new-style prompt.
165 if { $MIFLAGS != "-i=mi1" } {
166 perror "(mi startup) Got unexpected old mi prompt."
167 remote_close host;
168 return -1;
169 }
d20bf2e8 170 verbose "GDB initialized."
fb40c209 171 }
76c520e0
AC
172 -re ".*unrecognized option.*for a complete list of options." {
173 untested "Skip mi tests (not compiled with mi support)."
174 remote_close host;
175 return -1;
176 }
7d76bd60
MK
177 -re ".*Interpreter `mi' unrecognized." {
178 untested "Skip mi tests (not compiled with mi support)."
179 remote_close host;
180 return -1;
181 }
fb40c209
AC
182 timeout {
183 perror "(timeout) GDB never initialized after 10 seconds."
184 remote_close host;
185 return -1
186 }
187 }
188 set gdb_spawn_id -1;
189
190 # FIXME: mi output does not go through pagers, so these can be removed.
191 # force the height to "unlimited", so no pagers get used
192 send_gdb "100-gdb-set height 0\n"
193 gdb_expect 10 {
194 -re ".*100-gdb-set height 0\r\n100\\\^done\r\n$mi_gdb_prompt$" {
195 verbose "Setting height to 0." 2
196 }
197 timeout {
198 warning "Couldn't set the height to 0"
199 }
200 }
201 # force the width to "unlimited", so no wraparound occurs
202 send_gdb "101-gdb-set width 0\n"
203 gdb_expect 10 {
204 -re ".*101-gdb-set width 0\r\n101\\\^done\r\n$mi_gdb_prompt$" {
205 verbose "Setting width to 0." 2
206 }
207 timeout {
208 warning "Couldn't set the width to 0."
209 }
210 }
ecd3fd0f
BR
211 # If allowing the inferior to have its own PTY then assign the inferior
212 # its own terminal device here.
213 if { $separate_inferior_pty } {
214 send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n"
215 gdb_expect 10 {
216 -re ".*102\\\^done\r\n$mi_gdb_prompt$" {
217 verbose "redirect inferior output to new terminal device."
218 }
219 timeout {
220 warning "Couldn't redirect inferior output." 2
221 }
222 }
223 }
fb40c209 224
f7f9a841
VP
225 detect_async
226
fb40c209
AC
227 return 0;
228}
229
79732189
AR
230#
231# Overridable function. You can override this function in your
232# baseboard file.
233#
234proc mi_gdb_start { args } {
235 return [default_mi_gdb_start $args]
236}
237
fb40c209
AC
238# Many of the tests depend on setting breakpoints at various places and
239# running until that breakpoint is reached. At times, we want to start
240# with a clean-slate with respect to breakpoints, so this utility proc
241# lets us do this without duplicating this code everywhere.
242#
243
244proc mi_delete_breakpoints {} {
245 global mi_gdb_prompt
246
247# FIXME: The mi operation won't accept a prompt back and will use the 'all' arg
248 send_gdb "102-break-delete\n"
249 gdb_expect 30 {
250 -re "Delete all breakpoints.*y or n.*$" {
251 send_gdb "y\n";
252 exp_continue
253 }
39fb8e9e 254 -re "102-break-delete\r\n102\\\^done\r\n$mi_gdb_prompt$" {
fb40c209
AC
255 # This happens if there were no breakpoints
256 }
f1c8a949 257 timeout { perror "Delete all breakpoints in mi_delete_breakpoints (timeout)" ; return }
fb40c209
AC
258 }
259
260# The correct output is not "No breakpoints or watchpoints." but an
261# empty BreakpointTable. Also, a query is not acceptable with mi.
262 send_gdb "103-break-list\n"
263 gdb_expect 30 {
264 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{\}\r\n$mi_gdb_prompt$" {}
6f3f3097 265 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[\\\]\}\r\n$mi_gdb_prompt$" {}
fb40c209
AC
266 -re "103-break-list\r\n103\\\^doneNo breakpoints or watchpoints.\r\n\r\n$mi_gdb_prompt$" {warning "Unexpected console text received"}
267 -re "$mi_gdb_prompt$" { perror "Breakpoints not deleted" ; return }
268 -re "Delete all breakpoints.*or n.*$" {
269 warning "Unexpected prompt for breakpoints deletion";
270 send_gdb "y\n";
271 exp_continue
272 }
273 timeout { perror "-break-list (timeout)" ; return }
274 }
275}
276
277proc mi_gdb_reinitialize_dir { subdir } {
278 global mi_gdb_prompt
da81390b 279 global MIFLAGS
fb40c209
AC
280
281 global suppress_flag
282 if { $suppress_flag } {
283 return
284 }
285
286 if [is_remote host] {
287 return "";
288 }
289
da81390b
JJ
290 if { $MIFLAGS == "-i=mi1" } {
291 send_gdb "104-environment-directory\n"
292 gdb_expect 60 {
fb40c209
AC
293 -re ".*Reinitialize source path to empty.*y or n. " {
294 warning "Got confirmation prompt for dir reinitialization."
295 send_gdb "y\n"
296 gdb_expect 60 {
297 -re "$mi_gdb_prompt$" {}
298 timeout {error "Dir reinitialization failed (timeout)"}
299 }
300 }
301 -re "$mi_gdb_prompt$" {}
302 timeout {error "Dir reinitialization failed (timeout)"}
da81390b
JJ
303 }
304 } else {
305 send_gdb "104-environment-directory -r\n"
306 gdb_expect 60 {
307 -re "104\\\^done,source-path=.*\r\n$mi_gdb_prompt$" {}
308 -re "$mi_gdb_prompt$" {}
309 timeout {error "Dir reinitialization failed (timeout)"}
310 }
fb40c209
AC
311 }
312
313 send_gdb "105-environment-directory $subdir\n"
314 gdb_expect 60 {
315 -re "Source directories searched.*$mi_gdb_prompt$" {
316 verbose "Dir set to $subdir"
317 }
da81390b 318 -re "105\\\^done.*\r\n$mi_gdb_prompt$" {
fb40c209
AC
319 # FIXME: We return just the prompt for now.
320 verbose "Dir set to $subdir"
321 # perror "Dir \"$subdir\" failed."
322 }
323 }
324}
325
da6012e5
DJ
326# Send GDB the "target" command.
327# FIXME: Some of these patterns are not appropriate for MI. Based on
328# config/monitor.exp:gdb_target_command.
329proc mi_gdb_target_cmd { targetname serialport } {
330 global mi_gdb_prompt
331
ef783a7d 332 set serialport_re [string_to_regexp $serialport]
da6012e5
DJ
333 for {set i 1} {$i <= 3} {incr i} {
334 send_gdb "47-target-select $targetname $serialport\n"
335 gdb_expect 60 {
56a8e183 336 -re "47\\^connected.*$mi_gdb_prompt" {
da6012e5
DJ
337 verbose "Set target to $targetname";
338 return 0;
339 }
401ea829
JB
340 -re "unknown host.*$mi_gdb_prompt" {
341 verbose "Couldn't look up $serialport"
342 }
da6012e5
DJ
343 -re "Couldn't establish connection to remote.*$mi_gdb_prompt$" {
344 verbose "Connection failed";
345 }
346 -re "Remote MIPS debugging.*$mi_gdb_prompt$" {
347 verbose "Set target to $targetname";
348 return 0;
349 }
ef783a7d 350 -re "Remote debugging using .*$serialport_re.*$mi_gdb_prompt$" {
da6012e5
DJ
351 verbose "Set target to $targetname";
352 return 0;
353 }
354 -re "Remote target $targetname connected to.*$mi_gdb_prompt$" {
355 verbose "Set target to $targetname";
356 return 0;
357 }
358 -re "Connected to.*$mi_gdb_prompt$" {
359 verbose "Set target to $targetname";
360 return 0;
361 }
362 -re "Ending remote.*$mi_gdb_prompt$" { }
363 -re "Connection refused.*$mi_gdb_prompt$" {
364 verbose "Connection refused by remote target. Pausing, and trying again."
365 sleep 5
366 continue
367 }
56a8e183
PA
368 -re "Non-stop mode requested, but remote does not support non-stop.*$mi_gdb_prompt" {
369 unsupported "Non-stop mode not supported"
370 return 1
371 }
da6012e5
DJ
372 -re "Timeout reading from remote system.*$mi_gdb_prompt$" {
373 verbose "Got timeout error from gdb.";
374 }
375 timeout {
376 send_gdb "\ 3";
377 break
378 }
379 }
380 }
381 return 1
382}
383
fb40c209 384#
da6012e5 385# load a file into the debugger (file command only).
fb40c209
AC
386# return a -1 if anything goes wrong.
387#
da6012e5 388proc mi_gdb_file_cmd { arg } {
fb40c209
AC
389 global verbose
390 global loadpath
391 global loadfile
392 global GDB
393 global mi_gdb_prompt
b741e217 394 global last_loaded_file
fb40c209
AC
395 upvar timeout timeout
396
b741e217 397 set last_loaded_file $arg
b53f9b27 398
da6012e5
DJ
399 if [is_remote host] {
400 set arg [remote_download host $arg];
401 if { $arg == "" } {
402 error "download failed"
403 return -1;
404 }
405 }
fb40c209 406
fb40c209
AC
407# FIXME: Several of these patterns are only acceptable for console
408# output. Queries are an error for mi.
409 send_gdb "105-file-exec-and-symbols $arg\n"
410 gdb_expect 120 {
411 -re "Reading symbols from.*done.*$mi_gdb_prompt$" {
412 verbose "\t\tLoaded $arg into the $GDB"
da6012e5 413 return 0
fb40c209
AC
414 }
415 -re "has no symbol-table.*$mi_gdb_prompt$" {
416 perror "$arg wasn't compiled with \"-g\""
417 return -1
418 }
fb40c209
AC
419 -re "Load new symbol table from \".*\".*y or n. $" {
420 send_gdb "y\n"
421 gdb_expect 120 {
422 -re "Reading symbols from.*done.*$mi_gdb_prompt$" {
423 verbose "\t\tLoaded $arg with new symbol table into $GDB"
424 # All OK
425 }
426 timeout {
427 perror "(timeout) Couldn't load $arg, other program already loaded."
428 return -1
429 }
430 }
431 }
432 -re "No such file or directory.*$mi_gdb_prompt$" {
433 perror "($arg) No such file or directory\n"
434 return -1
435 }
436 -re "105-file-exec-and-symbols .*\r\n105\\\^done\r\n$mi_gdb_prompt$" {
da6012e5
DJ
437 # We (MI) are just giving the prompt back for now, instead of giving
438 # some acknowledgement.
439 return 0
440 }
fb40c209
AC
441 timeout {
442 perror "couldn't load $arg into $GDB (timed out)."
443 return -1
444 }
da6012e5 445 eof {
fb40c209
AC
446 # This is an attempt to detect a core dump, but seems not to
447 # work. Perhaps we need to match .* followed by eof, in which
448 # gdb_expect does not seem to have a way to do that.
449 perror "couldn't load $arg into $GDB (end of file)."
450 return -1
451 }
452 }
da6012e5
DJ
453}
454
455#
b741e217 456# connect to the target and download a file, if necessary.
da6012e5
DJ
457# return a -1 if anything goes wrong.
458#
b741e217 459proc mi_gdb_target_load { } {
da6012e5
DJ
460 global verbose
461 global loadpath
462 global loadfile
463 global GDB
464 global mi_gdb_prompt
e2d69cb5
JZ
465
466 if [target_info exists gdb_load_timeout] {
467 set loadtimeout [target_info gdb_load_timeout]
468 } else {
469 set loadtimeout 1600
470 }
da6012e5 471
da6012e5 472 if { [info procs gdbserver_gdb_load] != "" } {
2226f861 473 mi_gdb_test "kill" ".*" ""
b741e217 474 set res [gdbserver_gdb_load]
da6012e5
DJ
475 set protocol [lindex $res 0]
476 set gdbport [lindex $res 1]
477
478 if { [mi_gdb_target_cmd $protocol $gdbport] != 0 } {
479 return -1
480 }
481 } elseif { [info procs send_target_sid] != "" } {
fb40c209 482 # For SID, things get complex
2b97317d
KB
483 send_gdb "kill\n"
484 gdb_expect 10 {
485 -re ".*$mi_gdb_prompt$"
486 }
fb40c209 487 send_target_sid
e2d69cb5 488 gdb_expect $loadtimeout {
2f168eed 489 -re "\\^done.*$mi_gdb_prompt$" {
fb40c209
AC
490 }
491 timeout {
e2d69cb5 492 perror "Unable to connect to SID target (timeout)"
fb40c209
AC
493 return -1
494 }
495 }
496 send_gdb "48-target-download\n"
e2d69cb5 497 gdb_expect $loadtimeout {
fb40c209
AC
498 -re "48\\^done.*$mi_gdb_prompt$" {
499 }
500 timeout {
e2d69cb5 501 perror "Unable to download to SID target (timeout)"
fb40c209
AC
502 return -1
503 }
504 }
505 } elseif { [target_info protocol] == "sim" } {
506 # For the simulator, just connect to it directly.
507 send_gdb "47-target-select sim\n"
e2d69cb5 508 gdb_expect $loadtimeout {
fb40c209
AC
509 -re "47\\^connected.*$mi_gdb_prompt$" {
510 }
511 timeout {
e2d69cb5 512 perror "Unable to select sim target (timeout)"
fb40c209
AC
513 return -1
514 }
515 }
516 send_gdb "48-target-download\n"
e2d69cb5 517 gdb_expect $loadtimeout {
fb40c209
AC
518 -re "48\\^done.*$mi_gdb_prompt$" {
519 }
520 timeout {
e2d69cb5 521 perror "Unable to download to sim target (timeout)"
fb40c209
AC
522 return -1
523 }
524 }
b53f9b27
MS
525 } elseif { [target_info gdb_protocol] == "remote" } {
526 # remote targets
8e3049aa
PB
527 if { [mi_gdb_target_cmd "remote" [target_info netport]] != 0 } {
528 perror "Unable to connect to remote target"
529 return -1
b53f9b27
MS
530 }
531 send_gdb "48-target-download\n"
e2d69cb5 532 gdb_expect $loadtimeout {
b53f9b27
MS
533 -re "48\\^done.*$mi_gdb_prompt$" {
534 }
535 timeout {
e2d69cb5 536 perror "Unable to download to remote target (timeout)"
b53f9b27
MS
537 return -1
538 }
539 }
fb40c209
AC
540 }
541 return 0
542}
543
b741e217
DJ
544#
545# load a file into the debugger.
546# return a -1 if anything goes wrong.
547#
548proc mi_gdb_load { arg } {
549 if { $arg != "" } {
550 return [mi_gdb_file_cmd $arg]
551 }
552 return 0
553}
554
ecd3fd0f
BR
555# mi_gdb_test COMMAND PATTERN MESSAGE [IPATTERN] -- send a command to gdb;
556# test the result.
fb40c209
AC
557#
558# COMMAND is the command to execute, send to GDB with send_gdb. If
559# this is the null string no command is sent.
560# PATTERN is the pattern to match for a PASS, and must NOT include
561# the \r\n sequence immediately before the gdb prompt.
f1ea48cb
BR
562# MESSAGE is the message to be printed. (If this is the empty string,
563# then sometimes we don't call pass or fail at all; I don't
564# understand this at all.)
ecd3fd0f
BR
565# IPATTERN is the pattern to match for the inferior's output. This parameter
566# is optional. If present, it will produce a PASS if the match is
567# successful, and a FAIL if unsuccessful.
fb40c209
AC
568#
569# Returns:
570# 1 if the test failed,
571# 0 if the test passes,
572# -1 if there was an internal error.
573#
574proc mi_gdb_test { args } {
575 global verbose
576 global mi_gdb_prompt
07c98896 577 global GDB expect_out
fb40c209
AC
578 upvar timeout timeout
579
fb40c209
AC
580 set command [lindex $args 0]
581 set pattern [lindex $args 1]
f1ea48cb 582 set message [lindex $args 2]
fb40c209 583
ecd3fd0f
BR
584 if [llength $args]==4 {
585 set ipattern [lindex $args 3]
586 }
587
fb40c209
AC
588 if [llength $args]==5 {
589 set question_string [lindex $args 3];
590 set response_string [lindex $args 4];
591 } else {
592 set question_string "^FOOBAR$"
593 }
594
595 if $verbose>2 then {
596 send_user "Sending \"$command\" to gdb\n"
597 send_user "Looking to match \"$pattern\"\n"
598 send_user "Message is \"$message\"\n"
599 }
600
601 set result -1
602 set string "${command}\n";
39fb8e9e
BR
603 set string_regex [string_to_regexp $command]
604
fb40c209
AC
605 if { $command != "" } {
606 while { "$string" != "" } {
607 set foo [string first "\n" "$string"];
608 set len [string length "$string"];
609 if { $foo < [expr $len - 1] } {
610 set str [string range "$string" 0 $foo];
611 if { [send_gdb "$str"] != "" } {
612 global suppress_flag;
613
614 if { ! $suppress_flag } {
615 perror "Couldn't send $command to GDB.";
616 }
617 fail "$message";
618 return $result;
619 }
620 gdb_expect 2 {
621 -re "\[\r\n\]" { }
622 timeout { }
623 }
624 set string [string range "$string" [expr $foo + 1] end];
625 } else {
626 break;
627 }
628 }
629 if { "$string" != "" } {
630 if { [send_gdb "$string"] != "" } {
631 global suppress_flag;
632
633 if { ! $suppress_flag } {
634 perror "Couldn't send $command to GDB.";
635 }
636 fail "$message";
637 return $result;
638 }
639 }
640 }
641
642 if [info exists timeout] {
643 set tmt $timeout;
644 } else {
645 global timeout;
646 if [info exists timeout] {
647 set tmt $timeout;
648 } else {
649 set tmt 60;
650 }
651 }
9d81d21b 652 verbose -log "Expecting: ^($string_regex\[\r\n\]+)?($pattern\[\r\n\]+$mi_gdb_prompt\[ \]*)"
fb40c209
AC
653 gdb_expect $tmt {
654 -re "\\*\\*\\* DOSEXIT code.*" {
655 if { $message != "" } {
656 fail "$message";
657 }
658 gdb_suppress_entire_file "GDB died";
659 return -1;
660 }
661 -re "Ending remote debugging.*$mi_gdb_prompt\[ \]*$" {
662 if ![isnative] then {
663 warning "Can`t communicate to remote target."
664 }
665 gdb_exit
666 gdb_start
667 set result -1
7ddebc7e 668 }
39fb8e9e
BR
669 -re "^($string_regex\[\r\n\]+)?($pattern\[\r\n\]+$mi_gdb_prompt\[ \]*)" {
670 # At this point, $expect_out(1,string) is the MI input command.
671 # and $expect_out(2,string) is the MI output command.
672 # If $expect_out(1,string) is "", then there was no MI input command here.
673
40e55bef
BR
674 # NOTE, there is no trailing anchor because with GDB/MI,
675 # asynchronous responses can happen at any point, causing more
676 # data to be available. Normally an anchor is used to make
677 # sure the end of the output is matched, however, $mi_gdb_prompt
678 # is just as good of an anchor since mi_gdb_test is meant to
679 # match a single mi output command. If a second GDB/MI output
680 # response is sent, it will be in the buffer for the next
681 # time mi_gdb_test is called.
7ddebc7e
KS
682 if ![string match "" $message] then {
683 pass "$message"
684 }
685 set result 0
fb40c209
AC
686 }
687 -re "(${question_string})$" {
688 send_gdb "$response_string\n";
689 exp_continue;
690 }
691 -re "Undefined.* command:.*$mi_gdb_prompt\[ \]*$" {
692 perror "Undefined command \"$command\"."
693 fail "$message"
694 set result 1
695 }
696 -re "Ambiguous command.*$mi_gdb_prompt\[ \]*$" {
697 perror "\"$command\" is not a unique command name."
698 fail "$message"
699 set result 1
fb40c209
AC
700 }
701 -re "Program exited with code \[0-9\]+.*$mi_gdb_prompt\[ \]*$" {
702 if ![string match "" $message] then {
ed4c619a 703 set errmsg "$message (the program exited)"
fb40c209 704 } else {
ed4c619a 705 set errmsg "$command (the program exited)"
fb40c209
AC
706 }
707 fail "$errmsg"
708 return -1
709 }
710 -re "The program is not being run.*$mi_gdb_prompt\[ \]*$" {
711 if ![string match "" $message] then {
ed4c619a 712 set errmsg "$message (the program is no longer running)"
fb40c209 713 } else {
ed4c619a 714 set errmsg "$command (the program is no longer running)"
fb40c209
AC
715 }
716 fail "$errmsg"
717 return -1
718 }
719 -re ".*$mi_gdb_prompt\[ \]*$" {
720 if ![string match "" $message] then {
721 fail "$message"
722 }
723 set result 1
724 }
725 "<return>" {
726 send_gdb "\n"
727 perror "Window too small."
728 fail "$message"
729 }
730 -re "\\(y or n\\) " {
731 send_gdb "n\n"
732 perror "Got interactive prompt."
733 fail "$message"
734 }
735 eof {
736 perror "Process no longer exists"
737 if { $message != "" } {
738 fail "$message"
739 }
740 return -1
741 }
742 full_buffer {
743 perror "internal buffer is full."
744 fail "$message"
745 }
746 timeout {
747 if ![string match "" $message] then {
748 fail "$message (timeout)"
749 }
750 set result 1
751 }
752 }
ecd3fd0f
BR
753
754 # If the GDB output matched, compare the inferior output.
755 if { $result == 0 } {
756 if [ info exists ipattern ] {
d084b331
DJ
757 if { ![target_info exists gdb,noinferiorio] } {
758 global mi_inferior_spawn_id
759 expect {
760 -i $mi_inferior_spawn_id -re "$ipattern" {
761 pass "$message inferior output"
762 }
763 timeout {
764 fail "$message inferior output (timeout)"
765 set result 1
766 }
ecd3fd0f 767 }
d084b331
DJ
768 } else {
769 unsupported "$message inferior output"
ecd3fd0f
BR
770 }
771 }
772 }
773
fb40c209
AC
774 return $result
775}
776
777#
778# MI run command. (A modified version of gdb_run_cmd)
779#
780
781# In patterns, the newline sequence ``\r\n'' is matched explicitly as
782# ``.*$'' could swallow up output that we attempt to match elsewhere.
783
784proc mi_run_cmd {args} {
785 global suppress_flag
786 if { $suppress_flag } {
787 return -1
788 }
789 global mi_gdb_prompt
66bb093b 790 global thread_selected_re
c86cf029 791 global library_loaded_re
fb40c209
AC
792
793 if [target_info exists gdb_init_command] {
794 send_gdb "[target_info gdb_init_command]\n";
795 gdb_expect 30 {
796 -re "$mi_gdb_prompt$" { }
797 default {
798 perror "gdb_init_command for target failed";
56a8e183 799 return -1;
fb40c209
AC
800 }
801 }
802 }
803
b741e217 804 if { [mi_gdb_target_load] < 0 } {
56a8e183 805 return -1
b741e217
DJ
806 }
807
fb40c209
AC
808 if [target_info exists use_gdb_stub] {
809 if [target_info exists gdb,do_reload_on_run] {
bb378428 810 send_gdb "220-exec-continue\n";
fb40c209 811 gdb_expect 60 {
d0b76dc6 812 -re "220\\^running\[\r\n\]+\\*running,thread-id=\"\[^\"\]+\"\r\n$mi_gdb_prompt" {}
fb40c209
AC
813 default {}
814 }
56a8e183 815 return 0;
fb40c209 816 }
6a90e1d0
AC
817
818 if [target_info exists gdb,start_symbol] {
819 set start [target_info gdb,start_symbol];
820 } else {
821 set start "start";
822 }
823
824 # HACK: Should either use 000-jump or fix the target code
825 # to better handle RUN.
826 send_gdb "jump *$start\n"
827 warning "Using CLI jump command, expect run-to-main FAIL"
56a8e183 828 return 0
fb40c209
AC
829 }
830
bb378428 831 send_gdb "220-exec-run $args\n"
fb40c209 832 gdb_expect {
c86cf029 833 -re "220\\^running\r\n(\\*running,thread-id=\"\[^\"\]+\"\r\n|=thread-created,id=\"1\",group-id=\"\[0-9\]+\"\r\n)*(${library_loaded_re})*(${thread_selected_re})?${mi_gdb_prompt}" {
fb40c209 834 }
56a8e183
PA
835 -re "\\^error,msg=\"The target does not support running in non-stop mode.\"" {
836 unsupported "Non-stop mode not supported"
837 return -1
838 }
fb40c209
AC
839 timeout {
840 perror "Unable to start target"
56a8e183 841 return -1
fb40c209
AC
842 }
843 }
2d0720d9 844 # NOTE: Shortly after this there will be a ``000*stopped,...(gdb)''
56a8e183
PA
845
846 return 0
fb40c209
AC
847}
848
849#
850# Just like run-to-main but works with the MI interface
851#
852
853proc mi_run_to_main { } {
854 global suppress_flag
855 if { $suppress_flag } {
856 return -1
857 }
858
fb40c209
AC
859 global srcdir
860 global subdir
861 global binfile
862 global srcfile
863
fb40c209
AC
864 mi_delete_breakpoints
865 mi_gdb_reinitialize_dir $srcdir/$subdir
866 mi_gdb_load ${binfile}
867
08b468e0
KS
868 mi_runto main
869}
fb40c209 870
08b468e0
KS
871
872# Just like gdb's "runto" proc, it will run the target to a given
873# function. The big difference here between mi_runto and mi_execute_to
874# is that mi_execute_to must have the inferior running already. This
875# proc will (like gdb's runto) (re)start the inferior, too.
876#
877# FUNC is the linespec of the place to stop (it inserts a breakpoint here).
878# It returns:
879# -1 if test suppressed, failed, timedout
880# 0 if test passed
881
f7e97bb3 882proc mi_runto_helper {func run_or_continue} {
08b468e0
KS
883 global suppress_flag
884 if { $suppress_flag } {
885 return -1
886 }
887
888 global mi_gdb_prompt expect_out
76ff342d 889 global hex decimal fullname_syntax
08b468e0
KS
890
891 set test "mi runto $func"
038224f6 892 mi_gdb_test "200-break-insert -t $func" \
d24317b4 893 "200\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",line=\"\[0-9\]*\",times=\"0\",original-location=\".*\"\}" \
08b468e0
KS
894 "breakpoint at $func"
895
896 if {![regexp {number="[0-9]+"} $expect_out(buffer) str]
897 || ![scan $str {number="%d"} bkptno]} {
898 set bkptno {[0-9]+}
899 }
900
f7e97bb3 901 if {$run_or_continue == "run"} {
56a8e183
PA
902 if { [mi_run_cmd] < 0 } {
903 return -1
904 }
f7e97bb3 905 } else {
bb378428 906 mi_send_resuming_command "exec-continue" "$test"
f7e97bb3 907 }
74a44383 908
18ac113b 909 mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } $test
fb40c209
AC
910}
911
f7e97bb3 912proc mi_runto {func} {
56a8e183 913 return [mi_runto_helper $func "run"]
f7e97bb3 914}
fb40c209
AC
915
916# Next to the next statement
08b468e0 917# For return values, see mi_execute_to_helper
fb40c209
AC
918
919proc mi_next { test } {
dc360f58 920 return [mi_next_to {.*} {.*} {.*} {.*} $test]
fb40c209
AC
921}
922
923
924# Step to the next statement
08b468e0 925# For return values, see mi_execute_to_helper
fb40c209
AC
926
927proc mi_step { test } {
dc360f58 928 return [mi_step_to {.*} {.*} {.*} {.*} $test]
fb40c209 929}
dcf95b47 930
f7f9a841
VP
931set async "unknown"
932
933proc detect_async {} {
934 global async
935 global mi_gdb_prompt
936
c6ebd6cf 937 send_gdb "show target-async\n"
f7f9a841 938
a2840c35 939 gdb_expect {
c6ebd6cf 940 -re ".*Controlling the inferior in asynchronous mode is on...*$mi_gdb_prompt$" {
a2840c35
VP
941 set async 1
942 }
943 -re ".*$mi_gdb_prompt$" {
944 set async 0
945 }
946 timeout {
947 set async 0
f7f9a841
VP
948 }
949 }
950 return $async
951}
952
bb378428
VP
953# Wait for MI *stopped notification to appear.
954# The REASON, FUNC, ARGS, FILE and LINE are regular expressions
955# to match against whatever is output in *stopped. ARGS should
956# not include [] the list of argument is enclosed in, and other
957# regular expressions should not include quotes.
958# If EXTRA is a list of one element, it's the regular expression
959# for output expected right after *stopped, and before GDB prompt.
960# If EXTRA is a list of two elements, the first element is for
961# output right after *stopped, and the second element is output
962# right after reason field. The regex after reason should not include
963# the comma separating it from the following fields.
964#
965# When we fail to match output at all, -1 is returned. Otherwise,
966# the line at which we stop is returned. This is useful when exact
967# line is not possible to specify for some reason -- one can pass
d0b76dc6
DJ
968# the .* or "\[0-9\]*" regexps for line, and then check the line
969# programmatically.
970#
971# Do not pass .* for any argument if you are expecting more than one stop.
bb378428 972proc mi_expect_stop { reason func args file line extra test } {
1902c51f 973
dcf95b47
DJ
974 global mi_gdb_prompt
975 global hex
976 global decimal
76ff342d 977 global fullname_syntax
f7f9a841 978 global async
66bb093b 979 global thread_selected_re
bb378428
VP
980
981 set after_stopped ""
982 set after_reason ""
983 if { [llength $extra] == 2 } {
984 set after_stopped [lindex $extra 0]
985 set after_reason [lindex $extra 1]
986 set after_reason "${after_reason},"
987 } elseif { [llength $extra] == 1 } {
988 set after_stopped [lindex $extra 0]
989 }
990
f7f9a841
VP
991 if {$async} {
992 set prompt_re ""
993 } else {
d0b76dc6 994 set prompt_re "$mi_gdb_prompt$"
f7f9a841
VP
995 }
996
997 if { $reason == "really-no-reason" } {
998 gdb_expect {
d0b76dc6 999 -re "\\*stopped\r\n$prompt_re" {
f7f9a841
VP
1000 pass "$test"
1001 }
1002 timeout {
1003 fail "$test (unknown output after running)"
1004 }
1005 }
1006 return
1007 }
1008
bb378428
VP
1009 if { $reason == "exited-normally" } {
1010
1011 gdb_expect {
d0b76dc6 1012 -re "\\*stopped,reason=\"exited-normally\"\r\n$prompt_re" {
bb378428
VP
1013 pass "$test"
1014 }
1015 -re ".*$mi_gdb_prompt$" {fail "continue to end (2)"}
1016 timeout {
1017 fail "$test (unknown output after running)"
1018 }
1019 }
1020 return
1021 }
1022
1023 set args "\\\[$args\\\]"
1024
1025 set bn ""
1026 if { $reason == "breakpoint-hit" } {
1027 set bn {bkptno="[0-9]+",}
1028 }
1029
1030 set r ""
1031 if { $reason != "" } {
1032 set r "reason=\"$reason\","
1033 }
1034
18ac113b
AR
1035
1036 set a $after_reason
1037
d0b76dc6
DJ
1038 set any "\[^\n\]*"
1039
1d33d6ba 1040 verbose -log "mi_expect_stop: expecting: \\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\"$any$file\",fullname=\"${fullname_syntax}$file\",line=\"$line\"\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thread_selected_re)?$prompt_re"
dcf95b47 1041 gdb_expect {
1d33d6ba 1042 -re "\\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\"$any$file\",fullname=\"${fullname_syntax}$file\",line=\"($line)\"\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thread_selected_re)?$prompt_re" {
dcf95b47 1043 pass "$test"
bb378428 1044 return $expect_out(2,string)
dcf95b47 1045 }
8997583e 1046 -re "\\*stopped,${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$any\",args=\[\\\[\{\]$any\[\\\]\}\],file=\"$any\",fullname=\"${fullname_syntax}$any\",line=\"\[0-9\]*\"\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n$prompt_re" {
8cf6e61a 1047 verbose -log "got $expect_out(buffer)"
dcf95b47
DJ
1048 fail "$test (stopped at wrong place)"
1049 return -1
1050 }
f7f9a841 1051 -re ".*\r\n$mi_gdb_prompt$" {
8cf6e61a 1052 verbose -log "got $expect_out(buffer)"
dcf95b47
DJ
1053 fail "$test (unknown output after running)"
1054 return -1
1055 }
dcf95b47
DJ
1056 timeout {
1057 fail "$test (timeout)"
1058 return -1
1059 }
bb378428 1060 }
dcf95b47
DJ
1061}
1062
1ad15515
PA
1063# Wait for MI *stopped notification related to an interrupt request to
1064# appear.
1065proc mi_expect_interrupt { test } {
1066 global mi_gdb_prompt
1067 global decimal
1068 global async
1069
1070 if {$async} {
1071 set prompt_re ""
1072 } else {
1073 set prompt_re "$mi_gdb_prompt$"
1074 }
1075
252fbfc8 1076 set r "reason=\"signal-received\",signal-name=\"0\",signal-meaning=\"Signal 0\""
1ad15515
PA
1077
1078 set any "\[^\n\]*"
1079
1080 # A signal can land anywhere, just ignore the location
1d33d6ba 1081 verbose -log "mi_expect_interrupt: expecting: \\*stopped,${r}$any\r\n$prompt_re"
1ad15515 1082 gdb_expect {
1d33d6ba 1083 -re "\\*stopped,${r}$any\r\n$prompt_re" {
1ad15515
PA
1084 pass "$test"
1085 return 0;
1086 }
1087 -re ".*\r\n$mi_gdb_prompt$" {
1088 verbose -log "got $expect_out(buffer)"
1089 fail "$test (unknown output after running)"
1090 return -1
1091 }
1092 timeout {
1093 fail "$test (timeout)"
1094 return -1
1095 }
1096 }
1097}
1098
bb378428
VP
1099# cmd should not include the number or newline (i.e. "exec-step 3", not
1100# "220-exec-step 3\n"
1101
1102# Can not match -re ".*\r\n${mi_gdb_prompt}", because of false positives
1103# after the first prompt is printed.
1104
08b468e0 1105proc mi_execute_to { cmd reason func args file line extra test } {
bb378428
VP
1106 global suppress_flag
1107 if { $suppress_flag } {
1108 return -1
1109 }
1110
1111 mi_send_resuming_command "$cmd" "$test"
1112 set r [mi_expect_stop $reason $func $args $file $line $extra $test]
1113 return $r
dcf95b47
DJ
1114}
1115
1116proc mi_next_to { func args file line test } {
08b468e0 1117 mi_execute_to "exec-next" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
1118 "$file" "$line" "" "$test"
1119}
1120
1121proc mi_step_to { func args file line test } {
08b468e0 1122 mi_execute_to "exec-step" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
1123 "$file" "$line" "" "$test"
1124}
1125
1126proc mi_finish_to { func args file line result ret test } {
08b468e0 1127 mi_execute_to "exec-finish" "function-finished" "$func" "$args" \
dcf95b47
DJ
1128 "$file" "$line" \
1129 ",gdb-result-var=\"$result\",return-value=\"$ret\"" \
1130 "$test"
1131}
1132
f7e97bb3
VP
1133proc mi_continue_to {func} {
1134 mi_runto_helper $func "continue"
dcf95b47
DJ
1135}
1136
08b468e0
KS
1137proc mi0_execute_to { cmd reason func args file line extra test } {
1138 mi_execute_to_helper "$cmd" "$reason" "$func" "\{$args\}" \
dcf95b47
DJ
1139 "$file" "$line" "$extra" "$test"
1140}
1141
1142proc mi0_next_to { func args file line test } {
08b468e0 1143 mi0_execute_to "exec-next" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
1144 "$file" "$line" "" "$test"
1145}
1146
1147proc mi0_step_to { func args file line test } {
08b468e0 1148 mi0_execute_to "exec-step" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
1149 "$file" "$line" "" "$test"
1150}
1151
1152proc mi0_finish_to { func args file line result ret test } {
08b468e0 1153 mi0_execute_to "exec-finish" "function-finished" "$func" "$args" \
dcf95b47
DJ
1154 "$file" "$line" \
1155 ",gdb-result-var=\"$result\",return-value=\"$ret\"" \
1156 "$test"
1157}
1158
1159proc mi0_continue_to { bkptno func args file line test } {
08b468e0 1160 mi0_execute_to "exec-continue" "breakpoint-hit\",bkptno=\"$bkptno" \
dcf95b47
DJ
1161 "$func" "$args" "$file" "$line" "" "$test"
1162}
b26ed50d 1163
d24317b4
VP
1164# Creates a breakpoint and checks the reported fields are as expected
1165proc mi_create_breakpoint { location number disp func file line address test } {
1166 verbose -log "Expecting: 222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",line=\"$line\",times=\"0\",original-location=\".*\"\}"
1167 mi_gdb_test "222-break-insert $location" \
1168 "222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",line=\"$line\",times=\"0\",original-location=\".*\"\}" \
1169 $test
1170}
1171
1172proc mi_list_breakpoints { expected test } {
1173 set fullname ".*"
1174
1175 set body ""
1176 set first 1
1177
48cb2d85 1178 foreach item $expected {
d24317b4
VP
1179 if {$first == 0} {
1180 set body "$body,"
48cb2d85 1181 set first 0
d24317b4 1182 }
d24317b4
VP
1183 set number [lindex $item 0]
1184 set disp [lindex $item 1]
1185 set func [lindex $item 2]
48cb2d85
VP
1186 set file [lindex $item 3]
1187 set line [lindex $item 4]
1188 set address [lindex $item 5]
1189 set body "${body}bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\".*$file\",${fullname},line=\"$line\",times=\"0\",original-location=\".*\"\}"
d24317b4
VP
1190 set first 0
1191 }
1192
48cb2d85 1193 verbose -log "Expecting: 666\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[$body\\\]\}"
d24317b4
VP
1194 mi_gdb_test "666-break-list" \
1195 "666\\\^done,BreakpointTable=\{nr_rows=\".\",nr_cols=\".\",hdr=\\\[\{width=\".*\",alignment=\".*\",col_name=\"number\",colhdr=\"Num\"\}.*colhdr=\"Type\".*colhdr=\"Disp\".*colhdr=\"Enb\".*colhdr=\"Address\".*colhdr=\"What\".*\\\],body=\\\[$body\\\]\}" \
1196 $test
1197}
1198
b26ed50d
VP
1199# Creates varobj named NAME for EXPRESSION.
1200# Name cannot be "-".
1201proc mi_create_varobj { name expression testname } {
1202 mi_gdb_test "-var-create $name * $expression" \
0cc7d26f 1203 "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=.*,has_more=\"0\"" \
b26ed50d
VP
1204 $testname
1205}
1206
fcacd99f
VP
1207proc mi_create_floating_varobj { name expression testname } {
1208 mi_gdb_test "-var-create $name @ $expression" \
0cc7d26f 1209 "\\^done,name=\"$name\",numchild=\"\(-1\|\[0-9\]+\)\",value=\".*\",type=.*" \
fcacd99f
VP
1210 $testname
1211}
1212
1213
9e8e3afe
VP
1214# Same as mi_create_varobj, but also checks the reported type
1215# of the varobj.
1216proc mi_create_varobj_checked { name expression type testname } {
1217 mi_gdb_test "-var-create $name * $expression" \
1218 "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=\"$type\".*" \
1219 $testname
1220}
1221
0cc7d26f
TT
1222# Same as mi_create_floating_varobj, but assumes the test is creating
1223# a dynamic varobj that has children, so the value must be "{...}".
1224proc mi_create_dynamic_varobj {name expression testname} {
1225 mi_gdb_test "-var-create $name @ $expression" \
1226 "\\^done,name=\"$name\",numchild=\"\(-1\|\[0-9\]+\)\",value=\"{\\.\\.\\.}\",type=.*" \
1227 $testname
1228}
1229
6e2a9270
VP
1230# Deletes the specified NAME.
1231proc mi_delete_varobj { name testname } {
1232 mi_gdb_test "-var-delete $name" \
1233 "\\^done,ndeleted=.*" \
1234 $testname
1235}
1236
b26ed50d
VP
1237# Updates varobj named NAME and checks that all varobjs in EXPECTED
1238# are reported as updated, and no other varobj is updated.
1239# Assumes that no varobj is out of scope and that no varobj changes
1240# types.
1241proc mi_varobj_update { name expected testname } {
1242 set er "\\^done,changelist=\\\["
1243 set first 1
1244 foreach item $expected {
0cc7d26f 1245 set v "{name=\"$item\",in_scope=\"true\",type_changed=\"false\",has_more=\".\"}"
25d5ea92 1246 if {$first == 1} {
b26ed50d 1247 set er "$er$v"
25d5ea92 1248 set first 0
b26ed50d
VP
1249 } else {
1250 set er "$er,$v"
1251 }
1252 }
1253 set er "$er\\\]"
1254
1255 verbose -log "Expecting: $er" 2
1256 mi_gdb_test "-var-update $name" $er $testname
1257}
1258
fcacd99f 1259proc mi_varobj_update_with_type_change { name new_type new_children testname } {
0cc7d26f 1260 set v "{name=\"$name\",in_scope=\"true\",type_changed=\"true\",new_type=\"$new_type\",new_num_children=\"$new_children\",has_more=\".\"}"
fcacd99f
VP
1261 set er "\\^done,changelist=\\\[$v\\\]"
1262 verbose -log "Expecting: $er"
1263 mi_gdb_test "-var-update $name" $er $testname
1264}
1265
0cc7d26f
TT
1266# A helper that turns a key/value list into a regular expression
1267# matching some MI output.
1268proc mi_varobj_update_kv_helper {list} {
1269 set first 1
1270 set rx ""
1271 foreach {key value} $list {
1272 if {!$first} {
1273 append rx ,
1274 }
1275 set first 0
1276 if {$key == "new_children"} {
1277 append rx "$key=\\\[$value\\\]"
1278 } else {
1279 append rx "$key=\"$value\""
1280 }
1281 }
1282 return $rx
1283}
b6313243 1284
0cc7d26f
TT
1285# A helper for mi_varobj_update_dynamic that computes a match
1286# expression given a child list.
1287proc mi_varobj_update_dynamic_helper {children} {
1288 set crx ""
b6313243 1289
0cc7d26f
TT
1290 set first 1
1291 foreach child $children {
1292 if {!$first} {
1293 append crx ,
1294 }
1295 set first 0
1296 append crx "{"
1297 append crx [mi_varobj_update_kv_helper $child]
1298 append crx "}"
1299 }
1300
1301 return $crx
1302}
1303
1304# Update a dynamic varobj named NAME. CHILDREN is a list of children
1305# that have been updated; NEW_CHILDREN is a list of children that were
1306# added to the primary varobj. Each child is a list of key/value
1307# pairs that are expected. SELF is a key/value list holding
1308# information about the varobj itself. TESTNAME is the name of the
1309# test.
1310proc mi_varobj_update_dynamic {name testname self children new_children} {
1311 if {[llength $new_children]} {
1312 set newrx [mi_varobj_update_dynamic_helper $new_children]
1313 lappend self new_children $newrx
1314 }
1315 set selfrx [mi_varobj_update_kv_helper $self]
1316 set crx [mi_varobj_update_dynamic_helper $children]
1317
1318 set er "\\^done,changelist=\\\[\{name=\"$name\",in_scope=\"true\""
1319 append er ",$selfrx\}"
1320 if {"$crx" != ""} {
1321 append er ",$crx"
1322 }
1323 append er "\\\]"
b6313243
TT
1324
1325 verbose -log "Expecting: $er"
1326 mi_gdb_test "-var-update $name" $er $testname
1327}
1328
b26ed50d
VP
1329proc mi_check_varobj_value { name value testname } {
1330
1331 mi_gdb_test "-var-evaluate-expression $name" \
1332 "\\^done,value=\"$value\"" \
1333 $testname
1334}
038224f6 1335
b6313243
TT
1336# Helper proc which constructs a child regexp for
1337# mi_list_varobj_children and mi_varobj_update_dynamic.
1338proc mi_child_regexp {children add_child} {
1339 set children_exp {}
1340 set whatever "\"\[^\"\]+\""
1341
1342 if {$add_child} {
1343 set pre "child="
1344 } else {
1345 set pre ""
1346 }
1347
1348 foreach item $children {
1349
1350 set name [lindex $item 0]
1351 set exp [lindex $item 1]
1352 set numchild [lindex $item 2]
1353 if {[llength $item] == 5} {
1354 set type [lindex $item 3]
1355 set value [lindex $item 4]
1356
1357 lappend children_exp\
1358 "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",value=\"$value\",type=\"$type\"\(,thread-id=\"\[0-9\]+\")?}"
1359 } elseif {[llength $item] == 4} {
1360 set type [lindex $item 3]
1361
1362 lappend children_exp\
1363 "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",type=\"$type\"\(,thread-id=\"\[0-9\]+\")?}"
1364 } else {
1365 lappend children_exp\
1366 "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\"(,thread-id=\"\[0-9\]+\")?}"
1367 }
1368 }
1369 return [join $children_exp ","]
1370}
1371
038224f6
VP
1372# Check the results of the:
1373#
1374# -var-list-children VARNAME
1375#
1376# command. The CHILDREN parement should be a list of lists.
1377# Each inner list can have either 3 or 4 elements, describing
1378# fields that gdb is expected to report for child variable object,
1379# in the following order
1380#
1381# - Name
1382# - Expression
1383# - Number of children
1384# - Type
1385#
1386# If inner list has 3 elements, the gdb is expected to output no
9e8e3afe
VP
1387# type for a child and no value.
1388#
1389# If the inner list has 4 elements, gdb output is expected to
1390# have no value.
038224f6
VP
1391#
1392proc mi_list_varobj_children { varname children testname } {
0cc7d26f 1393 mi_list_varobj_children_range $varname "" "" [llength $children] $children \
b6313243
TT
1394 $testname
1395}
038224f6 1396
0cc7d26f
TT
1397# Like mi_list_varobj_children, but sets a subrange. NUMCHILDREN is
1398# the total number of children.
1399proc mi_list_varobj_children_range {varname from to numchildren children testname} {
9e8e3afe
VP
1400 set options ""
1401 if {[llength $varname] == 2} {
1402 set options [lindex $varname 1]
1403 set varname [lindex $varname 0]
1404 }
1405
038224f6
VP
1406 set whatever "\"\[^\"\]+\""
1407
b6313243 1408 set children_exp_j [mi_child_regexp $children 1]
9e8e3afe
VP
1409 if {$numchildren} {
1410 set expected "\\^done,numchild=\".*\",children=\\\[$children_exp_j.*\\\]"
1411 } {
1412 set expected "\\^done,numchild=\"0\""
1413 }
038224f6 1414
0cc7d26f
TT
1415 if {"$to" == ""} {
1416 append expected ",has_more=\"0\""
1417 } elseif {$to >= 0 && $numchildren > $to} {
1418 append expected ",has_more=\"1\""
1419 } else {
1420 append expected ",has_more=\"0\""
1421 }
1422
038224f6
VP
1423 verbose -log "Expecting: $expected"
1424
0cc7d26f
TT
1425 mi_gdb_test "-var-list-children $options $varname $from $to" \
1426 $expected $testname
9e8e3afe
VP
1427}
1428
1429# Verifies that variable object VARNAME has NUMBER children,
1430# where each one is named $VARNAME.<index-of-child> and has type TYPE.
1431proc mi_list_array_varobj_children { varname number type testname } {
1432 set t {}
1433 for {set i 0} {$i < $number} {incr i} {
1434 lappend t [list $varname.$i $i 0 $type]
1435 }
1436 mi_list_varobj_children $varname $t $testname
038224f6 1437}
2d0720d9
VP
1438
1439# A list of two-element lists. First element of each list is
1440# a Tcl statement, and the second element is the line
1441# number of source C file where the statement originates.
1442set mi_autotest_data ""
1443# The name of the source file for autotesting.
1444set mi_autotest_source ""
1445
1446proc count_newlines { string } {
1447 return [regexp -all "\n" $string]
1448}
1449
1450# Prepares for running inline tests in FILENAME.
1451# See comments for mi_run_inline_test for detailed
1452# explanation of the idea and syntax.
1453proc mi_prepare_inline_tests { filename } {
1454
1455 global srcdir
1456 global subdir
1457 global mi_autotest_source
1458 global mi_autotest_data
1459
1460 set mi_autotest_data {}
1461
1462 set mi_autotest_source $filename
1463
1464 if { ! [regexp "^/" "$filename"] } then {
1465 set filename "$srcdir/$subdir/$filename"
1466 }
1467
1468 set chan [open $filename]
1469 set content [read $chan]
1470 set line_number 1
1471 while {1} {
1472 set start [string first "/*:" $content]
1473 if {$start != -1} {
1474 set end [string first ":*/" $content]
1475 if {$end == -1} {
1476 error "Unterminated special comment in $filename"
1477 }
1478
1479 set prefix [string range $content 0 $start]
1480 set prefix_newlines [count_newlines $prefix]
1481
1482 set line_number [expr $line_number+$prefix_newlines]
1483 set comment_line $line_number
1484
1485 set comment [string range $content [expr $start+3] [expr $end-1]]
1486
1487 set comment_newlines [count_newlines $comment]
1488 set line_number [expr $line_number+$comment_newlines]
1489
1490 set comment [string trim $comment]
1491 set content [string range $content [expr $end+3] \
1492 [string length $content]]
1493 lappend mi_autotest_data [list $comment $comment_line]
1494 } else {
1495 break
1496 }
1497 }
1498 close $chan
1499}
1500
1501# Helper to mi_run_inline_test below.
1502# Return the list of all (statement,line_number) lists
1503# that comprise TESTCASE. The begin and end markers
1504# are not included.
1505proc mi_get_inline_test {testcase} {
1506
1507 global mi_gdb_prompt
1508 global mi_autotest_data
1509 global mi_autotest_source
1510
1511 set result {}
1512
1513 set seen_begin 0
1514 set seen_end 0
1515 foreach l $mi_autotest_data {
1516
1517 set comment [lindex $l 0]
1518
1519 if {$comment == "BEGIN: $testcase"} {
1520 set seen_begin 1
1521 } elseif {$comment == "END: $testcase"} {
1522 set seen_end 1
1523 break
1524 } elseif {$seen_begin==1} {
1525 lappend result $l
1526 }
1527 }
1528
1529 if {$seen_begin == 0} {
1530 error "Autotest $testcase not found"
1531 }
1532
1533 if {$seen_begin == 1 && $seen_end == 0} {
1534 error "Missing end marker for test $testcase"
1535 }
1536
1537 return $result
1538}
1539
1540# Sets temporary breakpoint at LOCATION.
1541proc mi_tbreak {location} {
1542
1543 global mi_gdb_prompt
1544
1545 mi_gdb_test "-break-insert -t $location" \
1546 {\^done,bkpt=.*} \
1547 "run to $location (set breakpoint)"
1548}
1549
1550# Send COMMAND that must be a command that resumes
1551# the inferiour (run/continue/next/etc) and consumes
1552# the "^running" output from it.
a2840c35 1553proc mi_send_resuming_command_raw {command test} {
2d0720d9
VP
1554
1555 global mi_gdb_prompt
66bb093b 1556 global thread_selected_re
c86cf029 1557 global library_loaded_re
2d0720d9 1558
a2840c35 1559 send_gdb "$command\n"
2d0720d9 1560 gdb_expect {
c86cf029 1561 -re "\\^running\r\n\\*running,thread-id=\"\[^\"\]+\"\r\n($library_loaded_re)*($thread_selected_re)?${mi_gdb_prompt}" {
7ebd49dc
VP
1562 # Note that lack of 'pass' call here -- this works around limitation
1563 # in DejaGNU xfail mechanism. mi-until.exp has this:
1564 #
1565 # setup_kfail gdb/2104 "*-*-*"
1566 # mi_execute_to ...
1567 #
1568 # and mi_execute_to uses mi_send_resuming_command. If we use 'pass' here,
1569 # it will reset kfail, so when the actual test fails, it will be flagged
1570 # as real failure.
d0b76dc6 1571 return 0
2d0720d9 1572 }
4ea95be9
DJ
1573 -re "\\^error,msg=\"Displaced stepping is only supported in ARM mode\".*" {
1574 unsupported "$test (Thumb mode)"
1575 return -1
bb378428 1576 }
a2840c35 1577 -re "\\^error,msg=.*" {
bb378428
VP
1578 fail "$test (MI error)"
1579 return -1
1580 }
4ea95be9
DJ
1581 -re ".*${mi_gdb_prompt}" {
1582 fail "$test (failed to resume)"
1583 return -1
1584 }
2d0720d9 1585 timeout {
bb378428
VP
1586 fail "$test"
1587 return -1
2d0720d9
VP
1588 }
1589 }
1590}
1591
a2840c35
VP
1592proc mi_send_resuming_command {command test} {
1593 mi_send_resuming_command_raw -$command $test
1594}
1595
2d0720d9
VP
1596# Helper to mi_run_inline_test below.
1597# Sets a temporary breakpoint at LOCATION and runs
1598# the program using COMMAND. When the program is stopped
1599# returns the line at which it. Returns -1 if line cannot
1600# be determined.
1601# Does not check that the line is the same as requested.
1602# The caller can check itself if required.
a73bafbc 1603proc mi_continue_to_line {location test} {
2d0720d9
VP
1604
1605 mi_tbreak $location
1606 mi_send_resuming_command "exec-continue" "run to $location (exec-continue)"
bb378428 1607 return [mi_get_stop_line $test]
2d0720d9
VP
1608}
1609
1610# Wait until gdb prints the current line.
bb378428 1611proc mi_get_stop_line {test} {
2d0720d9
VP
1612
1613 global mi_gdb_prompt
f7f9a841
VP
1614 global async
1615
1616 if {$async} {
1617 set prompt_re ""
1618 } else {
d0b76dc6 1619 set prompt_re "$mi_gdb_prompt$"
f7f9a841 1620 }
2d0720d9
VP
1621
1622 gdb_expect {
d0b76dc6 1623 -re ".*line=\"(\[0-9\]*)\".*\r\n$prompt_re" {
2d0720d9
VP
1624 return $expect_out(1,string)
1625 }
d0b76dc6 1626 -re ".*$mi_gdb_prompt" {
2d0720d9
VP
1627 fail "wait for stop ($test)"
1628 }
1629 timeout {
1630 fail "wait for stop ($test)"
1631 }
1632 }
1633}
1634
1635# Run a MI test embedded in comments in a C file.
1636# The C file should contain special comments in the following
1637# three forms:
1638#
1639# /*: BEGIN: testname :*/
1640# /*: <Tcl statements> :*/
1641# /*: END: testname :*/
1642#
1643# This procedure find the begin and end marker for the requested
1644# test. Then, a temporary breakpoint is set at the begin
1645# marker and the program is run (from start).
1646#
1647# After that, for each special comment between the begin and end
1648# marker, the Tcl statements are executed. It is assumed that
1649# for each comment, the immediately preceding line is executable
1650# C statement. Then, gdb will be single-stepped until that
1651# preceding C statement is executed, and after that the
1652# Tcl statements in the comment will be executed.
1653#
1654# For example:
1655#
1656# /*: BEGIN: assignment-test :*/
1657# v = 10;
1658# /*: <Tcl code to check that 'v' is indeed 10 :*/
1659# /*: END: assignment-test :*/
1660#
1661# The mi_prepare_inline_tests function should be called before
1662# calling this function. A given C file can contain several
1663# inline tests. The names of the tests must be unique within one
1664# C file.
1665#
1666proc mi_run_inline_test { testcase } {
1667
1668 global mi_gdb_prompt
1669 global hex
1670 global decimal
1671 global fullname_syntax
1672 global mi_autotest_source
1673
1674 set commands [mi_get_inline_test $testcase]
1675
1676 set first 1
1677 set line_now 1
1678
1679 foreach c $commands {
1680 set statements [lindex $c 0]
1681 set line [lindex $c 1]
1682 set line [expr $line-1]
1683
1684 # We want gdb to be stopped at the expression immediately
1685 # before the comment. If this is the first comment, the
1686 # program is either not started yet or is in some random place,
1687 # so we run it. For further comments, we might be already
1688 # standing at the right line. If not continue till the
1689 # right line.
1690
1691 if {$first==1} {
1692 # Start the program afresh.
1693 mi_tbreak "$mi_autotest_source:$line"
1694 mi_run_cmd
bb378428 1695 set line_now [mi_get_stop_line "$testcase: step to $line"]
2d0720d9
VP
1696 set first 0
1697 } elseif {$line_now!=$line} {
25d5ea92 1698 set line_now [mi_continue_to_line "$mi_autotest_source:$line" "continue to $line"]
2d0720d9
VP
1699 }
1700
1701 if {$line_now!=$line} {
1702 fail "$testcase: go to line $line"
1703 }
1704
1705 # We're not at the statement right above the comment.
1706 # Execute that statement so that the comment can test
1707 # the state after the statement is executed.
1708
1709 # Single-step past the line.
d0b76dc6
DJ
1710 if { [mi_send_resuming_command "exec-next" "$testcase: step over $line"] != 0 } {
1711 return -1
1712 }
1713 set line_now [mi_get_stop_line "$testcase: step over $line"]
2d0720d9
VP
1714
1715 # We probably want to use 'uplevel' so that statements
1716 # have direct access to global variables that the
1717 # main 'exp' file has set up. But it's not yet clear,
1718 # will need more experience to be sure.
1719 eval $statements
1720 }
1721}
9d81d21b
VP
1722
1723proc get_mi_thread_list {name} {
1724 global expect_out
1725
1726 # MI will return a list of thread ids:
1727 #
1728 # -thread-list-ids
1729 # ^done,thread-ids=[thread-id="1",thread-id="2",...],number-of-threads="N"
1730 # (gdb)
1731 mi_gdb_test "-thread-list-ids" \
592375cd 1732 {.*\^done,thread-ids={(thread-id="[0-9]+"(,)?)+},current-thread-id="[0-9]+",number-of-threads="[0-9]+"} \
9d81d21b
VP
1733 "-thread_list_ids ($name)"
1734
1735 set output {}
1736 if {[info exists expect_out(buffer)]} {
1737 set output $expect_out(buffer)
1738 }
1739
1740 set thread_list {}
1741 if {![regexp {thread-ids=\{(thread-id="[0-9]+"(,)?)*\}} $output threads]} {
1742 fail "finding threads in MI output ($name)"
1743 } else {
1744 pass "finding threads in MI output ($name)"
1745
1746 # Make list of console threads
1747 set start [expr {[string first \{ $threads] + 1}]
1748 set end [expr {[string first \} $threads] - 1}]
1749 set threads [string range $threads $start $end]
1750 foreach thread [split $threads ,] {
1751 if {[scan $thread {thread-id="%d"} num]} {
1752 lappend thread_list $num
1753 }
1754 }
1755 }
1756
1757 return $thread_list
1758}
1759
1760# Check that MI and the console know of the same threads.
1761# Appends NAME to all test names.
1762proc check_mi_and_console_threads {name} {
1763 global expect_out
1764
1765 mi_gdb_test "-thread-list-ids" \
592375cd 1766 {.*\^done,thread-ids={(thread-id="[0-9]+"(,)*)+},current-thread-id="[0-9]+",number-of-threads="[0-9]+"} \
9d81d21b
VP
1767 "-thread-list-ids ($name)"
1768 set mi_output {}
1769 if {[info exists expect_out(buffer)]} {
1770 set mi_output $expect_out(buffer)
1771 }
1772
1773 # GDB will return a list of thread ids and some more info:
1774 #
1775 # (gdb)
1776 # -interpreter-exec console "info threads"
1777 # ~" 4 Thread 2051 (LWP 7734) 0x401166b1 in __libc_nanosleep () at __libc_nanosleep:-1"
1778 # ~" 3 Thread 1026 (LWP 7733) () at __libc_nanosleep:-1"
1779 # ~" 2 Thread 2049 (LWP 7732) 0x401411f8 in __poll (fds=0x804bb24, nfds=1, timeout=2000) at ../sysdeps/unix/sysv/linux/poll.c:63"
1780 # ~"* 1 Thread 1024 (LWP 7731) main (argc=1, argv=0xbfffdd94) at ../../../src/gdb/testsuite/gdb.mi/pthreads.c:160"
1781 # FIXME: kseitz/2002-09-05: Don't use the hack-cli method.
1782 mi_gdb_test "info threads" \
1783 {.*(~".*"[\r\n]*)+.*} \
1784 "info threads ($name)"
1785 set console_output {}
1786 if {[info exists expect_out(buffer)]} {
1787 set console_output $expect_out(buffer)
1788 }
1789
1790 # Make a list of all known threads to console (gdb's thread IDs)
1791 set console_thread_list {}
1792 foreach line [split $console_output \n] {
1793 if {[string index $line 0] == "~"} {
1794 # This is a line from the console; trim off "~", " ", "*", and "\""
1795 set line [string trim $line ~\ \"\*]
1796 if {[scan $line "%d" id] == 1} {
1797 lappend console_thread_list $id
1798 }
1799 }
1800 }
1801
1802 # Now find the result string from MI
1803 set mi_result ""
1804 foreach line [split $mi_output \n] {
1805 if {[string range $line 0 4] == "^done"} {
1806 set mi_result $line
1807 }
1808 }
1809 if {$mi_result == ""} {
1810 fail "finding MI result string ($name)"
1811 } else {
1812 pass "finding MI result string ($name)"
1813 }
1814
1815 # Finally, extract the thread ids and compare them to the console
1816 set num_mi_threads_str ""
1817 if {![regexp {number-of-threads="[0-9]+"} $mi_result num_mi_threads_str]} {
1818 fail "finding number of threads in MI output ($name)"
1819 } else {
1820 pass "finding number of threads in MI output ($name)"
1821
1822 # Extract the number of threads from the MI result
1823 if {![scan $num_mi_threads_str {number-of-threads="%d"} num_mi_threads]} {
1824 fail "got number of threads from MI ($name)"
1825 } else {
1826 pass "got number of threads from MI ($name)"
1827
1828 # Check if MI and console have same number of threads
1829 if {$num_mi_threads != [llength $console_thread_list]} {
1830 fail "console and MI have same number of threads ($name)"
1831 } else {
1832 pass "console and MI have same number of threads ($name)"
1833
1834 # Get MI thread list
1835 set mi_thread_list [get_mi_thread_list $name]
1836
1837 # Check if MI and console have the same threads
1838 set fails 0
1839 foreach ct [lsort $console_thread_list] mt [lsort $mi_thread_list] {
1840 if {$ct != $mt} {
1841 incr fails
1842 }
1843 }
1844 if {$fails > 0} {
1845 fail "MI and console have same threads ($name)"
1846
1847 # Send a list of failures to the log
1848 send_log "Console has thread ids: $console_thread_list\n"
1849 send_log "MI has thread ids: $mi_thread_list\n"
1850 } else {
1851 pass "MI and console have same threads ($name)"
1852 }
1853 }
1854 }
1855 }
1856}
5e06a3d1 1857
759f0f0b 1858# Download shared libraries to the target.
5e06a3d1
VP
1859proc mi_load_shlibs { args } {
1860 if {![is_remote target]} {
1861 return
1862 }
1863
1864 foreach file $args {
759f0f0b 1865 gdb_download [shlib_target_file $file]
5e06a3d1
VP
1866 }
1867
1868 # Even if the target supplies full paths for shared libraries,
1869 # they may not be paths for this system.
1870 mi_gdb_test "set solib-search-path [file dirname [lindex $args 0]]" "\^done" ""
1871}
1872
1ad15515
PA
1873proc mi_reverse_list { list } {
1874 if { [llength $list] <= 1 } {
1875 return $list
1876 }
1877 set tail [lrange $list 1 [llength $list]]
1878 set rtail [mi_reverse_list $tail]
1879 lappend rtail [lindex $list 0]
1880 return $rtail
1881}
1882
1883proc mi_check_thread_states { xstates test } {
1884 global expect_out
1885 set states [mi_reverse_list $xstates]
f4e164aa 1886 set pattern ".*\\^done,threads=\\\["
1ad15515
PA
1887 foreach s $states {
1888 set pattern "${pattern}(.*)state=\"$s\""
1889 }
dc146f7c 1890 set pattern "${pattern}(,core=\"\[0-9\]*\")?\\\}\\\].*"
1ad15515
PA
1891
1892 verbose -log "expecting: $pattern"
1893 mi_gdb_test "-thread-info" $pattern $test
1894}
b6313243
TT
1895
1896# Return a list of MI features supported by this gdb.
1897proc mi_get_features {} {
1898 global expect_out mi_gdb_prompt
1899
1900 send_gdb "-list-features\n"
1901
1902 gdb_expect {
1903 -re "\\^done,features=\\\[(.*)\\\]\r\n$mi_gdb_prompt$" {
1904 regsub -all -- \" $expect_out(1,string) "" features
1905 return [split $features ,]
1906 }
1907 -re ".*\r\n$mi_gdb_prompt$" {
1908 verbose -log "got $expect_out(buffer)"
1909 return ""
1910 }
1911 timeout {
1912 verbose -log "timeout in mi_gdb_prompt"
1913 return ""
1914 }
1915 }
1916}
This page took 1.097462 seconds and 4 git commands to generate.