1 # Copyright
(C
) 2014-2019 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
/>.
16 if [target_info
exists gdb
,nointerrupts
] {
17 verbose
"Skipping double-prompt-target-event-error.exp because of nointerrupts."
23 if {[prepare_for_testing
"failed to prepare" $testfile $srcfile debug] == -1} {
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
34 proc cancel_pagination_in_target_event
{ command
} {
35 global binfile srcfile
36 global gdb_prompt pagination_prompt
38 set testline
[gdb_get_line_number
"after sleep"]
40 with_test_prefix
"ctrlc target event: $command" {
41 clean_restart $binfile
43 if ![runto_main
] then {
44 fail
"can't run to main"
48 gdb_test
"b $srcfile:$testline" \
49 "Breakpoint .*$srcfile, line $testline.*" \
52 gdb_test_no_output
"set height 2"
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"
66 # Wait
for pagination prompt after the
"Continuing" line,
67 # indicating the
program was running and
then stopped.
69 set test
"continue to pagination"
70 gdb_test_multiple
"$command" $test {
71 -re
"$pagination_prompt$" {
72 if {$saw_continuing
} {
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
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 {
100 # We should only see one prompt more, and it should be
101 # preceeded by print's output.
102 set test
"no double prompt"
103 gdb_test_multiple
"" $test {
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
110 -re
" = 1\r\n$gdb_prompt $" {
115 # In case the board file wants to send further commands.
116 gdb_test_no_output
"set height unlimited"
120 foreach variant
{ "continue" "wrapcont" } {
121 cancel_pagination_in_target_event $variant