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

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