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

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