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

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