* gdb.mi/mi-nonstop.exp: Don't check isnative. Use
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-nsmoribund.exp
CommitLineData
0fb0cc75 1# Copyright 2008, 2009 Free Software Foundation, Inc.
1c5cfe86
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
1c5cfe86
PA
16load_lib mi-support.exp
17set MIFLAGS "-i=mi"
18
19gdb_exit
20if {[mi_gdb_start]} {
21 continue
22}
23
24#
25# Start here
26#
27set testfile "nsmoribund"
28set srcfile "$testfile.c"
29set binfile "$objdir/$subdir/mi-$testfile"
30
31set options [list debug incdir=$objdir]
32if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
33 return -1
34}
35
36mi_gdb_reinitialize_dir $srcdir/$subdir
37mi_gdb_load $binfile
38
39set supported 0
40send_gdb "-gdb-show non-stop\n"
41gdb_expect {
42 -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
43 if { $expect_out(1,string) == "1" } {
44 set supported 1
45 }
46 }
47 -re ".$mi_gdb_prompt$" {
48 }
49}
50
51mi_gdb_test "-gdb-set non-stop 1" ".*"
52mi_gdb_test "-gdb-set target-async 1" ".*"
53detect_async
54
56a8e183
PA
55if { [mi_run_to_main] < 0 } {
56 perror "mi-nsmoribund.exp tests suppressed"
57 continue
1c5cfe86 58}
1c5cfe86
PA
59
60# Keep this in sync with THREADS in the the $srcfile.
61set nthreads 10
62
63# Set a breakpoint and let all threads hit it (except the main
64# thread).
65
66set bkpt_line [gdb_get_line_number "set breakpoint here"]
67
68mi_create_breakpoint "$srcfile:$bkpt_line" 2 keep thread_function .* .* .* \
69 "breakpoint at thread_function"
70
71mi_send_resuming_command "exec-continue --all" "resume all"
72for {set i 0} {$i < $nthreads} {incr i} {
73 mi_expect_stop "breakpoint-hit" "thread_function" "\[^\n\]*" "$srcfile" \
74 "\[0-9\]*" {"" "disp=\"keep\""} "stop $i"
75}
76
77# All but the main thread should have hit it.
78
79mi_check_thread_states \
80 {"running" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped" "stopped"} \
81 "thread state: all stopped except the main thread"
82
83# Select a stopped thread to make sure we're able to delete
84# breakpoints
85mi_gdb_test "-thread-select 5" "\\^done.*" "select thread 5"
86
87# Now that we know about all the threads, we can get rid of
88# breakpoint.
89mi_delete_breakpoints
90
91# Recreate the same breakpoint, but this time, specific to thread 5.
92mi_create_breakpoint "-p 5 $srcfile:$bkpt_line" 3 keep thread_function .* .* .* \
93 "thread specific breakpoint at thread_function"
94
95# Resume all threads. Only thread 5 should report a stop.
96
97set running_re ""
98for {set i $nthreads} {$i > 0} {incr i -1} {
99 set running_re "$running_re\\*running,thread-id=\"$decimal\"\r\n"
100}
101
102send_gdb "-exec-continue --all\n"
103gdb_expect {
104 -re ".*$running_re$mi_gdb_prompt" {
105 pass "resume all, thread specific breakpoint"
106 }
107 timeout {
108 fail "resume all, thread specific breakpoint (timeout)"
109 }
110}
111
112mi_expect_stop "breakpoint-hit" "thread_function" "\[^\n\]*" "$srcfile" \
113 "\[0-9\]*" {"" "disp=\"keep\""} "hit thread specific breakpoint"
114
115# All threads except both thread 5 (and the main thread) should now be
116# repeatedly hitting the thread specific breakpoint and stepping over
117# it transparently. These are internal events, so the frontend should
118# see those threads as running.
119
120mi_check_thread_states \
121 {"running" "running" "running" "running" "stopped" "running" "running" "running" "running"} \
122 "thread state: all running except the breakpoint thread"
123
124# Get rid of the breakpoint while the other threads are stepping over
125# it, and tell all threads to exit. The program should exit
126# gracefully shortly. Send all commands in a row, since if something
127# goes wrong with moribund locations support or displaced stepping (or
128# a target bug if it can step over breakpoints itself), a spurious
129# SIGTRAP/SIGSEGV can come at any time after deleting the breakpoint.
130
131send_gdb "102-break-delete\n"
132send_gdb "print done = 1\n"
133send_gdb "103-exec-continue --all\n"
134
135gdb_expect {
136 -re "\\*stopped,reason=\"exited-normally\"" {
137 pass "resume all, program exited normally"
138 }
139 -re "\\*stopped" {
140 fail "unexpected stop"
141 }
142 timeout {
143 fail "resume all, waiting for program exit (timeout)"
144 }
145}
146
147mi_gdb_exit
This page took 0.069169 seconds and 4 git commands to generate.