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

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