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

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