Commit | Line | Data |
---|---|---|
ecd75fc8 | 1 | # Copyright 1999-2014 Free Software Foundation, Inc. |
104c1213 JM |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
104c1213 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
104c1213 JM |
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. | |
e22f8b7c | 12 | # |
104c1213 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
104c1213 | 15 | |
104c1213 | 16 | |
104c1213 JM |
17 | # |
18 | # test running programs | |
19 | # | |
104c1213 | 20 | |
a64d2530 | 21 | standard_testfile |
104c1213 | 22 | |
148e57e2 PA |
23 | if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { |
24 | untested $testfile.exp | |
25 | return -1 | |
26 | } | |
104c1213 | 27 | |
0172b6a7 DE |
28 | gdb_test_no_output "set target-async on" |
29 | ||
104c1213 JM |
30 | # |
31 | # set it up at a breakpoint so we can play with it | |
32 | # | |
33 | if ![runto_main] then { | |
34 | perror "couldn't run to breakpoint" | |
35 | continue | |
36 | } | |
37 | ||
de7ff789 | 38 | gdb_test "break baz" ".*" "" |
104c1213 JM |
39 | |
40 | # | |
41 | # Make sure we get a 'completed' message when the target is done. | |
42 | # | |
0172b6a7 | 43 | gdb_test_no_output "set exec-done-display on" |
104c1213 | 44 | |
884e37dc PA |
45 | # Test a background execution command. COMMAND is the command to |
46 | # send. BEFORE_PROMPT is the pattern expected before the GDB prompt | |
47 | # is output. AFTER_PROMPT is the pattern expected after the prompt | |
48 | # and before "completed". MESSAGE is optional, and is the pass/fail | |
49 | # message to br printed. If omitted, then the command string is used | |
50 | # as message. | |
51 | proc test_background {command before_prompt after_prompt {message ""}} { | |
52 | global gdb_prompt | |
53 | ||
54 | if {$message eq ""} { | |
55 | set message $command | |
56 | } | |
57 | ||
58 | send_gdb "$command\n" | |
59 | gdb_expect { | |
60 | -re "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\.\r\n" { | |
61 | pass "$message" | |
62 | } | |
8bcfb00a | 63 | -re "$gdb_prompt.*completed\.\r\n" { |
884e37dc PA |
64 | fail "$message" |
65 | } | |
66 | timeout { | |
67 | fail "$message (timeout)" | |
68 | } | |
69 | } | |
104c1213 JM |
70 | } |
71 | ||
884e37dc | 72 | test_background "next&" "" ".*z = 9.*" |
104c1213 | 73 | |
6048b950 | 74 | test_background "step&" "" ".*y = foo \\(\\).*" "step& #1" |
104c1213 | 75 | |
6048b950 | 76 | test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*" "step& #2" |
104c1213 | 77 | |
884e37dc | 78 | test_background "stepi&" "" ".*$hex.*x = 5.*" |
104c1213 | 79 | |
884e37dc | 80 | test_background "nexti&" "" ".*y = 3.*" |
104c1213 | 81 | |
884e37dc PA |
82 | test_background "finish&" \ |
83 | "Run till exit from #0 foo \\(\\) at.*async.c.*\r\n" \ | |
84 | ".*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*" | |
e2f6c966 | 85 | |
884e37dc PA |
86 | set jump_here [gdb_get_line_number "jump here"] |
87 | test_background "jump $jump_here&" \ | |
88 | ".*Continuing at $hex.*" \ | |
89 | ".*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*" \ | |
90 | "jump&" | |
104c1213 | 91 | |
e2f6c966 | 92 | set until_here [gdb_get_line_number "until here"] |
884e37dc PA |
93 | test_background "until $until_here&" \ |
94 | ".*" \ | |
95 | ".*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*" \ | |
96 | "until&" | |
104c1213 | 97 | |
0172b6a7 | 98 | gdb_test_no_output "set exec-done-display off" |