]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-6.3-step-thread-exit-20050211-test.patch
- update to gdb-7.0-7.fc12.src.rpm; but leave cactus patches as these seem newer
[packages/gdb.git] / gdb-6.3-step-thread-exit-20050211-test.patch
CommitLineData
3a58abaf
AM
12005-02-11 Jeff Johnston <jjohnstn@redhat.com>
2
3 * testsuite/gdb.threads/step-thread-exit.c: New testcase.
4 * testsuite/gdb.threads/step-thread-exit.exp: Ditto.
5
6Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.c
7===================================================================
8--- /dev/null 1970-01-01 00:00:00.000000000 +0000
9+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.c 2008-12-08 22:21:26.000000000 +0100
10@@ -0,0 +1,50 @@
11+/* This testcase is part of GDB, the GNU debugger.
12+
13+ Copyright 2005 Free Software Foundation, Inc.
14+
15+ This program is free software; you can redistribute it and/or modify
16+ it under the terms of the GNU General Public License as published by
17+ the Free Software Foundation; either version 2 of the License, or
18+ (at your option) any later version.
19+
20+ This program is distributed in the hope that it will be useful,
21+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+ GNU General Public License for more details.
24+
25+ You should have received a copy of the GNU General Public License
26+ along with this program; if not, write to the Free Software
27+ Foundation, Inc., 59 Temple Place - Suite 330,
28+ Boston, MA 02111-1307, USA. */
29+
30+#include <pthread.h>
31+#include <stdio.h>
32+#include <stdlib.h>
33+#include <unistd.h>
34+
35+void *thread_function (void *ptr)
36+{
37+ int *x = (int *)ptr;
38+ printf("In thread_function, *x is %d\n", *x);
39+} /* thread_function_end */
40+
41+volatile int repeat = 0;
42+
43+main()
44+{
45+ int ret;
46+ pthread_t th;
47+ int i = 3;
48+
49+ ret = pthread_create (&th, NULL, thread_function, &i);
50+ do
51+ {
52+ repeat = 0;
53+ sleep (3); /* sleep */
54+ }
55+ while (repeat);
56+ pthread_join (th, NULL);
57+ return 0;
58+}
59+
60+
61Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.exp
62===================================================================
63--- /dev/null 1970-01-01 00:00:00.000000000 +0000
64+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/step-thread-exit.exp 2008-12-08 22:22:14.000000000 +0100
65@@ -0,0 +1,130 @@
66+# This testcase is part of GDB, the GNU debugger.
67+
68+# Copyright 2005 Free Software Foundation, Inc.
69+
70+# This program is free software; you can redistribute it and/or modify
71+# it under the terms of the GNU General Public License as published by
72+# the Free Software Foundation; either version 2 of the License, or
73+# (at your option) any later version.
74+#
75+# This program is distributed in the hope that it will be useful,
76+# but WITHOUT ANY WARRANTY; without even the implied warranty of
77+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78+# GNU General Public License for more details.
79+#
80+# You should have received a copy of the GNU General Public License
81+# along with this program; if not, write to the Free Software
82+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
83+
84+# Check that GDB can step over a thread exit.
85+
86+if $tracelevel {
87+ strace $tracelevel
88+}
89+
90+set prms_id 0
91+set bug_id 0
92+
93+set testfile "step-thread-exit"
94+set srcfile ${testfile}.c
95+set binfile ${objdir}/${subdir}/${testfile}
96+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
97+ return -1
98+}
99+
100+gdb_exit
101+gdb_start
102+gdb_reinitialize_dir $srcdir/$subdir
103+gdb_load ${binfile}
104+
105+# Reset the debug file directory so we can't debug within the C library
106+gdb_test "set debug-file-directory ." "" ""
107+
108+#
109+# Run to `main' where we begin our tests.
110+#
111+
112+if ![runto_main] then {
113+ gdb_suppress_tests
114+}
115+
116+# FIXME: Currently the main thread will escape/exit before our thread finishes
117+# without this setting.
118+gdb_test "set scheduler-locking step"
119+gdb_test "show scheduler-locking" "Mode for locking scheduler during execution is \"step\"." "check scheduler-locking first"
120+
121+set sleep_line [expr [gdb_get_line_number "sleep"]]
122+set end_line [expr [gdb_get_line_number "thread_function_end"]]
123+
124+gdb_breakpoint "$end_line"
125+gdb_test "continue" "Break.*thread_function.*" "continue to thread_function 1"
126+
127+# Keep nexting until we cause the thread to exit. We expect the main
128+# thread to be stopped and a message printed to tell us we have stepped
129+# over the thread exit.
130+set test "step over thread exit 1"
131+gdb_test_multiple "next" "$test" {
132+ -re "\}.*$gdb_prompt $" {
133+ send_gdb "next\n"
134+ exp_continue
135+ }
136+ -re "\[Thread .* exited\].*Program received signal SIGSTOP.*$gdb_prompt $" {
137+ pass "$test"
138+ }
139+ -re "start_thread.*$gdb_prompt $" {
140+ send_gdb "next\n"
141+ exp_continue
142+ }
143+}
144+
145+# Without this fixup we could end up in:
146+# #0 0x00110416 in __kernel_vsyscall ()
147+# #1 0x0011de26 in __lll_unlock_wake_private () from /lib/libpthread.so.0
148+# #2 0x001179f4 in _L_unlock_3164 () from /lib/libpthread.so.0
149+# #3 0x00116f01 in pthread_create@@GLIBC_2.1 () from /lib/libpthread.so.0
150+# #4 0x08048531 in main () at ../.././gdb/testsuite/gdb.threads/step-thread-exit.c:39
151+gdb_breakpoint "$sleep_line"
152+gdb_test "set repeat=1" "" "Get to the sleep function prepare 1"
153+gdb_test "continue" "Break.*$sleep_line.*" "Get to the sleep function 1"
154+
155+gdb_test "bt" "main.*$sleep_line.*" "backtrace after step 1"
156+
157+runto_main
158+gdb_test "show scheduler-locking" "Mode for locking scheduler during execution is \"step\"." "check scheduler-locking second"
159+
160+gdb_breakpoint "$sleep_line"
161+gdb_breakpoint "$end_line"
162+set test "continue to thread_function 2"
163+gdb_test_multiple "continue" "$test" {
164+ -re "Break.*thread_function.*$gdb_prompt $" {
165+ pass $test
166+ }
167+ -re "Break.*$sleep_line.*$gdb_prompt $" {
168+ gdb_test "set repeat=1" "" ""
169+ send_gdb "continue\n"
170+ exp_continue
171+ }
172+}
173+
174+# Keep nexting until we cause the thread to exit. In this case, we
175+# expect the breakpoint in the main thread to have already triggered
176+# and so we should stop there with a message that we stepped over
177+# the thread exit.
178+set test "step over thread exit 2"
179+gdb_test_multiple "next" "$test" {
180+ -re "\}.*$gdb_prompt $" {
181+ send_gdb "next\n"
182+ exp_continue
183+ }
184+ -re "\[Thread .* exited\].*Break.*$sleep_line.*$gdb_prompt $" {
185+ pass "$test (breakpoint hit)"
186+ }
187+ -re "\[Thread .* exited\].*$gdb_prompt $" {
188+ pass "$test (breakpoint not hit)"
189+ }
190+ -re "start_thread.*$gdb_prompt $" {
191+ send_gdb "next\n"
192+ exp_continue
193+ }
194+}
195+
This page took 0.424628 seconds and 4 git commands to generate.