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

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