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

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