---- /dev/null 2008-05-02 23:36:22.370004160 +0200
-+++ gdb-6.8/gdb/testsuite/gdb.base/gcore-shmid0.exp 2008-05-03 22:36:56.000000000 +0200
-@@ -0,0 +1,120 @@
-+# Copyright 2007 Free Software Foundation, Inc.
+Index: gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.exp
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.exp 2009-06-29 16:24:36.000000000 +0200
+@@ -0,0 +1,96 @@
++# Copyright 2007, 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
-+# Please email any bugs, comments, and/or additions to this file to:
-+# bug-gdb@prep.ai.mit.edu
-+
+# Test GDB's handling of gcore for mapping with a name but zero inode.
+
-+set testfile "gcore-shmid0"
-+set srcfile ${testfile}.c
-+set binfile ${objdir}/${subdir}/${testfile}
-+
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-+ untested gcore.exp
-+ return -1
++if { [prepare_for_testing gcore-shmid0.exp gcore-shmid0] } {
++ return -1
+}
+
-+# Start with a fresh gdb.
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
+# Does this gdb support gcore?
-+send_gdb "help gcore\n"
-+gdb_expect {
++set test "help gcore"
++gdb_test_multiple $test $test {
+ -re "Undefined command: .gcore.*$gdb_prompt $" {
+ # gcore command not supported -- nothing to test here.
+ unsupported "gdb does not support gcore on this target"
+ return -1;
+ }
+ -re "Save a core file .*$gdb_prompt $" {
-+ pass "help gcore"
-+ }
-+ -re ".*$gdb_prompt $" {
-+ fail "help gcore"
-+ }
-+ timeout {
-+ fail "help gcore (timeout)"
++ pass $test
+ }
+}
+
+ -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
+ unsupported $test
+ }
-+ eof {
-+ fail $test
-+ }
+}
+
+# Be sure to remove the handle first.
+ fail $test
+ }
+}
---- /dev/null 2008-05-02 23:36:22.370004160 +0200
-+++ gdb-6.8/gdb/testsuite/gdb.base/gcore-shmid0.c 2008-05-03 22:39:10.000000000 +0200
-@@ -0,0 +1,95 @@
-+/* Copyright 2007 Free Software Foundation, Inc.
+Index: gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.c 2009-06-29 16:22:49.000000000 +0200
+@@ -0,0 +1,123 @@
++/* Copyright 2007, 2009 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+#include <unistd.h>
+#include <assert.h>
+
-+/* We need a backtrace through the stack. */
++/* The same test running in a parallel testsuite may steal us the zero SID,
++ even if we never get any EEXIST. Just try a while. */
++
++#define TIMEOUT_SEC 10
+
+static void
+initialized (void)
+{
+ int sid;
+ unsigned int *addr = (void *) -1L;
-+ int try;
++ int attempt, round = 0;
++ time_t ts_start, ts;
+
-+ /* The generated SID will cycle with an increment of 32768, try until it
++ if (time (&ts_start) == (time_t) -1)
++ {
++ printf ("time (): %m\n");
++ exit (1);
++ }
++
++ /* The generated SID will cycle with an increment of 32768, attempt until it
+ * wraps to 0. */
+
-+ for (try = 0; addr == (void *) -1L; try++)
++ for (attempt = 0; addr == (void *) -1L; attempt++)
+ {
-+ /* At least kernel-2.6.25-8.fc9.x86_64 just never returns the value 0 by
-+ shmget(2). */
-+ if (try > 0x10000)
++ /* kernel-2.6.25-8.fc9.x86_64 just never returns the value 0 by
++ shmget(2). shmget returns SID range 0..1<<31 in steps of 32768,
++ 0x1000 should be enough but wrap the range it to be sure. */
++
++ if (attempt > 0x21000)
+ {
-+ printf ("Problem no longer reproducible on this kernel (try %d)\n",
-+ try);
++ if (time (&ts) == (time_t) -1)
++ {
++ printf ("time (): %m\n");
++ exit (1);
++ }
++
++ if (ts >= ts_start && ts < ts_start + TIMEOUT_SEC)
++ {
++ attempt = 0;
++ round++;
++ continue;
++ }
++
++ printf ("Problem is not reproducible on this kernel (attempt %d, "
++ "round %d))\n", attempt, round);
+ unresolved ();
+ exit (1);
+ }
+ sid = shmget ((key_t) rand (), 0x1000, IPC_CREAT | IPC_EXCL | 0777);
+ if (sid == -1)
+ {
++ if (errno == EEXIST)
++ continue;
++
+ printf ("shmget (%d, 0x1000, IPC_CREAT): errno %d\n", 0, errno);
+ exit (1);
+ }