]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
- update to gdb-7.0-7.fc12.src.rpm; but leave cactus patches as these seem newer
[packages/gdb.git] / gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
CommitLineData
3a58abaf
AM
12007-06-25 Jan Kratochvil <jan.kratochvil@redhat.com>
2
3 * gdb.threads/atomic-seq-threaded.c,
4 gdb.threads/atomic-seq-threaded.exp: New files.
5
6Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.c
7===================================================================
8--- /dev/null 1970-01-01 00:00:00.000000000 +0000
9+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.c 2008-12-08 22:27:01.000000000 +0100
10@@ -0,0 +1,171 @@
11+/* This testcase is part of GDB, the GNU debugger.
12+
13+ Copyright 2007 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., 51 Franklin Street, Fifth Floor, Boston,
28+ MA 02110-1301, USA. */
29+
30+/* Test stepping over RISC atomic sequences.
31+ This variant testcases the code for stepping another thread while skipping
32+ over the atomic sequence in the former thread
33+ (STEPPING_PAST_SINGLESTEP_BREAKPOINT).
34+ Code comes from gcc/testsuite/gcc.dg/sync-2.c */
35+
36+/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
37+/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */
38+
39+/* Test functionality of the intrinsics for 'short' and 'char'. */
40+
41+#include <stdlib.h>
42+#include <string.h>
43+#include <pthread.h>
44+#include <assert.h>
45+#include <unistd.h>
46+
47+#define LOOPS 2
48+
49+static int unused;
50+
51+static char AI[18];
52+static char init_qi[18] = { 3,5,7,9,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 };
53+static char test_qi[18] = { 3,5,7,9,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 };
54+
55+static void
56+do_qi (void)
57+{
58+ if (__sync_fetch_and_add(AI+4, 1) != 0)
59+ abort ();
60+ if (__sync_fetch_and_add(AI+5, 4) != 0)
61+ abort ();
62+ if (__sync_fetch_and_add(AI+6, 22) != 0)
63+ abort ();
64+ if (__sync_fetch_and_sub(AI+7, 12) != 0)
65+ abort ();
66+ if (__sync_fetch_and_and(AI+8, 7) != (char)-1)
67+ abort ();
68+ if (__sync_fetch_and_or(AI+9, 8) != 0)
69+ abort ();
70+ if (__sync_fetch_and_xor(AI+10, 9) != 0)
71+ abort ();
72+ if (__sync_fetch_and_nand(AI+11, 7) != 0)
73+ abort ();
74+
75+ if (__sync_add_and_fetch(AI+12, 1) != 1)
76+ abort ();
77+ if (__sync_sub_and_fetch(AI+13, 12) != (char)-12)
78+ abort ();
79+ if (__sync_and_and_fetch(AI+14, 7) != 7)
80+ abort ();
81+ if (__sync_or_and_fetch(AI+15, 8) != 8)
82+ abort ();
83+ if (__sync_xor_and_fetch(AI+16, 9) != 9)
84+ abort ();
85+ if (__sync_nand_and_fetch(AI+17, 7) != 7)
86+ abort ();
87+}
88+
89+static short AL[18];
90+static short init_hi[18] = { 3,5,7,9,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 };
91+static short test_hi[18] = { 3,5,7,9,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 };
92+
93+static void
94+do_hi (void)
95+{
96+ if (__sync_fetch_and_add(AL+4, 1) != 0)
97+ abort ();
98+ if (__sync_fetch_and_add(AL+5, 4) != 0)
99+ abort ();
100+ if (__sync_fetch_and_add(AL+6, 22) != 0)
101+ abort ();
102+ if (__sync_fetch_and_sub(AL+7, 12) != 0)
103+ abort ();
104+ if (__sync_fetch_and_and(AL+8, 7) != -1)
105+ abort ();
106+ if (__sync_fetch_and_or(AL+9, 8) != 0)
107+ abort ();
108+ if (__sync_fetch_and_xor(AL+10, 9) != 0)
109+ abort ();
110+ if (__sync_fetch_and_nand(AL+11, 7) != 0)
111+ abort ();
112+
113+ if (__sync_add_and_fetch(AL+12, 1) != 1)
114+ abort ();
115+ if (__sync_sub_and_fetch(AL+13, 12) != -12)
116+ abort ();
117+ if (__sync_and_and_fetch(AL+14, 7) != 7)
118+ abort ();
119+ if (__sync_or_and_fetch(AL+15, 8) != 8)
120+ abort ();
121+ if (__sync_xor_and_fetch(AL+16, 9) != 9)
122+ abort ();
123+ if (__sync_nand_and_fetch(AL+17, 7) != 7)
124+ abort ();
125+}
126+
127+static void *
128+start1 (void *arg)
129+{
130+ unsigned loop;
131+ sleep(1);
132+
133+ for (loop = 0; loop < LOOPS; loop++)
134+ {
135+ memcpy(AI, init_qi, sizeof(init_qi));
136+
137+ do_qi ();
138+
139+ if (memcmp (AI, test_qi, sizeof(test_qi)))
140+ abort ();
141+ }
142+
143+ return arg; /* _delete1_ */
144+}
145+
146+static void *
147+start2 (void *arg)
148+{
149+ unsigned loop;
150+
151+ for (loop = 0; loop < LOOPS; loop++)
152+ {
153+ memcpy(AL, init_hi, sizeof(init_hi));
154+
155+ do_hi ();
156+
157+ if (memcmp (AL, test_hi, sizeof(test_hi)))
158+ abort ();
159+ }
160+
161+ return arg; /* _delete2_ */
162+}
163+
164+int
165+main (int argc, char **argv)
166+{
167+ pthread_t thread;
168+ int i;
169+
170+ i = pthread_create (&thread, NULL, start1, NULL); /* _create_ */
171+ assert (i == 0); /* _create_after_ */
172+
173+ sleep (1);
174+
175+ start2 (NULL);
176+
177+ i = pthread_join (thread, NULL); /* _delete_ */
178+ assert (i == 0);
179+
180+ return 0; /* _exit_ */
181+}
182Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.exp
183===================================================================
184--- /dev/null 1970-01-01 00:00:00.000000000 +0000
185+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.exp 2008-12-08 22:31:01.000000000 +0100
186@@ -0,0 +1,84 @@
187+# atomic-seq-threaded.exp -- Test case for stepping over RISC atomic code seqs.
188+# This variant testcases the code for stepping another thread while skipping
189+# over the atomic sequence in the former thread
190+# (STEPPING_PAST_SINGLESTEP_BREAKPOINT).
191+# Copyright (C) 2007 Free Software Foundation, Inc.
192+
193+# This program is free software; you can redistribute it and/or modify
194+# it under the terms of the GNU General Public License as published by
195+# the Free Software Foundation; either version 2 of the License, or
196+# (at your option) any later version.
197+#
198+# This program is distributed in the hope that it will be useful,
199+# but WITHOUT ANY WARRANTY; without even the implied warranty of
200+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
201+# GNU General Public License for more details.
202+#
203+# You should have received a copy of the GNU General Public License
204+# along with this program; if not, write to the Free Software
205+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
206+
207+# Please email any bugs, comments, and/or additions to this file to:
208+# bug-gdb@prep.ai.mit.edu
209+
210+set testfile atomic-seq-threaded
211+set srcfile ${testfile}.c
212+set binfile ${objdir}/${subdir}/${testfile}
213+
214+foreach opts {{} {compiler=gcc4} {FAIL}} {
215+ if {$opts eq "FAIL"} {
216+ return -1
217+ }
218+ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $opts]] eq "" } {
219+ break
220+ }
221+}
222+
223+gdb_exit
224+gdb_start
225+gdb_reinitialize_dir $srcdir/$subdir
226+
227+gdb_load ${binfile}
228+if ![runto_main] then {
229+ fail "Can't run to main"
230+ return 0
231+}
232+
233+# pthread_create () will not pass even on x86_64 with software watchpoint.
234+# Pass after pthread_create () without any watchpoint active.
235+set line [gdb_get_line_number "_create_after_"]
236+gdb_test "tbreak $line" \
237+ "reakpoint (\[0-9\]+) at .*$srcfile, line $line\..*" \
238+ "set breakpoint after pthread_create ()"
239+gdb_test "c" \
240+ ".*/\\* _create_after_ \\*/.*" \
241+ "run till after pthread_create ()"
242+
243+# Without a watchpoint being software no single-stepping would be used.
244+set test "Start (software) watchpoint"
245+gdb_test_multiple "watch unused" $test {
246+ -re "Watchpoint \[0-9\]+: unused.*$gdb_prompt $" {
247+ pass $test
248+ }
249+ -re "Hardware watchpoint \[0-9\]+: unused.*$gdb_prompt $" {
250+ # We do not test the goal but still the whole testcase should pass.
251+ unsupported $test
252+ }
253+}
254+
255+# More thorough testing of the scheduling logic.
256+gdb_test "set scheduler-locking step" ""
257+
258+# Critical code path is stepped through at this point.
259+set line [gdb_get_line_number "_exit_"]
260+gdb_test "tbreak $line" \
261+ "reakpoint \[0-9\]+ at .*$srcfile, line $line\..*" \
262+ "set breakpoint at _exit_"
263+gdb_test "c" \
264+ ".*/\\* _exit_ \\*/.*" \
265+ "run till _exit_"
266+
267+# Just a nonproblematic program exit.
268+gdb_test "c" \
269+ ".*Program exited normally\\..*" \
270+ "run till program exit"
This page took 0.529257 seconds and 4 git commands to generate.