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

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