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

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