1 # Copyright 1999-2014 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # test running programs
23 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
24 untested $testfile.exp
29 # set it up at a breakpoint so we can play with it
31 if ![runto_main] then {
32 perror "couldn't run to breakpoint"
36 gdb_test "break baz" ".*" ""
39 # Make sure we get a 'completed' message when the target is done.
41 gdb_test_no_output "set exec-done-display on"
43 # Test a background execution command. COMMAND is the command to
44 # send. BEFORE_PROMPT is the pattern expected before the GDB prompt
45 # is output. AFTER_PROMPT is the pattern expected after the prompt
46 # and before "completed". MESSAGE is optional, and is the pass/fail
47 # message to br printed. If omitted, then the command string is used
49 proc test_background {command before_prompt after_prompt {message ""}} {
58 -re "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\.\r\n" {
61 -re "$gdb_prompt.*completed\.\r\n" {
65 fail "$message (timeout)"
70 test_background "next&" "" ".*z = 9.*"
72 test_background "step&" "" ".*y = foo \\(\\).*" "step& #1"
74 test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*" "step& #2"
76 test_background "stepi&" "" ".*$hex.*x = 5.*"
78 test_background "nexti&" "" ".*y = 3.*"
80 test_background "finish&" \
81 "Run till exit from #0 foo \\(\\) at.*async.c.*\r\n" \
82 ".*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*"
84 set jump_here [gdb_get_line_number "jump here"]
85 test_background "jump $jump_here&" \
86 ".*Continuing at $hex.*" \
87 ".*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*" \
90 set until_here [gdb_get_line_number "until here"]
91 test_background "until $until_here&" \
93 ".*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*" \
96 gdb_test_no_output "set exec-done-display off"