xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp (revision fc4f42693f9b1c31f39f9cf50af1bf2010325808)
1# Copyright 2016 Free Software Foundation, Inc.
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
16load_lib mi-support.exp
17set MIFLAGS "-i=mi"
18
19standard_testfile
20
21if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" } {
22    return -1
23}
24
25# This tests the resolution of PR 20039.
26#
27# With a multi-threaded inferior and with MI/all-stop, it was not possible
28# to interrupt it with ctrl-C after a continue.
29
30proc test_continue_interrupt { } {
31  global binfile
32  global async
33
34  gdb_exit
35  if {[mi_gdb_start]} {
36      continue
37  }
38
39  # Load the binary in gdb...
40  mi_gdb_load $binfile
41
42  # ... and run it.
43  #
44  # Note this test relies on mi_runto deleting the breakpoint.
45  # A step-over here would mask the bug.
46  mi_runto "all_threads_created"
47
48  # Consistency check.
49  mi_check_thread_states {"stopped" "stopped" "stopped"} "check thread states"
50
51  # Continue.
52  mi_send_resuming_command "exec-continue" "continue"
53
54  # Wait a bit to make sure all MI events are sent, before sending the
55  # interruption request.
56  sleep 1
57
58  # Send the interrupt request.
59  if { $async } {
60    mi_gdb_test "888-exec-interrupt" "888\\^done" "interrupt"
61  } else {
62    send_gdb "\003"
63  }
64
65  # Wait for the *stopped.
66  mi_expect_interrupt "interrupt reported"
67}
68
69test_continue_interrupt
70