Blame SOURCES/gdb-simultaneous-step-resume-breakpoint-test.patch

f9426a
--- /dev/null	2009-09-25 12:44:54.497650251 +0200
f9426a
+++ ./gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.exp	2009-09-25 17:27:12.000000000 +0200
f9426a
@@ -0,0 +1,65 @@
f9426a
+# Copyright (C) 2009 Free Software Foundation, Inc.
f9426a
+
f9426a
+# This program is free software; you can redistribute it and/or modify
f9426a
+# it under the terms of the GNU General Public License as published by
f9426a
+# the Free Software Foundation; either version 3 of the License, or
f9426a
+# (at your option) any later version.
f9426a
+#
f9426a
+# This program is distributed in the hope that it will be useful,
f9426a
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f9426a
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9426a
+# GNU General Public License for more details.
f9426a
+#
f9426a
+# You should have received a copy of the GNU General Public License
f9426a
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
f9426a
+
f9426a
+# Test multiple threads stepping into a .debug_line-less function with
f9426a
+# a breakpoint placed on its return-to-caller point.
f9426a
+
f9426a
+set testfile simultaneous-step-resume-breakpoint
f9426a
+set srcfile ${testfile}.c
f9426a
+set binfile ${objdir}/${subdir}/${testfile}
f9426a
+
f9426a
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
f9426a
+    return -1
f9426a
+}
f9426a
+
f9426a
+gdb_exit
f9426a
+gdb_start
f9426a
+gdb_reinitialize_dir $srcdir/$subdir
f9426a
+
f9426a
+# Ensure we have no debuginfo for the `sleep' call itself (=for libc).
f9426a
+gdb_test "set debug-file-directory /DoesNotExist"
f9426a
+
f9426a
+gdb_load ${binfile}
f9426a
+if ![runto_main] {
f9426a
+   return -1
f9426a
+}
f9426a
+
f9426a
+# Red Hat vendor patch does set it to "step" by default.
f9426a
+gdb_test "set scheduler-locking off"
f9426a
+
f9426a
+gdb_breakpoint [gdb_get_line_number "final-exit"]
f9426a
+
f9426a
+gdb_breakpoint [gdb_get_line_number "sleep-call"]
f9426a
+gdb_continue_to_breakpoint "sleep-call"
f9426a
+
f9426a
+gdb_test "step" "sleep-call.*" "step thread 1"
f9426a
+gdb_test "step" "sleep-call.*" "step thread 2"
f9426a
+gdb_test "step" "sleep-after.*" "step thread 3"
f9426a
+
f9426a
+set test "first continue"
f9426a
+gdb_test_multiple "continue" $test {
f9426a
+    -re "final-exit.*$gdb_prompt $" {
f9426a
+	# gdb-7.0.
f9426a
+	pass $test
f9426a
+	return
f9426a
+    }
f9426a
+    -re "sleep-after.*$gdb_prompt $" {
f9426a
+	# Fedora/RHEL branch.
f9426a
+	pass $test
f9426a
+    }
f9426a
+}
f9426a
+
f9426a
+gdb_test "continue" "sleep-after.*" "second continue"
f9426a
+gdb_test "continue" "final-exit.*" "third continue"
f9426a
--- /dev/null	2009-09-25 12:44:54.497650251 +0200
f9426a
+++ ./gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.c	2009-09-25 17:29:42.000000000 +0200
f9426a
@@ -0,0 +1,79 @@
f9426a
+/* Copyright 2009 Free Software Foundation, Inc.
f9426a
+
f9426a
+   Written by Fred Fish of Cygnus Support
f9426a
+   Contributed by Cygnus Support
f9426a
+
f9426a
+   This file is part of GDB.
f9426a
+
f9426a
+   This program is free software; you can redistribute it and/or modify
f9426a
+   it under the terms of the GNU General Public License as published by
f9426a
+   the Free Software Foundation; either version 3 of the License, or
f9426a
+   (at your option) any later version.
f9426a
+
f9426a
+   This program is distributed in the hope that it will be useful,
f9426a
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
f9426a
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9426a
+   GNU General Public License for more details.
f9426a
+
f9426a
+   You should have received a copy of the GNU General Public License
f9426a
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
f9426a
+
f9426a
+/* Test multiple threads stepping into a .debug_line-less function with
f9426a
+   a breakpoint placed on its return-to-caller point.  */
f9426a
+
f9426a
+#include <pthread.h>
f9426a
+#include <assert.h>
f9426a
+#include <unistd.h>
f9426a
+#include <errno.h>
f9426a
+#include <stdio.h>
f9426a
+
f9426a
+#define THREADS 3
f9426a
+
f9426a
+static void *
f9426a
+func (void *unused)
f9426a
+{
f9426a
+  int i;
f9426a
+
f9426a
+  errno = 0;
f9426a
+  i = 0xdeadf00d;
f9426a
+  i = sleep (THREADS);	/* sleep-call */
f9426a
+  if (errno != 0)	/* sleep-after */
f9426a
+    perror ("sleep");
f9426a
+
f9426a
+  /* The GDB bug with forgotten step-resume breakpoint could leave stale
f9426a
+     breakpoint on the I assignment making it a nop.  */
f9426a
+  if (i == 0xdeadf00d)
f9426a
+    assert (0);
f9426a
+
f9426a
+  assert (i == 0);
f9426a
+
f9426a
+  pthread_exit (NULL);
f9426a
+}
f9426a
+
f9426a
+int
f9426a
+main (void)
f9426a
+{
f9426a
+  pthread_t threads[THREADS];
f9426a
+  int threadi;
f9426a
+
f9426a
+  for (threadi = 0; threadi < THREADS; threadi++)
f9426a
+    {
f9426a
+      int i;
f9426a
+
f9426a
+      i = pthread_create (&threads[threadi], NULL, func, NULL);
f9426a
+      assert (i == 0);
f9426a
+
f9426a
+      i = sleep (1);
f9426a
+      assert (i == 0);
f9426a
+    }
f9426a
+
f9426a
+  for (threadi = 0; threadi < THREADS; threadi++)
f9426a
+    {
f9426a
+      int i;
f9426a
+
f9426a
+      i = pthread_join (threads[threadi], NULL);
f9426a
+      assert (i == 0);
f9426a
+    }
f9426a
+
f9426a
+  return 0;	/* final-exit */
f9426a
+}