* thread.c (do_restore_current_thread_cleanup): Redo test for
[external/binutils.git] / gdb / testsuite / gdb.mi / mi-nonstop-exit.exp
1 # Copyright 2009
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # This only works with native configurations
18 if {![isnative]} {
19   return
20 }
21
22 load_lib mi-support.exp
23 set MIFLAGS "-i=mi"
24
25 gdb_exit
26 if {[mi_gdb_start]} {
27     continue
28 }
29
30 #
31 # Start here
32 #
33 set testfile "non-stop-exit"
34 set srcfile "$testfile.c"
35 set binfile "$objdir/$subdir/mi-$testfile"
36
37 set options [list debug incdir=$objdir]
38 if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
39     return -1
40 }
41
42 mi_gdb_reinitialize_dir $srcdir/$subdir
43 mi_gdb_load $binfile
44
45 set supported 0
46 send_gdb "-gdb-show non-stop\n"
47 gdb_expect {
48     -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
49         if { $expect_out(1,string) == "1" } {
50             set supported 1
51         }
52     }
53     -re ".$mi_gdb_prompt$" {
54     }
55 }
56
57 mi_gdb_test "-gdb-set non-stop 1" ".*"
58 mi_gdb_test "-gdb-set target-async 1" ".*"
59 detect_async
60
61 mi_gdb_test "200-break-insert -t main" ".*"
62
63 set created "=thread-created,id=\"$decimal\"\r\n"
64 set running "\\*running,thread-id=\"$decimal\"\r\n"
65
66 set notifs "($created)*($running)*($library_loaded_re)*"
67
68 # Note: presently, we skip this test on non-native targets,
69 # so 'run' is OK.  As soon as we start to run this on remote
70 # target, the logic from mi_run_cmd will have to be refactored.
71 send_gdb "-exec-run\n"
72 gdb_expect {
73     -re "\\^running\r\n$notifs$mi_gdb_prompt" {
74     }
75     -re "\\^error,msg=\"The target does not support running in non-stop mode.\"" {
76         verbose -log "Non-stop mode not supported, skipping all tests"
77         return
78     }
79     -re "\r\n$mi_gdb_prompt" {
80         perror "Cannot start target (unknown output after running)"
81         return -1
82     }
83     timeout {
84         perror "Cannot start target (timeout)"
85         return -1
86     }
87 }
88 mi_expect_stop "breakpoint-hit" main ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "run to main"
89
90 mi_send_resuming_command "exec-continue" "continue"
91
92 mi_expect_stop "exited-normally" "" "" "" "" "" "finished exec continue"
93
94 # Run the program again.
95
96 mi_gdb_test "200-break-insert -t main" ".*"
97
98 mi_send_resuming_command "exec-run" "run (2)"
99
100 mi_expect_stop "breakpoint-hit" main ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "run to main (2)"
101
102 mi_send_resuming_command "exec-continue" "continue (2)"
103
104 mi_expect_stop "exited-normally" "" "" "" "" "" "finished exec continue (2)"
105
106 mi_gdb_exit