]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.mi/interrupt-thread-group.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / interrupt-thread-group.exp
1 # Copyright 2021-2024 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
16 # Test --exec-interrupt with thread-group.
17 #
18 # Run two inferiors, try interrupting them both with --exec-interrupt +
19 # --thread-group.
20
21 load_lib mi-support.exp
22 set MIFLAGS "-i=mi"
23
24 standard_testfile .c
25
26 if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
27 executable {debug additional_flags=-std=gnu99}] != "" } {
28 return -1
29 }
30
31 save_vars { GDBFLAGS } {
32 append GDBFLAGS " -ex \"set non-stop on\" -ex \"set mi-async\""
33 mi_clean_restart $binfile
34 }
35
36 mi_detect_async
37
38 # Create breakpoint by hand instead of using mi_runto, since we'll need it for
39 # both inferiors.
40 mi_create_breakpoint "all_threads_started" \
41 "set breakpoint on all_threads_started"
42
43 # Run first inferior to all_threads_started (to ensure all threads are started)
44 # and resume it.
45 if { [mi_run_cmd] < 0 } {
46 return
47 }
48
49 mi_expect_stop "breakpoint-hit" "all_threads_started" ".*" ".*" ".*" {"" "disp=\"keep\""} \
50 "inferior i1 stops at all_threads_started"
51
52 mi_send_resuming_command "exec-continue --thread-group i1" \
53 "continue inferior 1"
54
55 # We can't run a second inferior on stub targets. We can still test with one
56 # inferior and ensure that the command has the desired effect.
57 set use_second_inferior [expr {![use_gdb_stub]}]
58
59 if { $use_second_inferior } {
60 mi_gdb_test "-add-inferior" \
61 "\\^done,inferior=\"i2\",connection=\\{\[^\}\]+\\}" \
62 "add inferior 2"
63 mi_gdb_test "-file-exec-and-symbols --thread-group i2 $::binfile" \
64 "\\^done" \
65 "set executable of inferior 2"
66 # Run second inferior to all_threads_started (to ensure all threads are
67 # started) and resume it.
68 mi_gdb_test "-exec-run --thread-group i2" \
69 "\\^running.*" \
70 "run inferior 2"
71
72 mi_expect_stop "breakpoint-hit" "all_threads_started" ".*" ".*" ".*" {"" "disp=\"keep\"" "locno=\"[0-9]+\""} \
73 "inferior i2 stops at all_threads_started"
74
75 mi_send_resuming_command "exec-continue --thread-group i2" \
76 "continue inferior 2"
77
78 mi_check_thread_states {
79 "running" "running" "running" "running" "running"
80 "running" "running" "running" "running" "running"
81 } "before interrupting"
82 } else {
83 mi_check_thread_states {
84 "running" "running" "running" "running" "running"
85 } "before interrupting"
86 }
87
88 # Interrupt inferior 1, wait for events.
89 mi_gdb_test "-exec-interrupt --thread-group i1" \
90 "\\^done" \
91 "interrupt inferior 1"
92
93 for {set i 0} {$i < 5} {incr i} {
94 mi_expect_interrupt "inferior 1, interrupt $i"
95 }
96
97 if { $use_second_inferior } {
98 mi_check_thread_states {
99 "stopped" "stopped" "stopped" "stopped" "stopped"
100 "running" "running" "running" "running" "running"
101 } "after interrupting inferior 1"
102
103 # Interrupt inferior 2, wait for events.
104 mi_gdb_test "-exec-interrupt --thread-group i2" \
105 "\\^done" \
106 "interrupt inferior 2"
107
108 for {set i 0} {$i < 5} {incr i} {
109 mi_expect_interrupt "inferior 2, interrupt $i"
110 }
111
112 mi_check_thread_states {
113 "stopped" "stopped" "stopped" "stopped" "stopped"
114 "stopped" "stopped" "stopped" "stopped" "stopped"
115 } "after interrupting inferior 2"
116 } else {
117 mi_check_thread_states {
118 "stopped" "stopped" "stopped" "stopped" "stopped"
119 } "after interrupting inferior 1"
120 }