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

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