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

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