]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-nsthrexec.exp
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-nsthrexec.exp
CommitLineData
1d506c26 1# Copyright 2009-2024 Free Software Foundation, Inc.
a75724bc
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
16# Test that when a thread other than the main thread execs, and the
17# main thread was stopped due to user request, the new incarnation of
18# the main thread doesn't just silently stop at the first internal
19# breakpoint (usually the _dl_debug_state breakpoint).
20
0a7043e0 21require support_displaced_stepping
d5b4a7be 22
a75724bc
PA
23load_lib mi-support.exp
24set MIFLAGS "-i=mi"
25
a75724bc
PA
26#
27# Start here
28#
298a9cf0 29standard_testfile nsthrexec.c
a75724bc 30
298a9cf0 31set options [list debug]
a75724bc
PA
32if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
33 return -1
34}
35
7cb2893d
SM
36save_vars { GDBFLAGS } {
37 append GDBFLAGS " -ex \"set non-stop on\""
38 mi_clean_restart $binfile
39}
a75724bc 40
329ea579 41mi_gdb_test "-gdb-set mi-async 1" ".*"
fcdfa280 42mi_detect_async
a75724bc 43
b75d55d4 44if { [mi_runto_main] < 0 } {
cdd42066 45 return
a75724bc
PA
46}
47
4b48d439
KS
48mi_create_breakpoint thread_execler \
49 "breakpoint at thread_execler" \
50 -number 2 -function thread_execler
a75724bc
PA
51
52# All threads should stop, except the main thread.
53mi_send_resuming_command "exec-continue --all" "resume all"
54mi_expect_stop "breakpoint-hit" "thread_execler" "\[^\n\]*" "$srcfile" \
55 "\[0-9\]*" {"" "disp=\"keep\""} "stop at thread_execler"
56
57mi_check_thread_states \
58 {"running" "stopped"} \
59 "thread state, execler stopped, main running"
60
61mi_gdb_test "200-exec-interrupt --thread 1" "200\\^done" "interrupt main thread"
62mi_expect_interrupt "main thread interrupted"
63
64mi_check_thread_states {"stopped" "stopped"} "thread state, all stopped"
65
66# now that we know about all the threads, we can get rid of the breakpoints
67mi_delete_breakpoints
68
4b48d439 69mi_create_breakpoint main \
b4130189 70 "insert breakpoint at main" \
4b48d439
KS
71 -number 3 -func main
72
a75724bc
PA
73
74# Now resume the execler thread. Eventually, it execs.
75mi_send_resuming_command "exec-continue --thread 2" "resume execler thread"
76
77# Check that the main thread passes by the _dl_debug_state internal
78# breakpoint without silently stopping.
79mi_expect_stop "breakpoint-hit" "main" "\[^\n\]*" "$srcfile" \
80 "\[0-9\]*" {"" "disp=\"keep\""} "stop at main after exec"
81
82mi_gdb_exit