Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 1999-2015 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 JM |
27 | |
28 | # | |
29 | # set it up at a breakpoint so we can play with it | |
30 | # | |
31 | if ![runto_main] then { | |
32 | perror "couldn't run to breakpoint" | |
33 | continue | |
34 | } | |
35 | ||
de7ff789 | 36 | gdb_test "break baz" ".*" "" |
104c1213 JM |
37 | |
38 | # | |
39 | # Make sure we get a 'completed' message when the target is done. | |
40 | # | |
0172b6a7 | 41 | gdb_test_no_output "set exec-done-display on" |
104c1213 | 42 | |
884e37dc PA |
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 | |
48 | # as message. | |
49 | proc test_background {command before_prompt after_prompt {message ""}} { | |
50 | global gdb_prompt | |
51 | ||
52 | if {$message eq ""} { | |
53 | set message $command | |
54 | } | |
55 | ||
56 | send_gdb "$command\n" | |
57 | gdb_expect { | |
58 | -re "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\.\r\n" { | |
59 | pass "$message" | |
60 | } | |
8bcfb00a | 61 | -re "$gdb_prompt.*completed\.\r\n" { |
884e37dc PA |
62 | fail "$message" |
63 | } | |
64 | timeout { | |
65 | fail "$message (timeout)" | |
66 | } | |
67 | } | |
104c1213 JM |
68 | } |
69 | ||
884e37dc | 70 | test_background "next&" "" ".*z = 9.*" |
104c1213 | 71 | |
6048b950 | 72 | test_background "step&" "" ".*y = foo \\(\\).*" "step& #1" |
104c1213 | 73 | |
6048b950 | 74 | test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*" "step& #2" |
104c1213 | 75 | |
884e37dc | 76 | test_background "stepi&" "" ".*$hex.*x = 5.*" |
104c1213 | 77 | |
e5e01dbf YQ |
78 | # Get the next instruction address. |
79 | set next_insn_addr "" | |
80 | set test "get next insn" | |
81 | gdb_test_multiple {x/2i $pc} "$test" { | |
82 | -re "=> $hex .* 0x(\[0-9a-f\]*) .*$gdb_prompt $" { | |
83 | set next_insn_addr $expect_out(1,string) | |
84 | pass "$test" | |
85 | } | |
86 | } | |
87 | ||
88 | # We nexti into the same source line. The current PC is printed out. | |
89 | test_background "nexti&" "" ".* 0x0*$next_insn_addr.* x = 5; .*" | |
104c1213 | 90 | |
e5e01dbf | 91 | # PC is in the middle of a source line, so the PC address is displayed. |
884e37dc | 92 | test_background "finish&" \ |
e5e01dbf | 93 | "Run till exit from #0 $hex in foo \\(\\) at.*async.c.*\r\n" \ |
884e37dc | 94 | ".*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*" |
e2f6c966 | 95 | |
884e37dc PA |
96 | set jump_here [gdb_get_line_number "jump here"] |
97 | test_background "jump $jump_here&" \ | |
98 | ".*Continuing at $hex.*" \ | |
99 | ".*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*" \ | |
100 | "jump&" | |
104c1213 | 101 | |
e2f6c966 | 102 | set until_here [gdb_get_line_number "until here"] |
884e37dc PA |
103 | test_background "until $until_here&" \ |
104 | ".*" \ | |
105 | ".*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*" \ | |
106 | "until&" | |
104c1213 | 107 | |
0172b6a7 | 108 | gdb_test_no_output "set exec-done-display off" |