bfd_follow_gnu_debuglink: New function. Follow the pointer contained inside a
[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 }
f1c8a949 215 timeout { perror "Delete all breakpoints in mi_delete_breakpoints (timeout)" ; return }
fb40c209
AC
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
da81390b 237 global MIFLAGS
fb40c209
AC
238
239 global suppress_flag
240 if { $suppress_flag } {
241 return
242 }
243
244 if [is_remote host] {
245 return "";
246 }
247
da81390b
JJ
248 if { $MIFLAGS == "-i=mi1" } {
249 send_gdb "104-environment-directory\n"
250 gdb_expect 60 {
fb40c209
AC
251 -re ".*Reinitialize source path to empty.*y or n. " {
252 warning "Got confirmation prompt for dir reinitialization."
253 send_gdb "y\n"
254 gdb_expect 60 {
255 -re "$mi_gdb_prompt$" {}
256 timeout {error "Dir reinitialization failed (timeout)"}
257 }
258 }
259 -re "$mi_gdb_prompt$" {}
260 timeout {error "Dir reinitialization failed (timeout)"}
da81390b
JJ
261 }
262 } else {
263 send_gdb "104-environment-directory -r\n"
264 gdb_expect 60 {
265 -re "104\\\^done,source-path=.*\r\n$mi_gdb_prompt$" {}
266 -re "$mi_gdb_prompt$" {}
267 timeout {error "Dir reinitialization failed (timeout)"}
268 }
fb40c209
AC
269 }
270
271 send_gdb "105-environment-directory $subdir\n"
272 gdb_expect 60 {
273 -re "Source directories searched.*$mi_gdb_prompt$" {
274 verbose "Dir set to $subdir"
275 }
da81390b 276 -re "105\\\^done.*\r\n$mi_gdb_prompt$" {
fb40c209
AC
277 # FIXME: We return just the prompt for now.
278 verbose "Dir set to $subdir"
279 # perror "Dir \"$subdir\" failed."
280 }
281 }
282}
283
284#
285# load a file into the debugger.
286# return a -1 if anything goes wrong.
287#
288proc mi_gdb_load { arg } {
289 global verbose
290 global loadpath
291 global loadfile
292 global GDB
293 global mi_gdb_prompt
294 upvar timeout timeout
295
296 # ``gdb_unload''
297
298 # ``gdb_file_cmd''
299# FIXME: Several of these patterns are only acceptable for console
300# output. Queries are an error for mi.
301 send_gdb "105-file-exec-and-symbols $arg\n"
302 gdb_expect 120 {
303 -re "Reading symbols from.*done.*$mi_gdb_prompt$" {
304 verbose "\t\tLoaded $arg into the $GDB"
305 # All OK
306 }
307 -re "has no symbol-table.*$mi_gdb_prompt$" {
308 perror "$arg wasn't compiled with \"-g\""
309 return -1
310 }
311 -re "A program is being debugged already.*Kill it.*y or n. $" {
312 send_gdb "y\n"
313 verbose "\t\tKilling previous program being debugged"
314 exp_continue
315 }
316 -re "Load new symbol table from \".*\".*y or n. $" {
317 send_gdb "y\n"
318 gdb_expect 120 {
319 -re "Reading symbols from.*done.*$mi_gdb_prompt$" {
320 verbose "\t\tLoaded $arg with new symbol table into $GDB"
321 # All OK
322 }
323 timeout {
324 perror "(timeout) Couldn't load $arg, other program already loaded."
325 return -1
326 }
327 }
328 }
329 -re "No such file or directory.*$mi_gdb_prompt$" {
330 perror "($arg) No such file or directory\n"
331 return -1
332 }
333 -re "105-file-exec-and-symbols .*\r\n105\\\^done\r\n$mi_gdb_prompt$" {
334 # We are just giving the prompt back for now
335 # All OK
336 }
337 timeout {
338 perror "couldn't load $arg into $GDB (timed out)."
339 return -1
340 }
341 eof {
342 # This is an attempt to detect a core dump, but seems not to
343 # work. Perhaps we need to match .* followed by eof, in which
344 # gdb_expect does not seem to have a way to do that.
345 perror "couldn't load $arg into $GDB (end of file)."
346 return -1
347 }
348 }
349
350 # ``load''
351 if { [info procs send_target_sid] != "" } {
352 # For SID, things get complex
353 send_target_sid
354 gdb_expect 60 {
355 -re "\\^done,.*$mi_gdb_prompt$" {
356 }
357 timeout {
358 perror "Unable to connect to SID target"
359 return -1
360 }
361 }
362 send_gdb "48-target-download\n"
363 gdb_expect 10 {
364 -re "48\\^done.*$mi_gdb_prompt$" {
365 }
366 timeout {
367 perror "Unable to download to SID target"
368 return -1
369 }
370 }
371 } elseif { [target_info protocol] == "sim" } {
372 # For the simulator, just connect to it directly.
373 send_gdb "47-target-select sim\n"
374 gdb_expect 10 {
375 -re "47\\^connected.*$mi_gdb_prompt$" {
376 }
377 timeout {
378 perror "Unable to select sim target"
379 return -1
380 }
381 }
382 send_gdb "48-target-download\n"
383 gdb_expect 10 {
384 -re "48\\^done.*$mi_gdb_prompt$" {
385 }
386 timeout {
387 perror "Unable to download to sim target"
388 return -1
389 }
390 }
391 }
392 return 0
393}
394
395# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
396#
397# COMMAND is the command to execute, send to GDB with send_gdb. If
398# this is the null string no command is sent.
399# PATTERN is the pattern to match for a PASS, and must NOT include
400# the \r\n sequence immediately before the gdb prompt.
401# MESSAGE is an optional message to be printed. If this is
402# omitted, then the pass/fail messages use the command string as the
403# message. (If this is the empty string, then sometimes we don't
404# call pass or fail at all; I don't understand this at all.)
405#
406# Returns:
407# 1 if the test failed,
408# 0 if the test passes,
409# -1 if there was an internal error.
410#
411proc mi_gdb_test { args } {
412 global verbose
413 global mi_gdb_prompt
07c98896 414 global GDB expect_out
fb40c209
AC
415 upvar timeout timeout
416
417 if [llength $args]>2 then {
418 set message [lindex $args 2]
419 } else {
420 set message [lindex $args 0]
421 }
422 set command [lindex $args 0]
423 set pattern [lindex $args 1]
424
425 if [llength $args]==5 {
426 set question_string [lindex $args 3];
427 set response_string [lindex $args 4];
428 } else {
429 set question_string "^FOOBAR$"
430 }
431
432 if $verbose>2 then {
433 send_user "Sending \"$command\" to gdb\n"
434 send_user "Looking to match \"$pattern\"\n"
435 send_user "Message is \"$message\"\n"
436 }
437
438 set result -1
439 set string "${command}\n";
440 if { $command != "" } {
441 while { "$string" != "" } {
442 set foo [string first "\n" "$string"];
443 set len [string length "$string"];
444 if { $foo < [expr $len - 1] } {
445 set str [string range "$string" 0 $foo];
446 if { [send_gdb "$str"] != "" } {
447 global suppress_flag;
448
449 if { ! $suppress_flag } {
450 perror "Couldn't send $command to GDB.";
451 }
452 fail "$message";
453 return $result;
454 }
455 gdb_expect 2 {
456 -re "\[\r\n\]" { }
457 timeout { }
458 }
459 set string [string range "$string" [expr $foo + 1] end];
460 } else {
461 break;
462 }
463 }
464 if { "$string" != "" } {
465 if { [send_gdb "$string"] != "" } {
466 global suppress_flag;
467
468 if { ! $suppress_flag } {
469 perror "Couldn't send $command to GDB.";
470 }
471 fail "$message";
472 return $result;
473 }
474 }
475 }
476
477 if [info exists timeout] {
478 set tmt $timeout;
479 } else {
480 global timeout;
481 if [info exists timeout] {
482 set tmt $timeout;
483 } else {
484 set tmt 60;
485 }
486 }
487 gdb_expect $tmt {
488 -re "\\*\\*\\* DOSEXIT code.*" {
489 if { $message != "" } {
490 fail "$message";
491 }
492 gdb_suppress_entire_file "GDB died";
493 return -1;
494 }
495 -re "Ending remote debugging.*$mi_gdb_prompt\[ \]*$" {
496 if ![isnative] then {
497 warning "Can`t communicate to remote target."
498 }
499 gdb_exit
500 gdb_start
501 set result -1
7ddebc7e
KS
502 }
503 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" {
504 if ![string match "" $message] then {
505 pass "$message"
506 }
507 set result 0
fb40c209
AC
508 }
509 -re "(${question_string})$" {
510 send_gdb "$response_string\n";
511 exp_continue;
512 }
513 -re "Undefined.* command:.*$mi_gdb_prompt\[ \]*$" {
514 perror "Undefined command \"$command\"."
515 fail "$message"
516 set result 1
517 }
518 -re "Ambiguous command.*$mi_gdb_prompt\[ \]*$" {
519 perror "\"$command\" is not a unique command name."
520 fail "$message"
521 set result 1
fb40c209
AC
522 }
523 -re "Program exited with code \[0-9\]+.*$mi_gdb_prompt\[ \]*$" {
524 if ![string match "" $message] then {
525 set errmsg "$message: the program exited"
526 } else {
527 set errmsg "$command: the program exited"
528 }
529 fail "$errmsg"
530 return -1
531 }
532 -re "The program is not being run.*$mi_gdb_prompt\[ \]*$" {
533 if ![string match "" $message] then {
534 set errmsg "$message: the program is no longer running"
535 } else {
536 set errmsg "$command: the program is no longer running"
537 }
538 fail "$errmsg"
539 return -1
540 }
541 -re ".*$mi_gdb_prompt\[ \]*$" {
542 if ![string match "" $message] then {
543 fail "$message"
544 }
545 set result 1
546 }
547 "<return>" {
548 send_gdb "\n"
549 perror "Window too small."
550 fail "$message"
551 }
552 -re "\\(y or n\\) " {
553 send_gdb "n\n"
554 perror "Got interactive prompt."
555 fail "$message"
556 }
557 eof {
558 perror "Process no longer exists"
559 if { $message != "" } {
560 fail "$message"
561 }
562 return -1
563 }
564 full_buffer {
565 perror "internal buffer is full."
566 fail "$message"
567 }
568 timeout {
569 if ![string match "" $message] then {
570 fail "$message (timeout)"
571 }
572 set result 1
573 }
574 }
575 return $result
576}
577
578#
579# MI run command. (A modified version of gdb_run_cmd)
580#
581
582# In patterns, the newline sequence ``\r\n'' is matched explicitly as
583# ``.*$'' could swallow up output that we attempt to match elsewhere.
584
585proc mi_run_cmd {args} {
586 global suppress_flag
587 if { $suppress_flag } {
588 return -1
589 }
590 global mi_gdb_prompt
591
592 if [target_info exists gdb_init_command] {
593 send_gdb "[target_info gdb_init_command]\n";
594 gdb_expect 30 {
595 -re "$mi_gdb_prompt$" { }
596 default {
597 perror "gdb_init_command for target failed";
598 return;
599 }
600 }
601 }
602
603 if [target_info exists use_gdb_stub] {
604 if [target_info exists gdb,do_reload_on_run] {
605 # Specifying no file, defaults to the executable
606 # currently being debugged.
607 if { [mi_gdb_load ""] < 0 } {
608 return;
609 }
610 send_gdb "000-exec-continue\n";
611 gdb_expect 60 {
612 -re "Continu\[^\r\n\]*\[\r\n\]" {}
613 default {}
614 }
615 return;
616 }
6a90e1d0
AC
617
618 if [target_info exists gdb,start_symbol] {
619 set start [target_info gdb,start_symbol];
620 } else {
621 set start "start";
622 }
623
624 # HACK: Should either use 000-jump or fix the target code
625 # to better handle RUN.
626 send_gdb "jump *$start\n"
627 warning "Using CLI jump command, expect run-to-main FAIL"
628 return
fb40c209
AC
629 }
630
631 send_gdb "000-exec-run $args\n"
632 gdb_expect {
633 -re "000\\^running\r\n${mi_gdb_prompt}" {
634 }
635 timeout {
636 perror "Unable to start target"
637 return
638 }
639 }
640 # NOTE: Shortly after this there will be a ``000*stopping,...(gdb)''
641}
642
643#
644# Just like run-to-main but works with the MI interface
645#
646
647proc mi_run_to_main { } {
648 global suppress_flag
649 if { $suppress_flag } {
650 return -1
651 }
652
fb40c209
AC
653 global srcdir
654 global subdir
655 global binfile
656 global srcfile
657
fb40c209
AC
658 mi_delete_breakpoints
659 mi_gdb_reinitialize_dir $srcdir/$subdir
660 mi_gdb_load ${binfile}
661
08b468e0
KS
662 mi_runto main
663}
fb40c209 664
08b468e0
KS
665
666# Just like gdb's "runto" proc, it will run the target to a given
667# function. The big difference here between mi_runto and mi_execute_to
668# is that mi_execute_to must have the inferior running already. This
669# proc will (like gdb's runto) (re)start the inferior, too.
670#
671# FUNC is the linespec of the place to stop (it inserts a breakpoint here).
672# It returns:
673# -1 if test suppressed, failed, timedout
674# 0 if test passed
675
676proc mi_runto {func} {
677 global suppress_flag
678 if { $suppress_flag } {
679 return -1
680 }
681
682 global mi_gdb_prompt expect_out
683 global hex decimal
684
685 set test "mi runto $func"
686 mi_gdb_test "200-break-insert $func" \
687 "200\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"$func\",file=\".*\",line=\"\[0-9\]*\",times=\"0\"\}" \
688 "breakpoint at $func"
689
690 if {![regexp {number="[0-9]+"} $expect_out(buffer) str]
691 || ![scan $str {number="%d"} bkptno]} {
692 set bkptno {[0-9]+}
693 }
694
695 mi_run_cmd
696 gdb_expect {
697 -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$" {
698 pass "$test"
699 return 0
700 }
701 -re ".*$mi_gdb_prompt$" {
702 fail "$test (2)"
703 }
704 timeout {
705 fail "$test (timeout)"
706 return -1
707 }
708 }
fb40c209
AC
709}
710
711
712# Next to the next statement
08b468e0 713# For return values, see mi_execute_to_helper
fb40c209
AC
714
715proc mi_next { test } {
dc360f58 716 return [mi_next_to {.*} {.*} {.*} {.*} $test]
fb40c209
AC
717}
718
719
720# Step to the next statement
08b468e0 721# For return values, see mi_execute_to_helper
fb40c209
AC
722
723proc mi_step { test } {
dc360f58 724 return [mi_step_to {.*} {.*} {.*} {.*} $test]
fb40c209 725}
dcf95b47
DJ
726
727# cmd should not include the number or newline (i.e. "exec-step 3", not
728# "220-exec-step 3\n"
729
1902c51f
DJ
730# Can not match -re ".*\r\n${mi_gdb_prompt}", because of false positives
731# after the first prompt is printed.
732
08b468e0 733proc mi_execute_to_helper { cmd reason func args file line extra test } {
dcf95b47
DJ
734 global suppress_flag
735 if { $suppress_flag } {
736 return -1
737 }
738 global mi_gdb_prompt
739 global hex
740 global decimal
741 send_gdb "220-$cmd\n"
742 gdb_expect {
dc360f58 743 -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
744 pass "$test"
745 return 0
746 }
dc360f58 747 -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
748 fail "$test (stopped at wrong place)"
749 return -1
750 }
751 -re "220\\^running\r\n${mi_gdb_prompt}.*\r\n${mi_gdb_prompt}$" {
752 fail "$test (unknown output after running)"
753 return -1
754 }
dcf95b47
DJ
755 timeout {
756 fail "$test (timeout)"
757 return -1
758 }
759 }
760}
761
08b468e0
KS
762proc mi_execute_to { cmd reason func args file line extra test } {
763 mi_execute_to_helper "$cmd" "$reason" "$func" "\\\[$args\\\]" \
dcf95b47
DJ
764 "$file" "$line" "$extra" "$test"
765}
766
767proc mi_next_to { func args file line test } {
08b468e0 768 mi_execute_to "exec-next" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
769 "$file" "$line" "" "$test"
770}
771
772proc mi_step_to { func args file line test } {
08b468e0 773 mi_execute_to "exec-step" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
774 "$file" "$line" "" "$test"
775}
776
777proc mi_finish_to { func args file line result ret test } {
08b468e0 778 mi_execute_to "exec-finish" "function-finished" "$func" "$args" \
dcf95b47
DJ
779 "$file" "$line" \
780 ",gdb-result-var=\"$result\",return-value=\"$ret\"" \
781 "$test"
782}
783
784proc mi_continue_to { bkptno func args file line test } {
08b468e0 785 mi_execute_to "exec-continue" "breakpoint-hit\",bkptno=\"$bkptno" \
dcf95b47
DJ
786 "$func" "$args" "$file" "$line" "" "$test"
787}
788
08b468e0
KS
789proc mi0_execute_to { cmd reason func args file line extra test } {
790 mi_execute_to_helper "$cmd" "$reason" "$func" "\{$args\}" \
dcf95b47
DJ
791 "$file" "$line" "$extra" "$test"
792}
793
794proc mi0_next_to { func args file line test } {
08b468e0 795 mi0_execute_to "exec-next" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
796 "$file" "$line" "" "$test"
797}
798
799proc mi0_step_to { func args file line test } {
08b468e0 800 mi0_execute_to "exec-step" "end-stepping-range" "$func" "$args" \
dcf95b47
DJ
801 "$file" "$line" "" "$test"
802}
803
804proc mi0_finish_to { func args file line result ret test } {
08b468e0 805 mi0_execute_to "exec-finish" "function-finished" "$func" "$args" \
dcf95b47
DJ
806 "$file" "$line" \
807 ",gdb-result-var=\"$result\",return-value=\"$ret\"" \
808 "$test"
809}
810
811proc mi0_continue_to { bkptno func args file line test } {
08b468e0 812 mi0_execute_to "exec-continue" "breakpoint-hit\",bkptno=\"$bkptno" \
dcf95b47
DJ
813 "$func" "$args" "$file" "$line" "" "$test"
814}
This page took 0.328906 seconds and 4 git commands to generate.