Commit | Line | Data |
---|---|---|
a75724bc PA |
1 | # Copyright 2009 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 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 | ||
21 | # No exec event support in the remote protocol. | |
22 | if { [is_remote target] } then { | |
23 | continue | |
24 | } | |
25 | ||
26 | load_lib mi-support.exp | |
27 | set MIFLAGS "-i=mi" | |
28 | ||
29 | gdb_exit | |
30 | if {[mi_gdb_start]} { | |
31 | continue | |
32 | } | |
33 | ||
34 | # | |
35 | # Start here | |
36 | # | |
37 | set testfile "nsthrexec" | |
38 | set srcfile "$testfile.c" | |
39 | set binfile "$objdir/$subdir/mi-$testfile" | |
40 | ||
41 | set options [list debug incdir=$objdir] | |
42 | if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { | |
43 | return -1 | |
44 | } | |
45 | ||
46 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
47 | mi_gdb_load $binfile | |
48 | ||
49 | set supported 0 | |
50 | send_gdb "-gdb-show non-stop\n" | |
51 | gdb_expect { | |
52 | -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" { | |
53 | if { $expect_out(1,string) == "1" } { | |
54 | set supported 1 | |
55 | } | |
56 | } | |
57 | -re ".$mi_gdb_prompt$" { | |
58 | } | |
59 | } | |
60 | ||
61 | mi_gdb_test "-gdb-set non-stop 1" ".*" | |
62 | mi_gdb_test "-gdb-set target-async 1" ".*" | |
63 | detect_async | |
64 | ||
65 | if { [mi_run_to_main] < 0 } { | |
66 | perror "mi-nsthrexec.exp tests suppressed" | |
67 | continue | |
68 | } | |
69 | ||
70 | mi_create_breakpoint thread_execler 2 keep thread_execler .* .* .* \ | |
71 | "breakpoint at thread_execler" | |
72 | ||
73 | # All threads should stop, except the main thread. | |
74 | mi_send_resuming_command "exec-continue --all" "resume all" | |
75 | mi_expect_stop "breakpoint-hit" "thread_execler" "\[^\n\]*" "$srcfile" \ | |
76 | "\[0-9\]*" {"" "disp=\"keep\""} "stop at thread_execler" | |
77 | ||
78 | mi_check_thread_states \ | |
79 | {"running" "stopped"} \ | |
80 | "thread state, execler stopped, main running" | |
81 | ||
82 | mi_gdb_test "200-exec-interrupt --thread 1" "200\\^done" "interrupt main thread" | |
83 | mi_expect_interrupt "main thread interrupted" | |
84 | ||
85 | mi_check_thread_states {"stopped" "stopped"} "thread state, all stopped" | |
86 | ||
87 | # now that we know about all the threads, we can get rid of the breakpoints | |
88 | mi_delete_breakpoints | |
89 | ||
90 | mi_create_breakpoint main 3 keep main .* .* .* \ | |
91 | "breakpoint at main" | |
92 | ||
93 | # Now resume the execler thread. Eventually, it execs. | |
94 | mi_send_resuming_command "exec-continue --thread 2" "resume execler thread" | |
95 | ||
96 | # Check that the main thread passes by the _dl_debug_state internal | |
97 | # breakpoint without silently stopping. | |
98 | mi_expect_stop "breakpoint-hit" "main" "\[^\n\]*" "$srcfile" \ | |
99 | "\[0-9\]*" {"" "disp=\"keep\""} "stop at main after exec" | |
100 | ||
101 | mi_gdb_exit |