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