|
|
e1d87d |
2007-06-25 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
e1d87d |
|
|
|
e1d87d |
* gdb.threads/atomic-seq-threaded.c,
|
|
|
e1d87d |
gdb.threads/atomic-seq-threaded.exp: New files.
|
|
|
e1d87d |
|
|
|
e1d87d |
Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.c
|
|
|
e1d87d |
===================================================================
|
|
|
e1d87d |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
e1d87d |
+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.c 2008-12-08 22:27:01.000000000 +0100
|
|
|
e1d87d |
@@ -0,0 +1,171 @@
|
|
|
e1d87d |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ Copyright 2007 Free Software Foundation, Inc.
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ This program is free software; you can redistribute it and/or modify
|
|
|
e1d87d |
+ it under the terms of the GNU General Public License as published by
|
|
|
e1d87d |
+ the Free Software Foundation; either version 2 of the License, or
|
|
|
e1d87d |
+ (at your option) any later version.
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ This program is distributed in the hope that it will be useful,
|
|
|
e1d87d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e1d87d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
e1d87d |
+ GNU General Public License for more details.
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ You should have received a copy of the GNU General Public License
|
|
|
e1d87d |
+ along with this program; if not, write to the Free Software
|
|
|
e1d87d |
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
e1d87d |
+ MA 02110-1301, USA. */
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+/* Test stepping over RISC atomic sequences.
|
|
|
e1d87d |
+ This variant testcases the code for stepping another thread while skipping
|
|
|
e1d87d |
+ over the atomic sequence in the former thread
|
|
|
e1d87d |
+ (STEPPING_PAST_SINGLESTEP_BREAKPOINT).
|
|
|
e1d87d |
+ Code comes from gcc/testsuite/gcc.dg/sync-2.c */
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
|
|
|
e1d87d |
+/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+/* Test functionality of the intrinsics for 'short' and 'char'. */
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+#include <stdlib.h>
|
|
|
e1d87d |
+#include <string.h>
|
|
|
e1d87d |
+#include <pthread.h>
|
|
|
e1d87d |
+#include <assert.h>
|
|
|
e1d87d |
+#include <unistd.h>
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+#define LOOPS 2
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+static int unused;
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+static char AI[18];
|
|
|
e1d87d |
+static char init_qi[18] = { 3,5,7,9,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 };
|
|
|
e1d87d |
+static char test_qi[18] = { 3,5,7,9,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 };
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+static void
|
|
|
e1d87d |
+do_qi (void)
|
|
|
e1d87d |
+{
|
|
|
e1d87d |
+ if (__sync_fetch_and_add(AI+4, 1) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_add(AI+5, 4) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_add(AI+6, 22) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_sub(AI+7, 12) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_and(AI+8, 7) != (char)-1)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_or(AI+9, 8) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_xor(AI+10, 9) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_nand(AI+11, 7) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ if (__sync_add_and_fetch(AI+12, 1) != 1)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_sub_and_fetch(AI+13, 12) != (char)-12)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_and_and_fetch(AI+14, 7) != 7)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_or_and_fetch(AI+15, 8) != 8)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_xor_and_fetch(AI+16, 9) != 9)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_nand_and_fetch(AI+17, 7) != 7)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+}
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+static short AL[18];
|
|
|
e1d87d |
+static short init_hi[18] = { 3,5,7,9,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0 };
|
|
|
e1d87d |
+static short test_hi[18] = { 3,5,7,9,1,4,22,-12,7,8,9,7,1,-12,7,8,9,7 };
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+static void
|
|
|
e1d87d |
+do_hi (void)
|
|
|
e1d87d |
+{
|
|
|
e1d87d |
+ if (__sync_fetch_and_add(AL+4, 1) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_add(AL+5, 4) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_add(AL+6, 22) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_sub(AL+7, 12) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_and(AL+8, 7) != -1)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_or(AL+9, 8) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_xor(AL+10, 9) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_fetch_and_nand(AL+11, 7) != 0)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ if (__sync_add_and_fetch(AL+12, 1) != 1)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_sub_and_fetch(AL+13, 12) != -12)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_and_and_fetch(AL+14, 7) != 7)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_or_and_fetch(AL+15, 8) != 8)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_xor_and_fetch(AL+16, 9) != 9)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ if (__sync_nand_and_fetch(AL+17, 7) != 7)
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+}
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+static void *
|
|
|
e1d87d |
+start1 (void *arg)
|
|
|
e1d87d |
+{
|
|
|
e1d87d |
+ unsigned loop;
|
|
|
e1d87d |
+ sleep(1);
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ for (loop = 0; loop < LOOPS; loop++)
|
|
|
e1d87d |
+ {
|
|
|
e1d87d |
+ memcpy(AI, init_qi, sizeof(init_qi));
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ do_qi ();
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ if (memcmp (AI, test_qi, sizeof(test_qi)))
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ }
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ return arg; /* _delete1_ */
|
|
|
e1d87d |
+}
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+static void *
|
|
|
e1d87d |
+start2 (void *arg)
|
|
|
e1d87d |
+{
|
|
|
e1d87d |
+ unsigned loop;
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ for (loop = 0; loop < LOOPS; loop++)
|
|
|
e1d87d |
+ {
|
|
|
e1d87d |
+ memcpy(AL, init_hi, sizeof(init_hi));
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ do_hi ();
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ if (memcmp (AL, test_hi, sizeof(test_hi)))
|
|
|
e1d87d |
+ abort ();
|
|
|
e1d87d |
+ }
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ return arg; /* _delete2_ */
|
|
|
e1d87d |
+}
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+int
|
|
|
e1d87d |
+main (int argc, char **argv)
|
|
|
e1d87d |
+{
|
|
|
e1d87d |
+ pthread_t thread;
|
|
|
e1d87d |
+ int i;
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ i = pthread_create (&thread, NULL, start1, NULL); /* _create_ */
|
|
|
e1d87d |
+ assert (i == 0); /* _create_after_ */
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ sleep (1);
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ start2 (NULL);
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ i = pthread_join (thread, NULL); /* _delete_ */
|
|
|
e1d87d |
+ assert (i == 0);
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+ return 0; /* _exit_ */
|
|
|
e1d87d |
+}
|
|
|
e1d87d |
Index: gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.exp
|
|
|
e1d87d |
===================================================================
|
|
|
e1d87d |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
e1d87d |
+++ gdb-6.8.50.20081128/gdb/testsuite/gdb.threads/atomic-seq-threaded.exp 2008-12-08 22:31:01.000000000 +0100
|
|
|
e1d87d |
@@ -0,0 +1,84 @@
|
|
|
e1d87d |
+# atomic-seq-threaded.exp -- Test case for stepping over RISC atomic code seqs.
|
|
|
e1d87d |
+# This variant testcases the code for stepping another thread while skipping
|
|
|
e1d87d |
+# over the atomic sequence in the former thread
|
|
|
e1d87d |
+# (STEPPING_PAST_SINGLESTEP_BREAKPOINT).
|
|
|
e1d87d |
+# Copyright (C) 2007 Free Software Foundation, Inc.
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+# This program is free software; you can redistribute it and/or modify
|
|
|
e1d87d |
+# it under the terms of the GNU General Public License as published by
|
|
|
e1d87d |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
e1d87d |
+# (at your option) any later version.
|
|
|
e1d87d |
+#
|
|
|
e1d87d |
+# This program is distributed in the hope that it will be useful,
|
|
|
e1d87d |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e1d87d |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
e1d87d |
+# GNU General Public License for more details.
|
|
|
e1d87d |
+#
|
|
|
e1d87d |
+# You should have received a copy of the GNU General Public License
|
|
|
e1d87d |
+# along with this program; if not, write to the Free Software
|
|
|
e1d87d |
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+# Please email any bugs, comments, and/or additions to this file to:
|
|
|
e1d87d |
+# bug-gdb@prep.ai.mit.edu
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+set testfile atomic-seq-threaded
|
|
|
e1d87d |
+set srcfile ${testfile}.c
|
|
|
e1d87d |
+set binfile [standard_output_file ${testfile}]
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+foreach opts {{} {compiler=gcc4} {FAIL}} {
|
|
|
e1d87d |
+ if {$opts eq "FAIL"} {
|
|
|
e1d87d |
+ return -1
|
|
|
e1d87d |
+ }
|
|
|
e1d87d |
+ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $opts]] eq "" } {
|
|
|
e1d87d |
+ break
|
|
|
e1d87d |
+ }
|
|
|
e1d87d |
+}
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+gdb_exit
|
|
|
e1d87d |
+gdb_start
|
|
|
e1d87d |
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+gdb_load ${binfile}
|
|
|
e1d87d |
+if ![runto_main] then {
|
|
|
e1d87d |
+ fail "Can't run to main"
|
|
|
e1d87d |
+ return 0
|
|
|
e1d87d |
+}
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+# pthread_create () will not pass even on x86_64 with software watchpoint.
|
|
|
e1d87d |
+# Pass after pthread_create () without any watchpoint active.
|
|
|
e1d87d |
+set line [gdb_get_line_number "_create_after_"]
|
|
|
e1d87d |
+gdb_test "tbreak $line" \
|
|
|
e1d87d |
+ "reakpoint (\[0-9\]+) at .*$srcfile, line $line\..*" \
|
|
|
e1d87d |
+ "set breakpoint after pthread_create ()"
|
|
|
e1d87d |
+gdb_test "c" \
|
|
|
e1d87d |
+ ".*/\\* _create_after_ \\*/.*" \
|
|
|
e1d87d |
+ "run till after pthread_create ()"
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+# Without a watchpoint being software no single-stepping would be used.
|
|
|
e1d87d |
+set test "Start (software) watchpoint"
|
|
|
e1d87d |
+gdb_test_multiple "watch unused" $test {
|
|
|
e1d87d |
+ -re "Watchpoint \[0-9\]+: unused.*$gdb_prompt $" {
|
|
|
e1d87d |
+ pass $test
|
|
|
e1d87d |
+ }
|
|
|
e1d87d |
+ -re "Hardware watchpoint \[0-9\]+: unused.*$gdb_prompt $" {
|
|
|
e1d87d |
+ # We do not test the goal but still the whole testcase should pass.
|
|
|
e1d87d |
+ unsupported $test
|
|
|
e1d87d |
+ }
|
|
|
e1d87d |
+}
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+# More thorough testing of the scheduling logic.
|
|
|
e1d87d |
+gdb_test "set scheduler-locking step" ""
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+# Critical code path is stepped through at this point.
|
|
|
e1d87d |
+set line [gdb_get_line_number "_exit_"]
|
|
|
e1d87d |
+gdb_test "tbreak $line" \
|
|
|
e1d87d |
+ "reakpoint \[0-9\]+ at .*$srcfile, line $line\..*" \
|
|
|
e1d87d |
+ "set breakpoint at _exit_"
|
|
|
e1d87d |
+gdb_test "c" \
|
|
|
e1d87d |
+ ".*/\\* _exit_ \\*/.*" \
|
|
|
e1d87d |
+ "run till _exit_"
|
|
|
e1d87d |
+
|
|
|
e1d87d |
+# Just a nonproblematic program exit.
|
|
|
e1d87d |
+gdb_test "c" \
|
|
|
e1d87d |
+ ".*Program exited normally\\..*" \
|
|
|
e1d87d |
+ "run till program exit"
|