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

Side by Side Diff: gdb/testsuite/gdb.threads/attach-stopped.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
OLDNEW
1 # Copyright 2008-2012 Free Software Foundation, Inc. 1 # Copyright 2008-2012 Free Software Foundation, Inc.
2 2
3 # This program is free software; you can redistribute it and/or modify 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 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 5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version. 6 # (at your option) any later version.
7 # 7 #
8 # This program is distributed in the hope that it will be useful, 8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 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/>. 14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 15
16 # This test was created by modifying attach.exp. 16 # This test was created by modifying attach.exp.
17 # This file was created by Jeff Johnston <jjohnstn@redhat.com>. 17 # This file was created by Jeff Johnston <jjohnstn@redhat.com>.
18 # This file was updated by Jan Kratochvil <jan.kratochvil@redhat.com>. 18 # This file was updated by Jan Kratochvil <jan.kratochvil@redhat.com>.
19 19
20 # This test only works on Linux 20 # This test only works on Linux
21 if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub] 21 if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub]
22 || ![istarget *-linux*] } { 22 || ![istarget *-linux*] } {
23 continue 23 continue
24 } 24 }
25 25
26 set testfile "attach-stopped" 26 standard_testfile
27 set srcfile ${testfile}.c 27 set escapedbinfile [string_to_regexp $binfile]
28 set binfile ${objdir}/${subdir}/${testfile}
29 set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
30 28
31 #execute_anywhere "rm -f ${binfile}" 29 #execute_anywhere "rm -f ${binfile}"
32 remote_exec build "rm -f ${binfile}" 30 remote_exec build "rm -f ${binfile}"
33 # For debugging this test 31 # For debugging this test
34 # 32 #
35 #log_user 1 33 #log_user 1
36 34
37 proc corefunc { threadtype } { 35 proc corefunc { threadtype } {
38 global srcfile 36 global srcfile
39 global binfile 37 global binfile
40 global escapedbinfile 38 global escapedbinfile
41 global srcdir 39 global srcdir
42 global subdir 40 global subdir
43 global gdb_prompt 41 global gdb_prompt
44 42
45 if [get_compiler_info ${binfile}] { 43 if [get_compiler_info] {
46 return -1 44 return -1
47 } 45 }
48 46
49 # Start the program running and then wait for a bit, to be sure 47 # Start the program running and then wait for a bit, to be sure
50 # that it can be attached to. 48 # that it can be attached to.
51 49
52 set testpid [eval exec $binfile &] 50 set testpid [eval exec $binfile &]
53 51
54 # Avoid some race: 52 # Avoid some race:
55 sleep 2 53 sleep 2
(...skipping 15 matching lines...) Expand all
71 pass "$test" 69 pass "$test"
72 } 70 }
73 } 71 }
74 72
75 # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there. 73 # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there.
76 if {[string equal $threadtype threaded]} { 74 if {[string equal $threadtype threaded]} {
77 gdb_test "thread apply all bt" ".*sleep.*start_thread.*" "$threadtype: a ttach2 to stopped bt" 75 gdb_test "thread apply all bt" ".*sleep.*start_thread.*" "$threadtype: a ttach2 to stopped bt"
78 } else { 76 } else {
79 gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach2 to stopped bt" 77 gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach2 to stopped bt"
80 } 78 }
81 # This breakpoint is there for old/non-x86 kernels not restarting syscalls.
82 gdb_breakpoint $srcfile:[gdb_get_line_number "Second sleep"]
83 set test "$threadtype: attach2 continue"
84 gdb_test_multiple "continue" "continue ($test)" {
85 -re "Continuing" {
86 pass "continue ($test)"
87 }
88 }
89
90 # For this to work we must be sure to consume the "Continuing."
91 # message first, or GDB's signal handler may not be in place.
92 after 1000 {send_gdb "\003"}
93 set test "$threadtype: attach2 stop interrupt"
94 gdb_expect 10 {
95 -re "Program received signal SIGINT.*$gdb_prompt $"
96 {
97 pass $test
98 }
99 -re "Breakpoint \[0-9\].*$srcfile.*$gdb_prompt $"
100 {
101 pass $test
102 }
103 timeout
104 {
105 fail $test
106 }
107 }
108 79
109 gdb_exit 80 gdb_exit
110 81
111 # Avoid some race: 82 # Avoid some race:
112 sleep 2 83 sleep 2
113 84
114 # At this point, the process should be sleeping 85 # At this point, the process may be sleeping or T (Stopped) depending on
86 # the Linux kernel version. The behavior is not tested as it is not
87 # dependent on GDB.
115 88
116 if [catch {open /proc/${testpid}/status r} fileid2] {
117 set line2 "NOTFOUND"
118 } else {
119 gets $fileid2 line1;
120 gets $fileid2 line2;
121 close $fileid2;
122 }
123
124 set test "$threadtype: attach2, exit leaves process sleeping"
125 if {[string match "*(sleeping)*" $line2]} {
126 pass $test
127 } else {
128 fail $test
129 }
130
131 # Make sure we don't leave a process around to confuse
132 # the next test run (and prevent the compile by keeping
133 # the text file busy), in case the "set should_exit" didn't
134 # work.
135
136 remote_exec build "kill -9 ${testpid}" 89 remote_exec build "kill -9 ${testpid}"
137 } 90 }
138 91
139 # build the test case first without threads 92 # build the test case first without threads
140 # 93 #
141 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb ug}] != "" } { 94 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb ug}] != "" } {
142 untested "attach-stopped.exp (unthreaded)" 95 untested "attach-stopped.exp (unthreaded)"
143 return -1 96 return -1
144 } 97 }
145 98
146 corefunc nonthreaded 99 corefunc nonthreaded
147 100
148 # build the test case first without threads 101 # build the test case first without threads
149 # 102 #
150 if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" execut able {debug additional_flags=-DUSE_THREADS}] != "" } { 103 if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" execut able {debug additional_flags=-DUSE_THREADS}] != "" } {
151 untested "attach-stopped.exp (threaded)" 104 untested "attach-stopped.exp (threaded)"
152 return -1 105 return -1
153 } 106 }
154 107
155 corefunc threaded 108 corefunc threaded
156 109
157 return 0 110 return 0
OLDNEW
« no previous file with comments | « gdb/testsuite/gdb.threads/attach-into-signal.exp ('k') | gdb/testsuite/gdb.threads/attachstop-mt.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698