Home | History | Annotate | Line # | Download | only in gdb.mi
mi-threads-interrupt.exp revision 1.1.1.4.2.1
      1  1.1.1.4.2.1  perseant # Copyright 2016-2023 Free Software Foundation, Inc.
      2          1.1  christos 
      3          1.1  christos # This program is free software; you can redistribute it and/or modify
      4          1.1  christos # it under the terms of the GNU General Public License as published by
      5          1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6          1.1  christos # (at your option) any later version.
      7          1.1  christos #
      8          1.1  christos # This program is distributed in the hope that it will be useful,
      9          1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10          1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11          1.1  christos # GNU General Public License for more details.
     12          1.1  christos #
     13          1.1  christos # You should have received a copy of the GNU General Public License
     14          1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15          1.1  christos 
     16      1.1.1.3  christos if [target_info exists gdb,nointerrupts] {
     17      1.1.1.3  christos     verbose "Skipping mi-threads-interrupt.exp because of nointerrupts."
     18  1.1.1.4.2.1  perseant     return
     19      1.1.1.3  christos }
     20      1.1.1.3  christos 
     21          1.1  christos load_lib mi-support.exp
     22          1.1  christos set MIFLAGS "-i=mi"
     23          1.1  christos 
     24          1.1  christos standard_testfile
     25          1.1  christos 
     26          1.1  christos if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" } {
     27          1.1  christos     return -1
     28          1.1  christos }
     29          1.1  christos 
     30          1.1  christos # This tests the resolution of PR 20039.
     31          1.1  christos #
     32          1.1  christos # With a multi-threaded inferior and with MI/all-stop, it was not possible
     33          1.1  christos # to interrupt it with ctrl-C after a continue.
     34          1.1  christos 
     35          1.1  christos proc test_continue_interrupt { } {
     36          1.1  christos   global binfile
     37          1.1  christos   global async
     38          1.1  christos 
     39          1.1  christos   gdb_exit
     40          1.1  christos   if {[mi_gdb_start]} {
     41  1.1.1.4.2.1  perseant       return
     42          1.1  christos   }
     43          1.1  christos 
     44          1.1  christos   # Load the binary in gdb...
     45          1.1  christos   mi_gdb_load $binfile
     46          1.1  christos 
     47          1.1  christos   # ... and run it.
     48          1.1  christos   #
     49          1.1  christos   # Note this test relies on mi_runto deleting the breakpoint.
     50          1.1  christos   # A step-over here would mask the bug.
     51          1.1  christos   mi_runto "all_threads_created"
     52          1.1  christos 
     53          1.1  christos   # Consistency check.
     54          1.1  christos   mi_check_thread_states {"stopped" "stopped" "stopped"} "check thread states"
     55          1.1  christos 
     56          1.1  christos   # Continue.
     57          1.1  christos   mi_send_resuming_command "exec-continue" "continue"
     58          1.1  christos 
     59          1.1  christos   # Wait a bit to make sure all MI events are sent, before sending the
     60          1.1  christos   # interruption request.
     61          1.1  christos   sleep 1
     62          1.1  christos 
     63          1.1  christos   # Send the interrupt request.
     64          1.1  christos   if { $async } {
     65          1.1  christos     mi_gdb_test "888-exec-interrupt" "888\\^done" "interrupt"
     66          1.1  christos   } else {
     67          1.1  christos     send_gdb "\003"
     68          1.1  christos   }
     69          1.1  christos 
     70          1.1  christos   # Wait for the *stopped.
     71          1.1  christos   mi_expect_interrupt "interrupt reported"
     72          1.1  christos }
     73          1.1  christos 
     74          1.1  christos test_continue_interrupt
     75