828ef129940246cd7423464789d81d28e5faf3a7
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / gdb.exp
1 # Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 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 written by Fred Fish. (fnf@cygnus.com)
21
22 # Generic gdb subroutines that should work for any target. If these
23 # need to be modified for any target, it can be done with a variable
24 # or by passing arguments.
25
26 load_lib libgloss.exp
27
28 global GDB
29 global CHILL_LIB
30 global CHILL_RT0
31
32 if ![info exists CHILL_LIB] {
33 set CHILL_LIB [findfile $base_dir/../../gcc/ch/runtime/libchill.a "$base_dir/../../gcc/ch/runtime/libchill.a" [transform -lchill]]
34 }
35 verbose "using CHILL_LIB = $CHILL_LIB" 2
36 if ![info exists CHILL_RT0] {
37 set CHILL_RT0 [findfile $base_dir/../../gcc/ch/runtime/chillrt0.o "$base_dir/../../gcc/ch/runtime/chillrt0.o" ""]
38 }
39 verbose "using CHILL_RT0 = $CHILL_RT0" 2
40
41 if ![info exists GDB] {
42 if ![is_remote host] {
43 set GDB [findfile $base_dir/../../gdb/gdb "$base_dir/../../gdb/gdb" [transform gdb]]
44 } else {
45 set GDB gdb
46 }
47 }
48 verbose "using GDB = $GDB" 2
49
50 global GDBFLAGS
51 if ![info exists GDBFLAGS] {
52 set GDBFLAGS "-nx"
53 }
54 verbose "using GDBFLAGS = $GDBFLAGS" 2
55
56 # The variable prompt is a regexp which matches the gdb prompt. Set it if it
57 # is not already set.
58 global prompt
59 if ![info exists prompt] then {
60 set prompt "\[(\]gdb\[)\]"
61 }
62
63 if ![info exists noargs] then {
64 set noargs 0
65 }
66
67 if ![info exists nosignals] then {
68 set nosignals 0
69 }
70
71 if ![info exists noinferiorio] then {
72 set noinferiorio 0
73 }
74
75 if ![info exists noresults] then {
76 set noresults 0
77 }
78
79 #
80 # gdb_version -- extract and print the version number of GDB
81 #
82 proc default_gdb_version {} {
83 global GDB
84 global GDBFLAGS
85 global prompt
86 set fileid [open "gdb_cmd" w];
87 puts $fileid "q";
88 close $fileid;
89 set cmdfile [remote_download host "gdb_cmd"];
90 set output [remote_exec host "$GDB -nw --command $cmdfile"]
91 remote_file build delete "gdb_cmd";
92 remote_file host delete "$cmdfile";
93 set tmp [lindex $output 1];
94 set version ""
95 regexp " \[0-9\]\[^ \t\n\r\]+" "$tmp" version
96 if ![is_remote host] {
97 clone_output "[which $GDB] version $version $GDBFLAGS\n"
98 } else {
99 clone_output "$GDB on remote host version $version $GDBFLAGS\n"
100 }
101 }
102
103 proc gdb_version { } {
104 return [default_gdb_version];
105 }
106
107 #
108 # gdb_unload -- unload a file if one is loaded
109 #
110
111 proc gdb_unload {} {
112 global verbose
113 global GDB
114 global prompt
115 send_gdb "file\n"
116 expect {
117 -re "No exec file now.*\r" { exp_continue }
118 -re "No symbol file now.*\r" { exp_continue }
119 -re "A program is being debugged already..*Kill it.*y or n. $"\
120 { send_gdb "y\n"
121 verbose "\t\tKilling previous program being debugged"
122 exp_continue
123 }
124 -re "Discard symbol table from .*y or n. $" {
125 send_gdb "y\n"
126 exp_continue
127 }
128 -re "$prompt $" {}
129 timeout {
130 perror "couldn't unload file in $GDB (timed out)."
131 return -1
132 }
133 }
134 }
135
136 # Many of the tests depend on setting breakpoints at various places and
137 # running until that breakpoint is reached. At times, we want to start
138 # with a clean-slate with respect to breakpoints, so this utility proc
139 # lets us do this without duplicating this code everywhere.
140 #
141
142 proc delete_breakpoints {} {
143 global prompt
144 global gdb_spawn_id
145
146 send_gdb "delete breakpoints\n"
147 expect {
148 -i $gdb_spawn_id -re ".*Delete all breakpoints.*y or n.*$" {
149 send_gdb "y\n";
150 exp_continue
151 }
152 -i $gdb_spawn_id -re ".*$prompt $" { # This happens if there were no breakpoints
153 }
154 -i $gdb_spawn_id timeout { perror "Delete all breakpoints in delete_breakpoints (timeout)" ; return }
155 }
156 send_gdb "info breakpoints\n"
157 expect {
158 -i $gdb_spawn_id -re "No breakpoints or watchpoints..*$prompt $" {}
159 -i $gdb_spawn_id -re ".*$prompt $" { perror "breakpoints not deleted" ; return }
160 -i $gdb_spawn_id -re "Delete all breakpoints.*or n.*$" {
161 send_gdb "y\n";
162 exp_continue
163 }
164 -i $gdb_spawn_id timeout { perror "info breakpoints (timeout)" ; return }
165 }
166 }
167
168
169 #
170 # Generic run command.
171 #
172 # The second pattern below matches up to the first newline *only*.
173 # Using ``.*$'' could swallow up output that we attempt to match
174 # elsewhere.
175 #
176 proc gdb_run_cmd {args} {
177 global prompt
178 global gdb_spawn_id
179
180 set spawn_id $gdb_spawn_id
181
182 if [target_info exists use_gdb_stub] {
183 send_gdb "jump *start\n"
184 expect {
185 -re "Line.* Jump anyway.*y or n. $" {
186 send_gdb "y\n"
187 expect {
188 -re "Continuing.*$prompt $" {}
189 timeout { perror "Jump to start() failed (timeout)"; return }
190 }
191 }
192 -re "No symbol.*context.*$prompt $" {}
193 -re "The program is not being run.*$prompt $" {
194 gdb_load "";
195 }
196 timeout { perror "Jump to start() failed (timeout)"; return }
197 }
198 send_gdb "continue\n"
199 return
200 }
201 send_gdb "run $args\n"
202 # This doesn't work quite right yet.
203 expect {
204 -re "The program .* has been started already.*y or n. $" {
205 send_gdb "y\n"
206 exp_continue
207 }
208 -re "Starting program: \[^\n\]*" {}
209 }
210 }
211
212 proc gdb_breakpoint { function } {
213 global prompt
214 global decimal
215 global gdb_spawn_id
216
217 set spawn_id $gdb_spawn_id
218
219 send_gdb "break $function\n"
220 # The first two regexps are what we get with -g, the third is without -g.
221 expect {
222 -re "Breakpoint \[0-9\]* at .*: file .*, line $decimal.\r\n$prompt $" {}
223 -re "Breakpoint \[0-9\]*: file .*, line $decimal.\r\n$prompt $" {}
224 -re "Breakpoint \[0-9\]* at .*$prompt $" {}
225 -re "$prompt $" { fail "setting breakpoint at $function" ; return 0 }
226 timeout { fail "setting breakpoint at $function (timeout)" ; return 0 }
227 }
228 return 1;
229 }
230
231 # Set breakpoint at function and run gdb until it breaks there.
232 # Since this is the only breakpoint that will be set, if it stops
233 # at a breakpoint, we will assume it is the one we want. We can't
234 # just compare to "function" because it might be a fully qualified,
235 # single quoted C++ function specifier.
236
237 proc runto { function } {
238 global prompt
239 global decimal
240 global gdb_spawn_id
241
242 set spawn_id $gdb_spawn_id
243
244 delete_breakpoints
245
246 if ![gdb_breakpoint $function] {
247 return 0;
248 }
249
250 gdb_run_cmd
251
252 # the "at foo.c:36" output we get with -g.
253 # the "in func" output we get without -g.
254 expect {
255 -re "Break.* at .*:$decimal.*$prompt $" {
256 return 1
257 }
258 -re "Breakpoint \[0-9\]*, \[0-9xa-f\]* in $function.*$prompt $" {
259 return 1
260 }
261 -re "$prompt $" {
262 fail "running to $function in runto"
263 return 0
264 }
265 timeout {
266 fail "running to $function in runto (timeout)"
267 return 0
268 }
269 }
270 return 1
271 }
272
273 #
274 # runto_main -- ask gdb to run until we hit a breakpoint at main.
275 # The case where the target uses stubs has to be handled
276 # specially--if it uses stubs, assuming we hit
277 # breakpoint() and just step out of the function.
278 #
279 proc runto_main {} {
280 global prompt
281 global decimal
282
283 if ![target_info exists gdb_stub] {
284 return [runto main]
285 }
286
287 delete_breakpoints
288
289 send_gdb "step\n"
290 # if use stubs step out of the breakpoint() function.
291 expect {
292 -re "main.* at .*$prompt $" {}
293 -re "_start.*$prompt $" {}
294 timeout { fail "single step at breakpoint() (timeout)" ; return 0 }
295 }
296 return 1
297 }
298
299 #
300 # gdb_test -- send_gdb a command to gdb and test the result.
301 # Takes three parameters.
302 # Parameters:
303 # First one is the command to execute. If this is the null string
304 # then no command is sent.
305 # Second one is the pattern to match for a PASS, and must NOT include
306 # the \r\n sequence immediately before the gdb prompt.
307 # Third one is an optional message to be printed. If this
308 # a null string "", then the pass/fail messages use the command
309 # string as the message.
310 # Returns:
311 # 1 if the test failed,
312 # 0 if the test passes,
313 # -1 if there was an internal error.
314 #
315 proc gdb_test { args } {
316 global verbose
317 global prompt
318 global GDB
319 global expect_out
320 upvar timeout timeout
321
322 if [llength $args]>2 then {
323 set message [lindex $args 2]
324 } else {
325 set message [lindex $args 0]
326 }
327 set command [lindex $args 0]
328 set pattern [lindex $args 1]
329
330 if [llength $args]==5 {
331 set question_string [lindex $args 3];
332 set response_string [lindex $args 4];
333 } else {
334 set question_string "^FOOBAR$"
335 }
336
337 if $verbose>2 then {
338 send_user "Sending \"$command\" to gdb\n"
339 send_user "Looking to match \"$pattern\"\n"
340 send_user "Message is \"$message\"\n"
341 }
342
343 set result -1
344 if ![string match $command ""] {
345 send_gdb "$command\n"
346 }
347
348 expect {
349 -re ".*Ending remote debugging.*$prompt$" {
350 if ![isnative] then {
351 warning "Can`t communicate to remote target."
352 }
353 gdb_exit
354 gdb_start
355 set result -1
356 }
357 -re "\[\r\n\]*$pattern\[\r\n\]+$prompt $" {
358 if ![string match "" $message] then {
359 pass "$message"
360 }
361 set result 0
362 }
363 -re "${question_string}$" {
364 send_gdb "$response_string\n";
365 exp_continue;
366 }
367 -re "Undefined command:.*$prompt" {
368 perror "Undefined command \"$command\"."
369 set result 1
370 }
371 -re "Ambiguous command.*$prompt $" {
372 perror "\"$command\" is not a unique command name."
373 set result 1
374 }
375 -re ".*Program exited with code \[0-9\]+.*$prompt $" {
376 if ![string match "" $message] then {
377 set errmsg "$message: the program exited"
378 } else {
379 set errmsg "$command: the program exited"
380 }
381 fail "$errmsg"
382 return -1
383 }
384 -re "The program is not being run.*$prompt $" {
385 if ![string match "" $message] then {
386 set errmsg "$message: the program is no longer running"
387 } else {
388 set errmsg "$command: the program is no longer running"
389 }
390 fail "$errmsg"
391 return -1
392 }
393 -re ".*$prompt $" {
394 if ![string match "" $message] then {
395 fail "$message"
396 }
397 set result 1
398 }
399 "<return>" {
400 send_gdb "\n"
401 perror "Window too small."
402 }
403 -re "\\(y or n\\) " {
404 send_gdb "n\n"
405 perror "Got interactive prompt."
406 }
407 eof {
408 perror "Process no longer exists"
409 return -1
410 }
411 full_buffer {
412 perror "internal buffer is full."
413 }
414 timeout {
415 if ![string match "" $message] then {
416 fail "(timeout) $message"
417 }
418 set result 1
419 }
420 }
421 return $result
422 }
423 \f
424 # Test that a command gives an error. For pass or fail, return
425 # a 1 to indicate that more tests can proceed. However a timeout
426 # is a serious error, generates a special fail message, and causes
427 # a 0 to be returned to indicate that more tests are likely to fail
428 # as well.
429
430 proc test_print_reject { args } {
431 global prompt
432 global verbose
433
434 if [llength $args]==2 then {
435 set expectthis [lindex $args 1]
436 } else {
437 set expectthis "should never match this bogus string"
438 }
439 set sendthis [lindex $args 0]
440 if $verbose>2 then {
441 send_user "Sending \"$sendthis\" to gdb\n"
442 send_user "Looking to match \"$expectthis\"\n"
443 }
444 send_gdb "$sendthis\n"
445 expect {
446 -re ".*A .* in expression.*\\.*$prompt $" {
447 pass "reject $sendthis"
448 return 1
449 }
450 -re ".*Invalid syntax in expression.*$prompt $" {
451 pass "reject $sendthis"
452 return 1
453 }
454 -re ".*Junk after end of expression.*$prompt $" {
455 pass "reject $sendthis"
456 return 1
457 }
458 -re ".*Invalid number.*$prompt $" {
459 pass "reject $sendthis"
460 return 1
461 }
462 -re ".*Invalid character constant.*$prompt $" {
463 pass "reject $sendthis"
464 return 1
465 }
466 -re ".*No symbol table is loaded.*$prompt $" {
467 pass "reject $sendthis"
468 return 1
469 }
470 -re ".*No symbol .* in current context.*$prompt $" {
471 pass "reject $sendthis"
472 return 1
473 }
474 -re ".*$expectthis.*$prompt $" {
475 pass "reject $sendthis"
476 return 1
477 }
478 -re ".*$prompt $" {
479 fail "reject $sendthis"
480 return 1
481 }
482 default {
483 fail "reject $sendthis (eof or timeout)"
484 return 0
485 }
486 }
487 }
488 \f
489 # Given an input string, adds backslashes as needed to create a
490 # regexp that will match the string.
491
492 proc string_to_regexp {str} {
493 set result $str
494 regsub -all {[]*+.|()^$\[]} $str {\\&} result
495 return $result
496 }
497
498 # Same as gdb_test, but the second parameter is not a regexp,
499 # but a string that must match exactly.
500
501 proc gdb_test_exact { args } {
502 upvar timeout timeout
503
504 set command [lindex $args 0]
505
506 # This applies a special meaning to a null string pattern. Without
507 # this, "$pattern\r\n$prompt $" will match anything, including error
508 # messages from commands that should have no output except a new
509 # prompt. With this, only results of a null string will match a null
510 # string pattern.
511
512 set pattern [lindex $args 1]
513 if [string match $pattern ""] {
514 set pattern [string_to_regexp [lindex $args 0]]
515 } else {
516 set pattern [string_to_regexp [lindex $args 1]]
517 }
518
519 # It is most natural to write the pattern argument with only
520 # embedded \n's, especially if you are trying to avoid Tcl quoting
521 # problems. But expect really wants to see \r\n in patterns. So
522 # transform the pattern here. First transform \r\n back to \n, in
523 # case some users of gdb_test_exact already do the right thing.
524 regsub -all "\r\n" $pattern "\n" pattern
525 regsub -all "\n" $pattern "\r\n" pattern
526 if [llength $args]==3 then {
527 set message [lindex $args 2]
528 } else {
529 set message $command
530 }
531
532 return [gdb_test $command $pattern $message]
533 }
534 \f
535 proc gdb_reinitialize_dir { subdir } {
536 global prompt
537 global gdb_spawn_id
538 set spawn_id $gdb_spawn_id
539
540 if [is_remote host] {
541 return "";
542 }
543 send_gdb "dir\n"
544 expect {
545 -re "Reinitialize source path to empty.*y or n. " {
546 send_gdb "y\n"
547 expect {
548 -re "Source directories searched.*$prompt $" {
549 send_gdb "dir $subdir\n"
550 expect {
551 -re "Source directories searched.*$prompt $" {
552 verbose "Dir set to $subdir"
553 }
554 -re ".*$prompt $" {
555 perror "Dir \"$subdir\" failed."
556 }
557 }
558 }
559 -re ".*$prompt $" {
560 perror "Dir \"$subdir\" failed."
561 }
562 }
563 }
564 -re ".*$prompt $" {
565 perror "Dir \"$subdir\" failed."
566 }
567 }
568 }
569
570 #
571 # gdb_exit -- exit the GDB, killing the target program if necessary
572 #
573 proc default_gdb_exit {} {
574 global GDB
575 global GDBFLAGS
576 global verbose
577 global gdb_spawn_id
578
579 if ![info exists gdb_spawn_id] {
580 return;
581 }
582
583 verbose "Quitting $GDB $GDBFLAGS"
584
585 # This used to be 1 for unix-gdb.exp
586 set timeout 5
587 verbose "Timeout is now $timeout seconds" 2
588
589 if [is_remote host] {
590 send_gdb "quit\n";
591 expect {
592 -i $gdb_spawn_id -re ".*and kill it.*y or n. " {
593 send_gdb "y\n";
594 exp_continue;
595 }
596 -i $gdb_spawn_id timeout { }
597 }
598 } else {
599 # We used to try to send_gdb "quit" to GDB, and wait for it to die.
600 # Dealing with all the cases and errors got pretty hairy. Just close it,
601 # that is simpler.
602 catch "close -i $gdb_spawn_id"
603
604 # Omitting this probably would cause strange timing-dependent failures.
605 catch "wait -i $gdb_spawn_id"
606 }
607
608 remote_close host;
609 unset gdb_spawn_id
610 }
611
612 #
613 # load a file into the debugger.
614 # return a -1 if anything goes wrong.
615 #
616 proc gdb_file_cmd { arg } {
617 global verbose
618 global loadpath
619 global loadfile
620 global GDB
621 global prompt
622 upvar timeout timeout
623 global gdb_spawn_id
624 set spawn_id $gdb_spawn_id
625
626 if [is_remote host] {
627 set arg [remote_download host $arg];
628 if { $arg == "" } {
629 error "download failed"
630 return -1;
631 }
632 }
633
634 send_gdb "file $arg\n"
635 expect {
636 -re "Reading symbols from.*done.*$prompt $" {
637 verbose "\t\tLoaded $arg into the $GDB"
638 return 0
639 }
640 -re "has no symbol-table.*$prompt $" {
641 perror "$arg wasn't compiled with \"-g\""
642 return -1
643 }
644 -re "A program is being debugged already.*Kill it.*y or n. $" {
645 send_gdb "y\n"
646 verbose "\t\tKilling previous program being debugged"
647 exp_continue
648 }
649 -re "Load new symbol table from \".*\".*y or n. $" {
650 send_gdb "y\n"
651 expect {
652 -re "Reading symbols from.*done.*$prompt $" {
653 verbose "\t\tLoaded $arg with new symbol table into $GDB"
654 return 0
655 }
656 timeout {
657 perror "(timeout) Couldn't load $arg, other program already loaded."
658 return -1
659 }
660 }
661 }
662 -re ".*No such file or directory.*$prompt $" {
663 perror "($arg) No such file or directory\n"
664 return -1
665 }
666 -re "$prompt $" {
667 perror "couldn't load $arg into $GDB."
668 return -1
669 }
670 timeout {
671 perror "couldn't load $arg into $GDB (timed out)."
672 return -1
673 }
674 eof {
675 # This is an attempt to detect a core dump, but seems not to
676 # work. Perhaps we need to match .* followed by eof, in which
677 # expect does not seem to have a way to do that.
678 perror "couldn't load $arg into $GDB (end of file)."
679 return -1
680 }
681 }
682 }
683
684 #
685 # start gdb -- start gdb running, default procedure
686 #
687 # When running over NFS, particularly if running many simultaneous
688 # tests on different hosts all using the same server, things can
689 # get really slow. Give gdb at least 3 minutes to start up.
690 #
691 proc default_gdb_start { } {
692 global verbose
693 global GDB
694 global GDBFLAGS
695 global prompt
696 global timeout
697 global gdb_spawn_id
698 global spawn_id
699 verbose "Spawning $GDB -nw $GDBFLAGS"
700
701 if [info exists gdb_spawn_id] {
702 return 0;
703 }
704
705 set oldtimeout $timeout
706 set timeout [expr "$timeout + 180"]
707 if [is_remote host] {
708 set shell_id [remote_spawn host "$GDB -nw $GDBFLAGS --command gdbinit"]
709 } else {
710 if { [which $GDB] == 0 } then {
711 perror "$GDB does not exist."
712 exit 1
713 }
714
715 set shell_id [remote_spawn host "$GDB -nw $GDBFLAGS"]
716 }
717 verbose $shell_id
718 set timeout 10
719 expect {
720 -i $shell_id -re ".*\[\r\n\]$prompt $" {
721 verbose "GDB initialized."
722 }
723 -i $shell_id -re "$prompt $" {
724 perror "GDB never initialized."
725 set timeout $oldtimeout
726 verbose "Timeout restored to $timeout seconds" 2
727 return -1
728 }
729 -i $shell_id timeout {
730 perror "(timeout) GDB never initialized after $timeout seconds."
731 set timeout $oldtimeout
732 verbose "Timeout restored to $timeout seconds" 2
733 return -1
734 }
735 }
736 set timeout $oldtimeout
737 verbose "Timeout restored to $timeout seconds" 2
738 set gdb_spawn_id $shell_id
739 set spawn_id $gdb_spawn_id
740 # force the height to "unlimited", so no pagers get used
741 send_gdb "set height 0\n"
742 expect {
743 -i $shell_id -re ".*$prompt $" {
744 verbose "Setting height to 0." 2
745 }
746 -i $shell_id timeout {
747 warning "Couldn't set the height to 0"
748 }
749 }
750 # force the width to "unlimited", so no wraparound occurs
751 send_gdb "set width 0\n"
752 expect {
753 -i $shell_id -re ".*$prompt $" {
754 verbose "Setting width to 0." 2
755 }
756 -i $shell_id timeout {
757 warning "Couldn't set the width to 0."
758 }
759 }
760 return 0;
761 }
762
763 #
764 # FIXME: this is a copy of the new library procedure, but it's here too
765 # till the new dejagnu gets installed everywhere. I'd hate to break the
766 # gdb testsuite.
767 #
768 global argv0
769 if ![info exists argv0] then {
770 proc exp_continue { } {
771 continue -expect
772 }
773 }
774
775 # * For crosses, the CHILL runtime doesn't build because it can't find
776 # setjmp.h, stdio.h, etc.
777 # * For AIX (as of 16 Mar 95), (a) there is no language code for
778 # CHILL in output_epilog in gcc/config/rs6000/rs6000.c, (b) collect2
779 # does not get along with AIX's too-clever linker.
780 # * On Irix5, there is a bug whereby set of bool, etc., don't get
781 # TYPE_LOW_BOUND for the bool right because force_to_range_type doesn't
782 # work with stub types.
783 # Lots of things seem to fail on the PA, and since it's not a supported
784 # chill target at the moment, don't run the chill tests.
785
786 proc skip_chill_tests {} {
787 if ![info exists do_chill_tests] {
788 return 1;
789 }
790 eval set skip_chill [expr ![isnative] || [istarget "*-*-aix*"] || [istarget "*-*-irix5*"] || [istarget "*-*-irix6*"] || [istarget "alpha-*-osf*"] || [istarget "hppa*-*-*"]]
791 verbose "Skip chill tests is $skip_chill"
792 return $skip_chill
793 }
794
795 proc get_compiler_info {binfile} {
796 # Create and source the file that provides information about the compiler
797 # used to compile the test case.
798 global srcdir
799 global subdir
800 # These two come from compiler.c.
801 global signed_keyword_not_used
802 global gcc_compiled
803
804 if { [gdb_compile "${srcdir}/${subdir}/compiler.c" "${binfile}.ci" preprocess {}] != "" } {
805 perror "Couldn't make ${binfile}.ci file"
806 return 1;
807 }
808 source ${binfile}.ci
809 return 0;
810 }
811
812 proc gdb_compile {source dest type options} {
813 if [target_info exists gdb_stub] {
814 set options2 { "additional_flags=-Dusestubs" }
815 lappend options "libs=[target_info gdb_stub]";
816 set options [concat $options2 $options]
817 }
818 verbose "options are $options"
819 verbose "source is $source $dest $type $options"
820 set result [target_compile $source $dest $type $options];
821 regsub "\[\r\n\]*$" "$result" "" result;
822 regsub "^\[\r\n\]*" "$result" "" result;
823 if { $result != "" } {
824 clone_output "gdb compile failed, $result"
825 }
826 return $result;
827 }
828
829 proc send_gdb { string } {
830 return [remote_send host "$string"];
831 }
832
833 proc gdb_start { } {
834 default_gdb_start
835 }
836
837 proc gdb_exit { } {
838 catch default_gdb_exit
839 }
840
841 #
842 # gdb_load -- load a file into the debugger.
843 # return a -1 if anything goes wrong.
844 #
845 proc gdb_load { arg } {
846 return [gdb_file_cmd $arg]
847 }
848
849 proc gdb_continue { function } {
850 global decimal
851
852 return [gdb_test "continue" ".*Breakpoint $decimal, $function .*" "continue to $function"];
853 }
854
855 proc gdb_finish { } {
856 gdb_exit;
857 }
This page took 0.048868 seconds and 4 git commands to generate.