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

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