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

01917d
--- /dev/null	2009-09-25 12:44:54.497650251 +0200
01917d
+++ ./gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.exp	2009-09-25 17:27:12.000000000 +0200
01917d
@@ -0,0 +1,65 @@
01917d
+# Copyright (C) 2009 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 3 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, see <http://www.gnu.org/licenses/>.  */
01917d
+
01917d
+# Test multiple threads stepping into a .debug_line-less function with
01917d
+# a breakpoint placed on its return-to-caller point.
01917d
+
01917d
+set testfile simultaneous-step-resume-breakpoint
01917d
+set srcfile ${testfile}.c
01917d
+set binfile ${objdir}/${subdir}/${testfile}
01917d
+
01917d
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
01917d
+    return -1
01917d
+}
01917d
+
01917d
+gdb_exit
01917d
+gdb_start
01917d
+gdb_reinitialize_dir $srcdir/$subdir
01917d
+
01917d
+# Ensure we have no debuginfo for the `sleep' call itself (=for libc).
01917d
+gdb_test "set debug-file-directory /DoesNotExist"
01917d
+
01917d
+gdb_load ${binfile}
01917d
+if ![runto_main] {
01917d
+   return -1
01917d
+}
01917d
+
01917d
+# Red Hat vendor patch does set it to "step" by default.
01917d
+gdb_test "set scheduler-locking off"
01917d
+
01917d
+gdb_breakpoint [gdb_get_line_number "final-exit"]
01917d
+
01917d
+gdb_breakpoint [gdb_get_line_number "sleep-call"]
01917d
+gdb_continue_to_breakpoint "sleep-call"
01917d
+
01917d
+gdb_test "step" "sleep-call.*" "step thread 1"
01917d
+gdb_test "step" "sleep-call.*" "step thread 2"
01917d
+gdb_test "step" "sleep-after.*" "step thread 3"
01917d
+
01917d
+set test "first continue"
01917d
+gdb_test_multiple "continue" $test {
01917d
+    -re "final-exit.*$gdb_prompt $" {
01917d
+	# gdb-7.0.
01917d
+	pass $test
01917d
+	return
01917d
+    }
01917d
+    -re "sleep-after.*$gdb_prompt $" {
01917d
+	# Fedora/RHEL branch.
01917d
+	pass $test
01917d
+    }
01917d
+}
01917d
+
01917d
+gdb_test "continue" "sleep-after.*" "second continue"
01917d
+gdb_test "continue" "final-exit.*" "third continue"
01917d
--- /dev/null	2009-09-25 12:44:54.497650251 +0200
01917d
+++ ./gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.c	2009-09-25 17:29:42.000000000 +0200
01917d
@@ -0,0 +1,79 @@
01917d
+/* Copyright 2009 Free Software Foundation, Inc.
01917d
+
01917d
+   Written by Fred Fish of Cygnus Support
01917d
+   Contributed by Cygnus Support
01917d
+
01917d
+   This file is part of GDB.
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 3 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, see <http://www.gnu.org/licenses/>.  */
01917d
+
01917d
+/* Test multiple threads stepping into a .debug_line-less function with
01917d
+   a breakpoint placed on its return-to-caller point.  */
01917d
+
01917d
+#include <pthread.h>
01917d
+#include <assert.h>
01917d
+#include <unistd.h>
01917d
+#include <errno.h>
01917d
+#include <stdio.h>
01917d
+
01917d
+#define THREADS 3
01917d
+
01917d
+static void *
01917d
+func (void *unused)
01917d
+{
01917d
+  int i;
01917d
+
01917d
+  errno = 0;
01917d
+  i = 0xdeadf00d;
01917d
+  i = sleep (THREADS);	/* sleep-call */
01917d
+  if (errno != 0)	/* sleep-after */
01917d
+    perror ("sleep");
01917d
+
01917d
+  /* The GDB bug with forgotten step-resume breakpoint could leave stale
01917d
+     breakpoint on the I assignment making it a nop.  */
01917d
+  if (i == 0xdeadf00d)
01917d
+    assert (0);
01917d
+
01917d
+  assert (i == 0);
01917d
+
01917d
+  pthread_exit (NULL);
01917d
+}
01917d
+
01917d
+int
01917d
+main (void)
01917d
+{
01917d
+  pthread_t threads[THREADS];
01917d
+  int threadi;
01917d
+
01917d
+  for (threadi = 0; threadi < THREADS; threadi++)
01917d
+    {
01917d
+      int i;
01917d
+
01917d
+      i = pthread_create (&threads[threadi], NULL, func, NULL);
01917d
+      assert (i == 0);
01917d
+
01917d
+      i = sleep (1);
01917d
+      assert (i == 0);
01917d
+    }
01917d
+
01917d
+  for (threadi = 0; threadi < THREADS; threadi++)
01917d
+    {
01917d
+      int i;
01917d
+
01917d
+      i = pthread_join (threads[threadi], NULL);
01917d
+      assert (i == 0);
01917d
+    }
01917d
+
01917d
+  return 0;	/* final-exit */
01917d
+}