* mi/mi-interp.c (mi_solib_loaded, mi_solib_unloaded): New.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-nsintrall.exp
CommitLineData
0fb0cc75 1# Copyright 2008, 2009 Free Software Foundation, Inc.
1ad15515
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# This only works with native configurations
17if {![isnative]} {
18 return
19}
20
21load_lib mi-support.exp
22set MIFLAGS "-i=mi"
23
24gdb_exit
25if {[mi_gdb_start]} {
26 continue
27}
28
29#
30# Start here
31#
32set testfile "nsintrall"
33set srcfile "$testfile.c"
34set binfile "$objdir/$subdir/mi-$testfile"
35
36set options [list debug incdir=$objdir]
37if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
38 return -1
39}
40
41mi_gdb_reinitialize_dir $srcdir/$subdir
42mi_gdb_load $binfile
43
44set supported 0
45send_gdb "-gdb-show non-stop\n"
46gdb_expect {
47 -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
48 if { $expect_out(1,string) == "1" } {
49 set supported 1
50 }
51 }
52 -re ".$mi_gdb_prompt$" {
53 }
54}
55
56mi_gdb_test "-gdb-set non-stop 1" ".*"
57mi_gdb_test "-gdb-set target-async 1" ".*"
58detect_async
59
60mi_gdb_test "200-break-insert -t main" ".*"
61
62set created "=thread-created,id=\"$decimal\"\r\n"
63set running "\\*running,thread-id=\"$decimal\"\r\n"
64
c86cf029 65set notifs "($created)*($running)*($library_loaded_re)*"
1ad15515
PA
66
67# Note: presently, we skip this test on non-native targets,
68# so 'run' is OK. As soon as we start to run this on remote
69# target, the logic from mi_run_cmd will have to be refactored.
70send_gdb "-exec-run\n"
71gdb_expect {
72 -re "\\^running\r\n$notifs$mi_gdb_prompt" {
73 }
74 -re "\\^error,msg=\"The target does not support running in non-stop mode.\"" {
75 verbose -log "Non-stop mode not supported, skipping all tests"
76 return
77 }
78 -re "\r\n$mi_gdb_prompt" {
79 perror "Cannot start target (unknown output after running)"
80 return -1
81 }
82 timeout {
83 perror "Cannot start target (timeout)"
84 return -1
85 }
86}
87mi_expect_stop "breakpoint-hit" main ".*" ".*" "\[0-9\]+" \
88 { "" "disp=\"del\"" } "run to main"
89
90mi_create_breakpoint thread_function 2 keep thread_function .* .* .* \
91 "breakpoint at thread_function"
92
93mi_send_resuming_command "exec-continue --all" "resume all"
94for {set i 0} {$i < 6} {incr i} {
95 mi_expect_stop "breakpoint-hit" "thread_function" "\[^\n\]*" "$srcfile" \
96 "\[0-9\]*" {"" "disp=\"keep\""} "stop $i"
97}
98
99mi_check_thread_states \
100 {"stopped" "stopped" "stopped" "stopped" "stopped" "stopped"} \
101 "thread state, all stopped"
102
103# now that we know about all the threads, we can get rid of the breakpoints
104mi_delete_breakpoints
105
106set running_re ""
107for {set i 6} {$i > 0} {incr i -1} {
108 set running_re "$running_re\\*running,thread-id=\"$i\"\r\n"
109}
110
111send_gdb "-exec-continue --all\n"
112gdb_expect {
113 -re ".*$running_re$mi_gdb_prompt" {
114 pass "resume all, no breakpoint"
115 }
116 timeout {
117 fail "resume all, no breakpoint (timeout)"
118 }
119}
120mi_check_thread_states \
121 {"running" "running" "running" "running" "running" "running"} \
122 "thread state, resume all"
123
124mi_gdb_test "200-exec-interrupt --all" "200\\^done" "interrupt all threads"
125
126for {set i 0} {$i < 6} {incr i} {
127 mi_expect_interrupt "interrupt $i"
128}
129mi_check_thread_states \
130 {"stopped" "stopped" "stopped" "stopped" "stopped" "stopped"} \
131 "thread state, all interrupted"
132
133# resume all threads, and check that no thread is spuriously left interrupted
134send_gdb "-exec-continue --all\n"
135gdb_expect {
136 -re ".*$running_re$mi_gdb_prompt" {
137 pass "resume all after interrupting"
138 }
139 timeout {
140 fail "resume all after interrupting (timeout)"
141 }
142}
143
144sleep 1
145mi_check_thread_states \
146 {"running" "running" "running" "running" "running" "running"} \
147 "thread state, resume all after interrupting"
148
149mi_gdb_exit
This page took 0.068779 seconds and 4 git commands to generate.