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

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