2002-11-08 Jeff Johnston <jjohnstn@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / mi-support.exp
CommitLineData
7ddebc7e 1# Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
fb40c209
AC
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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was based on a file written by Fred Fish. (fnf@cygnus.com)
21
22# Test setup routines that work with the MI interpreter.
23
24# The variable mi_gdb_prompt is a regexp which matches the gdb mi prompt.
25# Set it if it is not already set.
26global mi_gdb_prompt
27if ![info exists mi_gdb_prompt] then {
28 set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
29}
30
31set MIFLAGS "-i=mi"
32
33#
34# mi_gdb_exit -- exit the GDB, killing the target program if necessary
35#
36proc mi_gdb_exit {} {
37 catch mi_uncatched_gdb_exit
38}
39
40proc mi_uncatched_gdb_exit {} {
41 global GDB
42 global GDBFLAGS
43 global verbose
44 global gdb_spawn_id;
45 global gdb_prompt
46 global mi_gdb_prompt
47 global MIFLAGS
48
49 gdb_stop_suppressing_tests;
50
51 if { [info procs sid_exit] != "" } {
52 sid_exit
53 }
54
55 if ![info exists gdb_spawn_id] {
56 return;
57 }
58
59 verbose "Quitting $GDB $GDBFLAGS $MIFLAGS"
60
61 if { [is_remote host] && [board_info host exists fileid] } {
62 send_gdb "999-gdb-exit\n";
63 gdb_expect 10 {
64 -re "y or n" {
65 send_gdb "y\n";
66 exp_continue;
67 }
68 -re "Undefined command.*$gdb_prompt $" {
69 send_gdb "quit\n"
70 exp_continue;
71 }
72 -re "DOSEXIT code" { }
73 default { }
74 }
75 }
76
77 if ![is_remote host] {
78 remote_close host;
79 }
80 unset gdb_spawn_id
81}
82
83#
84# start gdb -- start gdb running, default procedure
85#
86# When running over NFS, particularly if running many simultaneous
87# tests on different hosts all using the same server, things can
88# get really slow. Give gdb at least 3 minutes to start up.
89#
90proc mi_gdb_start { } {
91 global verbose
92 global GDB
93 global GDBFLAGS
94 global gdb_prompt
95 global mi_gdb_prompt
96 global timeout
97 global gdb_spawn_id;
98 global MIFLAGS
99
100 gdb_stop_suppressing_tests;
101
1759b3c3
AC
102 # Start SID.
103 if { [info procs sid_start] != "" } {
104 verbose "Spawning SID"
105 sid_start
106 }
107
fb40c209
AC
108 verbose "Spawning $GDB -nw $GDBFLAGS $MIFLAGS"
109
110 if [info exists gdb_spawn_id] {
111 return 0;
112 }
113
114 if ![is_remote host] {
115 if { [which $GDB] == 0 } then {
116 perror "$GDB does not exist."
117 exit 1
118 }
119 }
120 set res [remote_spawn host "$GDB -nw $GDBFLAGS $MIFLAGS [host_info gdb_opts]"];
121 if { $res < 0 || $res == "" } {
122 perror "Spawning $GDB failed."
123 return 1;
124 }
125 gdb_expect {
1f312e79
JJ
126 -re "~\"GNU.*\r\n~\".*$mi_gdb_prompt$" {
127 # We have a new format mi startup prompt. If we are
128 # running mi1, then this is an error as we should be
129 # using the old-style prompt.
130 if { $MIFLAGS == "-i=mi1" } {
131 perror "(mi startup) Got unexpected new mi prompt."
132 remote_close host;
133 return -1;
134 }
135 verbose "GDB initialized."
136 }
137 -re "\[^~\].*$mi_gdb_prompt$" {
138 # We have an old format mi startup prompt. If we are
139 # not running mi1, then this is an error as we should be
140 # using the new-style prompt.
141 if { $MIFLAGS != "-i=mi1" } {
142 perror "(mi startup) Got unexpected old mi prompt."
143 remote_close host;
144 return -1;
145 }
d20bf2e8 146 verbose "GDB initialized."
fb40c209
AC
147 }
148 -re ".*$gdb_prompt $" {
149 untested "Skip mi tests (got non-mi prompt)."
150 remote_close host;
151 return -1;
152 }
76c520e0
AC
153 -re ".*unrecognized option.*for a complete list of options." {
154 untested "Skip mi tests (not compiled with mi support)."
155 remote_close host;
156 return -1;
157 }
7d76bd60
MK
158 -re ".*Interpreter `mi' unrecognized." {
159 untested "Skip mi tests (not compiled with mi support)."
160 remote_close host;
161 return -1;
162 }
fb40c209
AC
163 timeout {
164 perror "(timeout) GDB never initialized after 10 seconds."
165 remote_close host;
166 return -1
167 }
168 }
169 set gdb_spawn_id -1;
170
171 # FIXME: mi output does not go through pagers, so these can be removed.
172 # force the height to "unlimited", so no pagers get used
173 send_gdb "100-gdb-set height 0\n"
174 gdb_expect 10 {
175 -re ".*100-gdb-set height 0\r\n100\\\^done\r\n$mi_gdb_prompt$" {
176 verbose "Setting height to 0." 2
177 }
178 timeout {
179 warning "Couldn't set the height to 0"
180 }
181 }
182 # force the width to "unlimited", so no wraparound occurs
183 send_gdb "101-gdb-set width 0\n"
184 gdb_expect 10 {
185 -re ".*101-gdb-set width 0\r\n101\\\^done\r\n$mi_gdb_prompt$" {
186 verbose "Setting width to 0." 2
187 }
188 timeout {
189 warning "Couldn't set the width to 0."
190 }
191 }
192
fb40c209
AC
193 return 0;
194}
195
196# Many of the tests depend on setting breakpoints at various places and
197# running until that breakpoint is reached. At times, we want to start
198# with a clean-slate with respect to breakpoints, so this utility proc
199# lets us do this without duplicating this code everywhere.
200#
201
202proc mi_delete_breakpoints {} {
203 global mi_gdb_prompt
204
205# FIXME: The mi operation won't accept a prompt back and will use the 'all' arg
206 send_gdb "102-break-delete\n"
207 gdb_expect 30 {
208 -re "Delete all breakpoints.*y or n.*$" {
209 send_gdb "y\n";
210 exp_continue
211 }
212 -re ".*102-break-delete\r\n102\\\^done\r\n$mi_gdb_prompt$" {
213 # This happens if there were no breakpoints
214 }
215 timeout { perror "Delete all breakpoints in delete_breakpoints (timeout)" ; return }
216 }
217
218# The correct output is not "No breakpoints or watchpoints." but an
219# empty BreakpointTable. Also, a query is not acceptable with mi.
220 send_gdb "103-break-list\n"
221 gdb_expect 30 {
222 -re "103-break-list\r\n103\\\^done,BreakpointTable=\{\}\r\n$mi_gdb_prompt$" {}
cff22675 223 -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=\\\[\\\]\}" {}
fb40c209
AC
224 -re "103-break-list\r\n103\\\^doneNo breakpoints or watchpoints.\r\n\r\n$mi_gdb_prompt$" {warning "Unexpected console text received"}
225 -re "$mi_gdb_prompt$" { perror "Breakpoints not deleted" ; return }
226 -re "Delete all breakpoints.*or n.*$" {
227 warning "Unexpected prompt for breakpoints deletion";
228 send_gdb "y\n";
229 exp_continue
230 }
231 timeout { perror "-break-list (timeout)" ; return }
232 }
233}
234
235proc mi_gdb_reinitialize_dir { subdir } {
236 global mi_gdb_prompt
237
238 global suppress_flag
239 if { $suppress_flag } {
240 return
241 }
242
243 if [is_remote host] {
244 return "";
245 }
246
247 send_gdb "104-environment-directory\n"
248 gdb_expect 60 {
249 -re ".*Reinitialize source path to empty.*y or n. " {
250 warning "Got confirmation prompt for dir reinitialization."
251 send_gdb "y\n"
252 gdb_expect 60 {
253 -re "$mi_gdb_prompt$" {}
254 timeout {error "Dir reinitialization failed (timeout)"}
255 }
256 }
257 -re "$mi_gdb_prompt$" {}
258 timeout {error "Dir reinitialization failed (timeout)"}
259 }
260
261 send_gdb "105-environment-directory $subdir\n"
262 gdb_expect 60 {
263 -re "Source directories searched.*$mi_gdb_prompt$" {
264 verbose "Dir set to $subdir"
265 }
266 -re "105\\\^done\r\n$mi_gdb_prompt$" {
267 # FIXME: We return just the prompt for now.
268 verbose "Dir set to $subdir"
269 # perror "Dir \"$subdir\" failed."
270 }
271 }
272}
273
274#
275# load a file into the debugger.
276# return a -1 if anything goes wrong.
277#
278proc mi_gdb_load { arg } {
279 global verbose
280 global loadpath
281 global loadfile
282 global GDB
283 global mi_gdb_prompt
284 upvar timeout timeout
285
286 # ``gdb_unload''
287
288 # ``gdb_file_cmd''
289# FIXME: Several of these patterns are only acceptable for console
290# output. Queries are an error for mi.
291 send_gdb "105-file-exec-and-symbols $arg\n"
292 gdb_expect 120 {
293 -re "Reading symbols from.*done.*$mi_gdb_prompt$" {
294 verbose "\t\tLoaded $arg into the $GDB"
295 # All OK
296 }
297 -re "has no symbol-table.*$mi_gdb_prompt$" {
298 perror "$arg wasn't compiled with \"-g\""
299 return -1
300 }
301 -re "A program is being debugged already.*Kill it.*y or n. $" {
302 send_gdb "y\n"
303 verbose "\t\tKilling previous program being debugged"
304 exp_continue
305 }
306 -re "Load new symbol table from \".*\".*y or n. $" {
307 send_gdb "y\n"
308 gdb_expect 120 {
309 -re "Reading symbols from.*done.*$mi_gdb_prompt$" {
310 verbose "\t\tLoaded $arg with new symbol table into $GDB"
311 # All OK
312 }
313 timeout {
314 perror "(timeout) Couldn't load $arg, other program already loaded."
315 return -1
316 }
317 }
318 }
319 -re "No such file or directory.*$mi_gdb_prompt$" {
320 perror "($arg) No such file or directory\n"
321 return -1
322 }
323 -re "105-file-exec-and-symbols .*\r\n105\\\^done\r\n$mi_gdb_prompt$" {
324 # We are just giving the prompt back for now
325 # All OK
326 }
327 timeout {
328 perror "couldn't load $arg into $GDB (timed out)."
329 return -1
330 }
331 eof {
332 # This is an attempt to detect a core dump, but seems not to
333 # work. Perhaps we need to match .* followed by eof, in which
334 # gdb_expect does not seem to have a way to do that.
335 perror "couldn't load $arg into $GDB (end of file)."
336 return -1
337 }
338 }
339
340 # ``load''
341 if { [info procs send_target_sid] != "" } {
342 # For SID, things get complex
343 send_target_sid
344 gdb_expect 60 {
345 -re "\\^done,.*$mi_gdb_prompt$" {
346 }
347 timeout {
348 perror "Unable to connect to SID target"
349 return -1
350 }
351 }
352 send_gdb "48-target-download\n"
353 gdb_expect 10 {
354 -re "48\\^done.*$mi_gdb_prompt$" {
355 }
356 timeout {
357 perror "Unable to download to SID target"
358 return -1
359 }
360 }
361 } elseif { [target_info protocol] == "sim" } {
362 # For the simulator, just connect to it directly.
363 send_gdb "47-target-select sim\n"
364 gdb_expect 10 {
365 -re "47\\^connected.*$mi_gdb_prompt$" {
366 }
367 timeout {
368 perror "Unable to select sim target"
369 return -1
370 }
371 }
372 send_gdb "48-target-download\n"
373 gdb_expect 10 {
374 -re "48\\^done.*$mi_gdb_prompt$" {
375 }
376 timeout {
377 perror "Unable to download to sim target"
378 return -1
379 }
380 }
381 }
382 return 0
383}
384
385# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
386#
387# COMMAND is the command to execute, send to GDB with send_gdb. If
388# this is the null string no command is sent.
389# PATTERN is the pattern to match for a PASS, and must NOT include
390# the \r\n sequence immediately before the gdb prompt.
391# MESSAGE is an optional message to be printed. If this is
392# omitted, then the pass/fail messages use the command string as the
393# message. (If this is the empty string, then sometimes we don't
394# call pass or fail at all; I don't understand this at all.)
395#
396# Returns:
397# 1 if the test failed,
398# 0 if the test passes,
399# -1 if there was an internal error.
400#
401proc mi_gdb_test { args } {
402 global verbose
403 global mi_gdb_prompt
07c98896 404 global GDB expect_out
fb40c209
AC
405 upvar timeout timeout
406
407 if [llength $args]>2 then {
408 set message [lindex $args 2]
409 } else {
410 set message [lindex $args 0]
411 }
412 set command [lindex $args 0]
413 set pattern [lindex $args 1]
414
415 if [llength $args]==5 {
416 set question_string [lindex $args 3];
417 set response_string [lindex $args 4];
418 } else {
419 set question_string "^FOOBAR$"
420 }
421
422 if $verbose>2 then {
423 send_user "Sending \"$command\" to gdb\n"
424 send_user "Looking to match \"$pattern\"\n"
425 send_user "Message is \"$message\"\n"
426 }
427
428 set result -1
429 set string "${command}\n";
430 if { $command != "" } {
431 while { "$string" != "" } {
432 set foo [string first "\n" "$string"];
433 set len [string length "$string"];
434 if { $foo < [expr $len - 1] } {
435 set str [string range "$string" 0 $foo];
436 if { [send_gdb "$str"] != "" } {
437 global suppress_flag;
438
439 if { ! $suppress_flag } {
440 perror "Couldn't send $command to GDB.";
441 }
442 fail "$message";
443 return $result;
444 }
445 gdb_expect 2 {
446 -re "\[\r\n\]" { }
447 timeout { }
448 }
449 set string [string range "$string" [expr $foo + 1] end];
450 } else {
451 break;
452 }
453 }
454 if { "$string" != "" } {
455 if { [send_gdb "$string"] != "" } {
456 global suppress_flag;
457
458 if { ! $suppress_flag } {
459 perror "Couldn't send $command to GDB.";
460 }
461 fail "$message";
462 return $result;
463 }
464 }
465 }
466
467 if [info exists timeout] {
468 set tmt $timeout;
469 } else {
470 global timeout;
471 if [info exists timeout] {
472 set tmt $timeout;
473 } else {
474 set tmt 60;
475 }
476 }
477 gdb_expect $tmt {
478 -re "\\*\\*\\* DOSEXIT code.*" {
479 if { $message != "" } {
480 fail "$message";
481 }
482 gdb_suppress_entire_file "GDB died";
483 return -1;
484 }
485 -re "Ending remote debugging.*$mi_gdb_prompt\[ \]*$" {
486 if ![isnative] then {
487 warning "Can`t communicate to remote target."
488 }
489 gdb_exit
490 gdb_start
491 set result -1
7ddebc7e
KS
492 }
493 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" {
494 if ![string match "" $message] then {
495 pass "$message"
496 }
497 set result 0
fb40c209
AC
498 }
499 -re "(${question_string})$" {
500 send_gdb "$response_string\n";
501 exp_continue;
502 }
503 -re "Undefined.* command:.*$mi_gdb_prompt\[ \]*$" {
504 perror "Undefined command \"$command\"."
505 fail "$message"
506 set result 1
507 }
508 -re "Ambiguous command.*$mi_gdb_prompt\[ \]*$" {
509 perror "\"$command\" is not a unique command name."
510 fail "$message"
511 set result 1
fb40c209
AC
512 }
513 -re "Program exited with code \[0-9\]+.*$mi_gdb_prompt\[ \]*$" {
514 if ![string match "" $message] then {
515 set errmsg "$message: the program exited"
516 } else {
517 set errmsg "$command: the program exited"
518 }
519 fail "$errmsg"
520 return -1
521 }
522 -re "The program is not being run.*$mi_gdb_prompt\[ \]*$" {
523 if ![string match "" $message] then {
524 set errmsg "$message: the program is no longer running"
525 } else {
526 set errmsg "$command: the program is no longer running"
527 }
528 fail "$errmsg"
529 return -1
530 }
531 -re ".*$mi_gdb_prompt\[ \]*$" {
532 if ![string match "" $message] then {
533 fail "$message"
534 }
535 set result 1
536 }
537 "<return>" {
538 send_gdb "\n"
539 perror "Window too small."
540 fail "$message"
541 }
542 -re "\\(y or n\\) " {
543 send_gdb "n\n"
544 perror "Got interactive prompt."
545 fail "$message"
546 }
547 eof {
548 perror "Process no longer exists"
549 if { $message != "" } {
550 fail "$message"
551 }
552 return -1
553 }
554 full_buffer {
555 perror "internal buffer is full."
556 fail "$message"
557 }
558 timeout {
559 if ![string match "" $message] then {
560 fail "$message (timeout)"
561 }
562 set result 1
563 }
564 }
565 return $result
566}
567
568#
569# MI run command. (A modified version of gdb_run_cmd)
570#
571
572# In patterns, the newline sequence ``\r\n'' is matched explicitly as
573# ``.*$'' could swallow up output that we attempt to match elsewhere.
574
575proc mi_run_cmd {args} {
576 global suppress_flag
577 if { $suppress_flag } {
578 return -1
579 }
580 global mi_gdb_prompt
581
582 if [target_info exists gdb_init_command] {
583 send_gdb "[target_info gdb_init_command]\n";
584 gdb_expect 30 {
585 -re "$mi_gdb_prompt$" { }
586 default {
587 perror "gdb_init_command for target failed";
588 return;
589 }
590 }
591 }
592
593 if [target_info exists use_gdb_stub] {
594 if [target_info exists gdb,do_reload_on_run] {
595 # Specifying no file, defaults to the executable
596 # currently being debugged.
597 if { [mi_gdb_load ""] < 0 } {
598 return;
599 }
600 send_gdb "000-exec-continue\n";
601 gdb_expect 60 {
602 -re "Continu\[^\r\n\]*\[\r\n\]" {}
603 default {}
604 }
605 return;
606 }
6a90e1d0
AC
607
608 if [target_info exists gdb,start_symbol] {
609 set start [target_info gdb,start_symbol];
610 } else {
611 set start "start";
612 }
613
614 # HACK: Should either use 000-jump or fix the target code
615 # to better handle RUN.
616 send_gdb "jump *$start\n"
617 warning "Using CLI jump command, expect run-to-main FAIL"
618 return
fb40c209
AC
619 }
620
621 send_gdb "000-exec-run $args\n"
622 gdb_expect {
623 -re "000\\^running\r\n${mi_gdb_prompt}" {
624 }
625 timeout {
626 perror "Unable to start target"
627 return
628 }
629 }
630 # NOTE: Shortly after this there will be a ``000*stopping,...(gdb)''
631}
632
633#
634# Just like run-to-main but works with the MI interface
635#
636
637proc mi_run_to_main { } {
638 global suppress_flag
639 if { $suppress_flag } {
640 return -1
641 }
642
fb40c209
AC
643 global srcdir
644 global subdir
645 global binfile
646 global srcfile
647
fb40c209
AC
648 mi_delete_breakpoints
649 mi_gdb_reinitialize_dir $srcdir/$subdir
650 mi_gdb_load ${binfile}
651
08b468e0
KS
652 mi_runto main
653}
fb40c209 654
08b468e0
KS
655
656# Just like gdb's "runto" proc, it will run the target to a given
657# function. The big difference here between mi_runto and mi_execute_to
658# is that mi_execute_to must have the inferior running already. This
659# proc will (like gdb's runto) (re)start the inferior, too.
660#
661# FUNC is the linespec of the place to stop (it inserts a breakpoint here).
662# It returns:
663# -1 if test suppressed, failed, timedout
664# 0 if test passed
665
666proc mi_runto {func} {
667 global suppress_flag
668 if { $suppress_flag } {
669 return -1
670 }
671
672 global mi_gdb_prompt expect_out
673 global hex decimal
674
675 set test "mi runto $func"
676 mi_gdb_test "200-break-insert $func" \
677 "200\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"$func\",file=\".*\",line=\"\[0-9\]*\",times=\"0\"\}" \
678 "breakpoint at $func"
679
680 if {![regexp {number="[0-9]+"} $expect_out(buffer) str]
681 || ![scan $str {number="%d"} bkptno]} {
682 set bkptno {[0-9]+}
683 }
684
685 mi_run_cmd
686 gdb_expect {
687 -re ".*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"$bkptno\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=\(\\\[.*\\\]\|\{.*\}\),file=\".*\",line=\"\[0-9\]*\"\}\r\n$mi_gdb_prompt$" {
688 pass "$test"
689 return 0
690 }
691 -re ".*$mi_gdb_prompt$" {
692 fail "$test (2)"
693 }
694 timeout {
695 fail "$test (timeout)"
696 return -1
697 }
698 }
fb40c209
AC
699}
700
701
702# Next to the next statement
08b468e0 703# For return values, see mi_execute_to_helper
fb40c209
AC
704
705proc mi_next { test } {
dc360f58 706 return [mi_next_to {.*} {.*} {.*} {.*} $test]
fb40c209
AC
707}
708
709
710# Step to the next statement
08b468e0 711# For return values, see mi_execute_to_helper
fb40c209
AC
712
713proc mi_step { test } {
dc360f58 714 return [mi_step_to {.*} {.*} {.*} {.*} $test]
fb40c209 715}
dcf95b47
DJ
716
717# cmd should not include the number or newline (i.e. "exec-step 3", not
718# "220-exec-step 3\n"
719
1902c51f
DJ
720# Can not match -re ".*\r\n${mi_gdb_prompt}", because of false positives
721# after the first prompt is printed.
722
08b468e0 723proc mi_execute_to_helper { cmd reason func args file line extra test } {
dcf95b47
DJ
724 global suppress_flag
725 if { $suppress_flag } {
726 return -1
727 }
728 global mi_gdb_prompt
729 global hex
730 global decimal
731 send_gdb "220-$cmd\n"
732 gdb_expect {
dc360f58 733 -re ".*220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\".*$file\",line=\"$line\"\}$extra\r\n$mi_gdb_prompt$" {
dcf95b47
DJ
734 pass "$test"
735 return 0
736 }
dc360f58 737 -re ".*220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\".*\",args=\[\\\[\{\].*\[\\\]\}\],file=\".*\",line=\"\[0-9\]*\"\}.*\r\n$mi_gdb_prompt$" {
dcf95b47
DJ
738 fail "$test (stopped at wrong place)"
739 return -1
740 }
741 -re "220\\^running\r\n${mi_gdb_prompt}.*\r\n${mi_gdb_prompt}$" {
742 fail "$test (unknown output after running)"
743 return -1
744 }
dcf95b47
DJ
745 timeout {
746 fail "$test (timeout)"
747 return -1
748 }
749 }
750}
751
08b468e0
KS
752proc mi_execute_to { cmd reason func args file line extra test } {
753 mi_execute_to_helper "$cmd" "$reason" "$func" "\\\[$args\\\]" \
dcf95b47
DJ
754 "$file" "$line" "$extra" "$test"
755}
756
757proc mi_next_to { func args file line test } {
08b468e0 758 mi_execute_to "exec-next" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
759 "$file" "$line" "" "$test"
760}
761
762proc mi_step_to { func args file line test } {
08b468e0 763 mi_execute_to "exec-step" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
764 "$file" "$line" "" "$test"
765}
766
767proc mi_finish_to { func args file line result ret test } {
08b468e0 768 mi_execute_to "exec-finish" "function-finished" "$func" "$args" \
dcf95b47
DJ
769 "$file" "$line" \
770 ",gdb-result-var=\"$result\",return-value=\"$ret\"" \
771 "$test"
772}
773
774proc mi_continue_to { bkptno func args file line test } {
08b468e0 775 mi_execute_to "exec-continue" "breakpoint-hit\",bkptno=\"$bkptno" \
dcf95b47
DJ
776 "$func" "$args" "$file" "$line" "" "$test"
777}
778
08b468e0
KS
779proc mi0_execute_to { cmd reason func args file line extra test } {
780 mi_execute_to_helper "$cmd" "$reason" "$func" "\{$args\}" \
dcf95b47
DJ
781 "$file" "$line" "$extra" "$test"
782}
783
784proc mi0_next_to { func args file line test } {
08b468e0 785 mi0_execute_to "exec-next" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
786 "$file" "$line" "" "$test"
787}
788
789proc mi0_step_to { func args file line test } {
08b468e0 790 mi0_execute_to "exec-step" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
791 "$file" "$line" "" "$test"
792}
793
794proc mi0_finish_to { func args file line result ret test } {
08b468e0 795 mi0_execute_to "exec-finish" "function-finished" "$func" "$args" \
dcf95b47
DJ
796 "$file" "$line" \
797 ",gdb-result-var=\"$result\",return-value=\"$ret\"" \
798 "$test"
799}
800
801proc mi0_continue_to { bkptno func args file line test } {
08b468e0 802 mi0_execute_to "exec-continue" "breakpoint-hit\",bkptno=\"$bkptno" \
dcf95b47
DJ
803 "$func" "$args" "$file" "$line" "" "$test"
804}
This page took 0.286269 seconds and 4 git commands to generate.