Skip tests that send ctrl-c to GDB if nointerrupts target property is set.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / double-prompt-target-event-error.exp
CommitLineData
32d0add0 1# Copyright (C) 2014-2015 Free Software Foundation, Inc.
1e973570
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
87a3a92c
SL
16if [target_info exists gdb,nointerrupts] {
17 verbose "Skipping double-prompt-target-event-error.exp because of nointerrupts."
18 return
19}
20
1e973570
PA
21standard_testfile
22
23if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug] == -1} {
24 return -1
25}
26
27# Test throwing an error while GDB is handling a target event. We use
28# a ctrl-c/quit in a pagination prompt to emulate an error. COMMAND
29# is either "continue" or "wrapcont". The latter is a continue issued
30# from a user-defined command. That exercises the case of the
31# interpreter forced sync, which was the case that originally had a
32# bug.
33
34proc cancel_pagination_in_target_event { command } {
35 global binfile srcfile
36 global gdb_prompt pagination_prompt
37
38 set testline [gdb_get_line_number "after sleep"]
39
40 with_test_prefix "ctrlc target event: $command" {
41 clean_restart $binfile
42
43 if ![runto_main] then {
44 fail "Can't run to main"
45 return 0
46 }
47
48 gdb_test "b $srcfile:$testline" \
49 "Breakpoint .*$srcfile, line $testline.*" \
50 "set breakpoint"
51
52 gdb_test_no_output "set height 2"
53
54 if { $command == "wrapcont" } {
55 gdb_test_multiple "define wrapcont" "define user command: wrapcont" {
56 -re "Type commands for definition of \"wrapcont\".\r\nEnd with a line saying just \"end\".\r\n>$" {
57 # Note that "Continuing." is ommitted when
58 # "continue" is issued from a user-defined
59 # command. Issue it ourselves.
60 gdb_test "echo Continuing\.\ncontinue\nend" "" \
61 "define user command: wrapcont"
62 }
63 }
64 }
65
66 # Wait for pagination prompt after the "Continuing" line,
67 # indicating the program was running and then stopped.
68 set saw_continuing 0
69 set test "continue to pagination"
70 gdb_test_multiple "$command" $test {
71 -re "$pagination_prompt$" {
72 if {$saw_continuing} {
73 pass $test
74 } else {
75 send_gdb "\n"
76 exp_continue
77 }
78 }
79 -re "Continuing" {
80 set saw_continuing 1
81 exp_continue
82 }
1e973570
PA
83 }
84
85 # We're now stopped in a pagination query while handling a
86 # target event (printing where the program stopped). Quitting
87 # the pagination should result in only one prompt being
88 # output.
89 send_gdb "\003p 1\n"
90
c3f814a1
PA
91 # Note gdb_test_multiple has a default match for the prompt,
92 # which issues a FAIL. Consume the first prompt.
93 set test "first prompt"
94 gdb_test_multiple "" $test {
95 -re "$gdb_prompt" {
96 pass "first prompt"
97 }
98 }
99
100 # We should only see one prompt more, and it should be
101 # preceeded by print's output.
1e973570
PA
102 set test "no double prompt"
103 gdb_test_multiple "" $test {
c3f814a1
PA
104 -re "$gdb_prompt.*$gdb_prompt $" {
105 # The bug is present, and expect managed to read
106 # enough characters into the buffer to fill it with
107 # both prompts.
1e973570
PA
108 fail $test
109 }
c3f814a1 110 -re " = 1\r\n$gdb_prompt $" {
1e973570
PA
111 pass $test
112 }
1e973570
PA
113 }
114
115 # In case the board file wants to send further commands.
116 gdb_test_no_output "set height unlimited"
117 }
118}
119
120foreach variant { "continue" "wrapcont" } {
121 cancel_pagination_in_target_event $variant
122}
This page took 0.190416 seconds and 4 git commands to generate.