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

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