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

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