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