Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: gdb/testsuite/gdb.threads/attachstop-mt.exp

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/testsuite/gdb.threads/attachstop-mt.c ('k') | gdb/testsuite/gdb.threads/bp_in_thread.exp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2008-2012 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 # This test is based on gdb.base/attach.exp with modifications by Jeff Johnston
17 # <jjohnstn@redhat.com> and Jan Kratochvil <jan.kratochvil@redhat.com>.
18
19 # This test only works on Linux
20 if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub]
21 || ![istarget *-linux*] } {
22 continue
23 }
24
25 set testfile "attachstop-mt"
26 set srcfile ${testfile}.c
27 set binfile ${objdir}/${subdir}/${testfile}
28 set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
29
30 #execute_anywhere "rm -f ${binfile}"
31 remote_exec build "rm -f ${binfile}"
32 # For debugging this test
33 #
34 #log_user 1
35
36 # build the test case
37 #
38 if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" execut able {debug}] != "" } {
39 untested attachstop-mt.exp
40 return -1
41 }
42
43 if [get_compiler_info ${binfile}] {
44 return -1
45 }
46
47 # Start the program running and then wait for a bit, to be sure
48 # that it can be attached to.
49
50 set testpid [eval exec $binfile &]
51
52 # No race
53 sleep 2
54
55 # The testcase has three threads, find some other thread TID for $testpid2.
56 set tids [exec sh -c "echo /proc/$testpid/task/*"]
57 regsub -all /proc/$testpid/task/ $tids {} tids
58 if {$tids == "*"} {
59 unresolved "/proc/PID/task is not supported (kernel-2.4?)"
60 remote_exec build "kill -9 ${testpid}"
61 return -1
62 }
63 set tids [lsort -integer [split $tids]]
64 if {[llength $tids] != 3 || [lindex $tids 0] != $testpid} {
65 verbose -log "Invalid TIDs <$tids> for PID $testpid"
66 fail "Invalid TIDs found"
67 remote_exec build "kill -9 ${testpid}"
68 return -1
69 }
70 set testpid2 [lindex $tids 2]
71
72 # Initial sanity test it is normally sleeping
73 set status2 /proc/${testpid}/task/${testpid2}/status
74 set fileid0 [open $status2 r];
75 gets $fileid0 line1;
76 gets $fileid0 line2;
77 close $fileid0;
78
79 set test "attach0, initial sanity check of the sleeping state"
80 if {[string match "*(sleeping)*" $line2]} {
81 pass $test
82 } else {
83 fail $test
84 }
85
86 # Sttach and detach to test it will not become stopped
87 gdb_start
88 gdb_reinitialize_dir $srcdir/$subdir
89 gdb_load ${binfile}
90
91 set test "attach0 to sleeping"
92 gdb_test_multiple "attach $testpid" "$test" {
93 -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_promp t $" {
94 pass "$test"
95 }
96 }
97
98 gdb_test "gcore /dev/null" ".*aved corefile.*" "attach0 to sleeping gcore invoca tion"
99
100 gdb_test "thread 2" ".*witching to thread 2 .*" "attach0 to sleeping switch thre ad"
101
102 gdb_test "bt" ".*sleep.*func.*" "attach0 to sleeping bt"
103
104 # Exit and detach the process.
105
106 gdb_exit
107
108 # No race
109 sleep 2
110
111 # Check it did not get stopped by our gdb
112 set fileid1 [open $status2 r];
113 gets $fileid1 line1;
114 gets $fileid1 line2;
115 close $fileid1;
116
117 set test "attach1, post-gdb sanity check of the sleeping state - Red Hat BZ 1975 84"
118 if {[string match "*(sleeping)*" $line2]} {
119 pass $test
120 } else {
121 fail $test
122 }
123
124 # Stop the program
125 remote_exec build "kill -s STOP ${testpid}"
126
127 # No race
128 sleep 2
129
130 # Check it really got stopped by kill(1)
131 set fileid2 [open $status2 r];
132 gets $fileid2 line1;
133 gets $fileid2 line2;
134 close $fileid2;
135
136 set test "attach2, initial sanity check of the stopped state"
137 if {[string match "*(stopped)*" $line2]} {
138 pass $test
139 } else {
140 fail $test
141 }
142
143 # Start with clean gdb
144 gdb_start
145 gdb_reinitialize_dir $srcdir/$subdir
146 gdb_load ${binfile}
147
148 # Verify that we can attach to the process by first giving its
149 # executable name via the file command, and using attach with the
150 # process ID.
151
152 set test "set file, before attach3 to stopped process"
153 gdb_test_multiple "file $binfile" "$test" {
154 -re "Load new symbol table from.*y or n. $" {
155 gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \
156 "$test (re-read)"
157 }
158 -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" {
159 pass "$test"
160 }
161 }
162
163 set test "attach3 to stopped, after setting file"
164 gdb_test_multiple "attach $testpid" "$test" {
165 -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_promp t $" {
166 pass "$test"
167 }
168 }
169
170 # We may be already after the threads phase.
171 # `thread 2' command is important for the test to switch the current thread to
172 # a non-primary one for the detach process.
173
174 gdb_test "thread 2" ".*(witching to thread 2 |hread ID 2 not known).*" "attach3 to stopped switch thread"
175 gdb_test "bt" ".*sleep.*(func|main).*" "attach3 to stopped bt"
176
177 # Exit and detach the process.
178 gdb_exit
179
180 # Stop the program
181 remote_exec build "kill -s STOP ${testpid}"
182
183 # No race
184 sleep 2
185
186 # Continue the test as we would hit another expected bug regarding
187 # Program received signal SIGSTOP, Stopped (signal).
188 # across NPTL threads.
189
190 gdb_start
191 gdb_reinitialize_dir $srcdir/$subdir
192 gdb_load ${binfile}
193
194 # Verify that we can attach to the process just by giving the
195 # process ID.
196
197 set test "attach4 to stopped, after setting file"
198 gdb_test_multiple "attach $testpid" "$test" {
199 -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_promp t $" {
200 pass "$test"
201 }
202 }
203
204 # We may be already after the threads phase.
205 # `thread 2' command is important for the test to switch the current thread to
206 # a non-primary one for the detach process.
207
208 gdb_test "thread 2" ".*(witching to thread 2 |hread ID 2 not known).*" "attach4 to stopped switch thread"
209 gdb_test "bt" ".*sleep.*(func|main).*" "attach4 to stopped bt"
210
211 # RHEL3U8 kernel-2.4.21-47.EL will not return SIGINT but only shorten the sleep.
212 gdb_breakpoint $srcfile:[gdb_get_line_number "Ridiculous time"]
213 gdb_breakpoint $srcfile:[gdb_get_line_number "cut the sleep time"]
214 set test "attach4 continue"
215 gdb_test_multiple "continue" "continue ($test)" {
216 -re "Continuing" {
217 pass "continue ($test)"
218 }
219 }
220
221 # For this to work we must be sure to consume the "Continuing."
222 # message first, or GDB's signal handler may not be in place.
223 after 1000 {send_gdb "\003"}
224 set test "attach4 stop by interrupt"
225 gdb_expect {
226 -re "Program received signal SIGINT.*$gdb_prompt $"
227 {
228 pass $test
229 }
230 -re "Breakpoint \[0-9\].*$srcfile.*$gdb_prompt $"
231 {
232 pass $test
233 }
234 timeout
235 {
236 fail "$test (timeout)"
237 }
238 }
239
240 gdb_exit
241
242 # No race
243 sleep 2
244
245 # At this point, the process should be sleeping
246
247 set fileid4 [open $status2 r];
248 gets $fileid4 line1;
249 gets $fileid4 line2;
250 close $fileid4;
251
252 set test "attach4, exit leaves process sleeping"
253 if {[string match "*(sleeping)*" $line2]} {
254 pass $test
255 } else {
256 fail $test
257 }
258
259 # Make sure we don't leave a process around to confuse
260 # the next test run (and prevent the compile by keeping
261 # the text file busy), in case the "set should_exit" didn't
262 # work.
263
264 remote_exec build "kill -9 ${testpid}"
265
266 return 0
OLDNEW
« no previous file with comments | « gdb/testsuite/gdb.threads/attachstop-mt.c ('k') | gdb/testsuite/gdb.threads/bp_in_thread.exp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698