Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright (C) 2014-2016 Free Software Foundation, Inc. |
0ff33695 PA |
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 3 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, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # Test that "c -a" doesn't leave GDB processing input, even if all | |
17 | # threads were already running. PR gdb/17300. | |
18 | ||
19 | standard_testfile | |
20 | ||
5b362f04 | 21 | if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile] } { |
0ff33695 PA |
22 | return -1 |
23 | } | |
24 | ||
25 | gdb_test_no_output "set non-stop on" | |
26 | ||
27 | if ![runto_main] { | |
28 | return | |
29 | } | |
30 | ||
31 | set linenum [gdb_get_line_number "set break here"] | |
32 | gdb_breakpoint "$linenum" | |
33 | ||
34 | gdb_test "c -a&" "Continuing\\." | |
35 | ||
36 | set test "no stop" | |
37 | gdb_test_multiple "" $test { | |
38 | -timeout 1 | |
39 | timeout { | |
40 | pass $test | |
41 | } | |
42 | } | |
43 | ||
44 | # Paranoia. Check that input works after bg command. | |
45 | gdb_test "print 1" " = 1" | |
46 | ||
47 | # Continue in the foreground, and wait one second to make sure the | |
48 | # inferior really starts running. If we get a prompt to soon (e.g., | |
49 | # the program stops), this issues a fail. | |
50 | set saw_continuing 0 | |
51 | set test "c -a" | |
52 | gdb_test_multiple "c -a" $test { | |
53 | -timeout 1 | |
54 | -re "Continuing\\." { | |
55 | set saw_continuing 1 | |
56 | exp_continue | |
57 | } | |
58 | timeout { | |
59 | gdb_assert $saw_continuing $test | |
60 | } | |
61 | } | |
62 | ||
63 | # Type something while the inferior is running in the foreground. | |
64 | send_gdb "print 2\n" | |
65 | ||
66 | # Poor buggy GDB would crash before the breakpoint was hit. | |
67 | set test "breakpoint hit" | |
68 | gdb_test_multiple "" $test { | |
69 | -re "set break here ..\r\n$gdb_prompt " { | |
70 | pass $test | |
71 | } | |
72 | } | |
73 | ||
74 | set test "print command result" | |
75 | gdb_test_multiple "" $test { | |
76 | -re " = 2\r\n$gdb_prompt $" { | |
77 | pass $test | |
78 | } | |
79 | } |